From 1ef6773dced7088b2a0ce4909db368384fb56ef6 Mon Sep 17 00:00:00 2001 From: Inaha Date: Wed, 27 Mar 2024 14:46:59 +0800 Subject: [PATCH] add some animation --- resources/resources.gresource.xml | 1 + resources/ui/episoderow.ui | 13 ++++ resources/ui/history.ui | 9 ++- resources/ui/item.ui | 10 ++- resources/ui/search.ui | 9 ++- src/ui/mod.rs | 2 +- src/ui/provider/episoderowitem.rs | 58 +++++++++++++++++ src/ui/provider/mod.rs | 1 + src/ui/widgets/episoderow.rs | 102 ++++++++++++++++++++++++++++++ src/ui/widgets/history.rs | 4 ++ src/ui/widgets/item.rs | 6 +- src/ui/widgets/mod.rs | 3 +- src/ui/widgets/search.rs | 5 ++ 13 files changed, 216 insertions(+), 7 deletions(-) create mode 100644 resources/ui/episoderow.ui create mode 100644 src/ui/provider/episoderowitem.rs create mode 100644 src/ui/provider/mod.rs create mode 100644 src/ui/widgets/episoderow.rs diff --git a/resources/resources.gresource.xml b/resources/resources.gresource.xml index bb49e038..77eb57ef 100644 --- a/resources/resources.gresource.xml +++ b/resources/resources.gresource.xml @@ -7,5 +7,6 @@ item.ui movie.ui history.ui + episoderow.ui diff --git a/resources/ui/episoderow.ui b/resources/ui/episoderow.ui new file mode 100644 index 00000000..153d141e --- /dev/null +++ b/resources/ui/episoderow.ui @@ -0,0 +1,13 @@ + + + + diff --git a/resources/ui/history.ui b/resources/ui/history.ui index 9e115c03..471cc8d9 100644 --- a/resources/ui/history.ui +++ b/resources/ui/history.ui @@ -26,7 +26,14 @@ - + + crossfade + 700 + False + + + + diff --git a/resources/ui/item.ui b/resources/ui/item.ui index 00737c2d..33313c27 100644 --- a/resources/ui/item.ui +++ b/resources/ui/item.ui @@ -55,8 +55,14 @@ fill 3 - - horizontal + + 700 + False + + + horizontal + + diff --git a/resources/ui/search.ui b/resources/ui/search.ui index 7b58668d..95eb8eb0 100644 --- a/resources/ui/search.ui +++ b/resources/ui/search.ui @@ -30,7 +30,14 @@ - + + crossfade + 700 + False + + + + diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 70a492b0..2759dd47 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -1,4 +1,4 @@ - +mod provider; mod image; mod network; mod new_dropsel; diff --git a/src/ui/provider/episoderowitem.rs b/src/ui/provider/episoderowitem.rs new file mode 100644 index 00000000..969aa334 --- /dev/null +++ b/src/ui/provider/episoderowitem.rs @@ -0,0 +1,58 @@ +mod imp { + use std::cell::RefCell; + + use glib::Properties; + use gtk::glib; + use gtk::prelude::*; + use gtk::subclass::prelude::*; + + use super::TaskData; + + // ANCHOR: struct_and_subclass + // Object holding the state + #[derive(Properties, Default)] + #[properties(wrapper_type = super::EpisodeObject)] + pub struct EpisodeObject { + #[property(name = "imageid", get, set, type = String, member = imageid)] + #[property(name = "label", get, set, type = String, member = label)] + pub data: RefCell, + } + + // The central trait for subclassing a GObject + #[glib::object_subclass] + impl ObjectSubclass for EpisodeObject { + const NAME: &'static str = "EpisodeObject"; + type Type = super::EpisodeObject; + } + + // Trait shared by all GObjects + #[glib::derived_properties] + impl ObjectImpl for EpisodeObject {} + // ANCHOR_END: struct_and_subclass +} + +use glib::Object; +use gtk::glib; + +// ANCHOR: glib_wrapper_and_new +glib::wrapper! { + pub struct EpisodeObject(ObjectSubclass); +} + +impl EpisodeObject { + pub fn new(imageid: bool, label: String) -> Self { + Object::builder() + .property("imageid", imageid) + .property("label", label) + .build() + } +} +// ANCHOR_END: glib_wrapper_and_new + +// ANCHOR: task_data +#[derive(Default)] +pub struct TaskData { + pub imageid: String, + pub label: String, +} +// ANCHOR: task_data \ No newline at end of file diff --git a/src/ui/provider/mod.rs b/src/ui/provider/mod.rs new file mode 100644 index 00000000..e6dda476 --- /dev/null +++ b/src/ui/provider/mod.rs @@ -0,0 +1 @@ +pub mod episoderowitem; \ No newline at end of file diff --git a/src/ui/widgets/episoderow.rs b/src/ui/widgets/episoderow.rs new file mode 100644 index 00000000..40cae9c9 --- /dev/null +++ b/src/ui/widgets/episoderow.rs @@ -0,0 +1,102 @@ +use glib::Object; +use gtk::prelude::*; +use gtk::subclass::prelude::*; +use gtk::{glib, pango}; +use pango::{AttrInt, AttrList}; + +use crate::ui::provider::episoderowitem::EpisodeObject; + +mod imp { + use std::cell::RefCell; + + use glib::Binding; + use gtk::subclass::prelude::*; + use gtk::{glib, CheckButton, CompositeTemplate, Label, Picture}; + + // Object holding the state + #[derive(Default, CompositeTemplate)] + #[template(resource = "/moe/tsukimi/episoderow.ui")] + pub struct EpisodeRow { + #[template_child] + pub image: TemplateChild, + #[template_child] + pub content_label: TemplateChild