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:
parent
d86a17f76e
commit
b5dbfb1a86
@ -182,12 +182,16 @@ impl App {
|
|||||||
Ok(Action::ShowWidgetAnimated) => {
|
Ok(Action::ShowWidgetAnimated) => {
|
||||||
let shows = content.get_shows();
|
let shows = content.get_shows();
|
||||||
let mut pop = shows.borrow().populated();
|
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) => {
|
Ok(Action::ShowShowsAnimated) => {
|
||||||
let shows = content.get_shows();
|
let shows = content.get_shows();
|
||||||
let mut pop = shows.borrow().populated();
|
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::HeaderBarShowTile(title)) => headerbar.switch_to_back(&title),
|
||||||
Ok(Action::HeaderBarNormal) => headerbar.switch_to_normal(),
|
Ok(Action::HeaderBarNormal) => headerbar.switch_to_normal(),
|
||||||
|
|||||||
@ -72,7 +72,7 @@ impl PopulatedStack {
|
|||||||
// removal and insertion in the gtk::Stack, so we have
|
// removal and insertion in the gtk::Stack, so we have
|
||||||
// to make sure it will stay the same.
|
// to make sure it will stay the same.
|
||||||
let s = self.state;
|
let s = self.state;
|
||||||
self.switch_visible(s);
|
self.switch_visible(s, gtk::StackTransitionType::None);
|
||||||
|
|
||||||
old.destroy();
|
old.destroy();
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -95,7 +95,7 @@ impl PopulatedStack {
|
|||||||
// removal and insertion in the gtk::Stack, so we have
|
// removal and insertion in the gtk::Stack, so we have
|
||||||
// to make sure it will stay the same.
|
// to make sure it will stay the same.
|
||||||
let s = self.state;
|
let s = self.state;
|
||||||
self.switch_visible(s);
|
self.switch_visible(s, gtk::StackTransitionType::None);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -114,7 +114,7 @@ impl PopulatedStack {
|
|||||||
// removal and insertion in the gtk::Stack, so we have
|
// removal and insertion in the gtk::Stack, so we have
|
||||||
// to make sure it will stay the same.
|
// to make sure it will stay the same.
|
||||||
let s = self.state;
|
let s = self.state;
|
||||||
self.switch_visible(s);
|
self.switch_visible(s, gtk::StackTransitionType::None);
|
||||||
|
|
||||||
old.destroy();
|
old.destroy();
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -135,18 +135,16 @@ impl PopulatedStack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn switch_visible(&mut self, state: PopulatedState) {
|
pub fn switch_visible(&mut self, state: PopulatedState, animation: gtk::StackTransitionType) {
|
||||||
use self::PopulatedState::*;
|
use self::PopulatedState::*;
|
||||||
|
|
||||||
match state {
|
match state {
|
||||||
View => {
|
View => {
|
||||||
self.stack
|
self.stack.set_visible_child_full("shows", animation);
|
||||||
.set_visible_child_full("shows", gtk::StackTransitionType::SlideRight);
|
|
||||||
self.state = View;
|
self.state = View;
|
||||||
}
|
}
|
||||||
Widget => {
|
Widget => {
|
||||||
self.stack
|
self.stack.set_visible_child_full("widget", animation);
|
||||||
.set_visible_child_full("widget", gtk::StackTransitionType::SlideLeft);
|
|
||||||
self.state = Widget;
|
self.state = Widget;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user