PopulatedStack: Allow for more control over the stack transitions.

When you just update/replace the widget there is no need for an animation
to occur. Thus why animations where broken before. This commit is not ideal
as it makes it the responsibility of the caller to declare valid(UX wise)
transitions.
This commit is contained in:
Jordan Petridis
2018-05-04 11:32:50 +03:00
parent d86a17f76e
commit b5dbfb1a86
2 changed files with 12 additions and 10 deletions
+6 -2
View File
@@ -182,12 +182,16 @@ impl App {
Ok(Action::ShowWidgetAnimated) => {
let shows = content.get_shows();
let mut pop = shows.borrow().populated();
pop.borrow_mut().switch_visible(PopulatedState::Widget);
pop.borrow_mut().switch_visible(
PopulatedState::Widget,
gtk::StackTransitionType::SlideLeft,
);
}
Ok(Action::ShowShowsAnimated) => {
let shows = content.get_shows();
let mut pop = shows.borrow().populated();
pop.borrow_mut().switch_visible(PopulatedState::View);
pop.borrow_mut()
.switch_visible(PopulatedState::View, gtk::StackTransitionType::SlideRight);
}
Ok(Action::HeaderBarShowTile(title)) => headerbar.switch_to_back(&title),
Ok(Action::HeaderBarNormal) => headerbar.switch_to_normal(),
+6 -8
View File
@@ -72,7 +72,7 @@ impl PopulatedStack {
// removal and insertion in the gtk::Stack, so we have
// to make sure it will stay the same.
let s = self.state;
self.switch_visible(s);
self.switch_visible(s, gtk::StackTransitionType::None);
old.destroy();
Ok(())
@@ -95,7 +95,7 @@ impl PopulatedStack {
// removal and insertion in the gtk::Stack, so we have
// to make sure it will stay the same.
let s = self.state;
self.switch_visible(s);
self.switch_visible(s, gtk::StackTransitionType::None);
Ok(())
}
@@ -114,7 +114,7 @@ impl PopulatedStack {
// removal and insertion in the gtk::Stack, so we have
// to make sure it will stay the same.
let s = self.state;
self.switch_visible(s);
self.switch_visible(s, gtk::StackTransitionType::None);
old.destroy();
Ok(())
@@ -135,18 +135,16 @@ impl PopulatedStack {
}
#[inline]
pub fn switch_visible(&mut self, state: PopulatedState) {
pub fn switch_visible(&mut self, state: PopulatedState, animation: gtk::StackTransitionType) {
use self::PopulatedState::*;
match state {
View => {
self.stack
.set_visible_child_full("shows", gtk::StackTransitionType::SlideRight);
self.stack.set_visible_child_full("shows", animation);
self.state = View;
}
Widget => {
self.stack
.set_visible_child_full("widget", gtk::StackTransitionType::SlideLeft);
self.stack.set_visible_child_full("widget", animation);
self.state = Widget;
}
}