imagePage: Make crossfade from spinner work
It did not work before because the spinner page did not take up the complete stack. Also hiding the spinner when animating out of it since it can be pretty dominant. Especially, since it's usually not really shown before but the animation starts emediately instead. Closes #153 Part-of: <https://gitlab.gnome.org/Incubator/loupe/-/merge_requests/205>
This commit is contained in:
parent
7c227f75a8
commit
c42fe235c6
2 changed files with 28 additions and 8 deletions
|
|
@ -39,12 +39,14 @@ mod imp {
|
|||
#[template_child]
|
||||
pub(super) stack: TemplateChild<gtk::Stack>,
|
||||
#[template_child]
|
||||
pub(super) spinner: TemplateChild<gtk::Spinner>,
|
||||
pub(super) spinner_page: TemplateChild<gtk::Widget>,
|
||||
#[template_child]
|
||||
pub(super) error_page: TemplateChild<adw::StatusPage>,
|
||||
#[template_child]
|
||||
pub(super) image_stack_page: TemplateChild<gtk::Widget>,
|
||||
#[template_child]
|
||||
pub(super) spinner: TemplateChild<gtk::Spinner>,
|
||||
#[template_child]
|
||||
pub(super) scrolled_window: TemplateChild<gtk::ScrolledWindow>,
|
||||
#[template_child]
|
||||
pub(super) image: TemplateChild<LpImage>,
|
||||
|
|
@ -108,10 +110,20 @@ mod imp {
|
|||
gesture.set_state(gtk::EventSequenceState::Claimed);
|
||||
}));
|
||||
|
||||
self.stack
|
||||
.connect_visible_child_notify(clone!(@weak obj => move |stack| {
|
||||
let imp = obj.imp();
|
||||
let spinner_visible =
|
||||
stack.visible_child().as_ref() == Some(imp.spinner_page.upcast_ref());
|
||||
// Hide spinner for crossfading into other content since it does not look great
|
||||
imp.spinner.set_visible(spinner_visible);
|
||||
}));
|
||||
|
||||
obj.image().connect_notify_local(
|
||||
Some("is-loaded"),
|
||||
clone!(@weak obj => move |_,_| {
|
||||
if obj.image().is_loaded() {
|
||||
log::debug!("Showing image");
|
||||
obj.imp()
|
||||
.stack
|
||||
.set_visible_child(&*obj.imp().image_stack_page);
|
||||
|
|
@ -127,7 +139,6 @@ mod imp {
|
|||
}
|
||||
}),
|
||||
);
|
||||
|
||||
// Do not waste CPU on spinner if it is not visible
|
||||
self.spinner.connect_map(|s| s.start());
|
||||
self.spinner.connect_unmap(|s| s.stop());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue