mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-07 15:18:08 +00:00
fix(core/t2b1): properly stop auto-mover on edges
fixes #3692 [no changelog]
This commit is contained in:
parent
ac6faa15bc
commit
88a76b3063
@ -425,24 +425,32 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Go to the choice visually on the left.
|
/// Go to the choice visually on the left.
|
||||||
fn move_left(&mut self, ctx: &mut EventCtx) {
|
fn move_left(&mut self, ctx: &mut EventCtx) -> bool {
|
||||||
if self.has_previous_choice() {
|
if self.has_previous_choice() {
|
||||||
self.decrease_page_counter();
|
self.decrease_page_counter();
|
||||||
self.update(ctx);
|
self.update(ctx);
|
||||||
|
true
|
||||||
} else if self.is_carousel {
|
} else if self.is_carousel {
|
||||||
self.page_counter_to_max();
|
self.page_counter_to_max();
|
||||||
self.update(ctx);
|
self.update(ctx);
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Go to the choice visually on the right.
|
/// Go to the choice visually on the right.
|
||||||
fn move_right(&mut self, ctx: &mut EventCtx) {
|
fn move_right(&mut self, ctx: &mut EventCtx) -> bool {
|
||||||
if self.has_next_choice() {
|
if self.has_next_choice() {
|
||||||
self.increase_page_counter();
|
self.increase_page_counter();
|
||||||
self.update(ctx);
|
self.update(ctx);
|
||||||
|
true
|
||||||
} else if self.is_carousel {
|
} else if self.is_carousel {
|
||||||
self.page_counter_to_zero();
|
self.page_counter_to_zero();
|
||||||
self.update(ctx);
|
self.update(ctx);
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -496,8 +504,8 @@ where
|
|||||||
match animation_direction {
|
match animation_direction {
|
||||||
ButtonPos::Left => self.move_left(ctx),
|
ButtonPos::Left => self.move_left(ctx),
|
||||||
ButtonPos::Right => self.move_right(ctx),
|
ButtonPos::Right => self.move_right(ctx),
|
||||||
_ => {}
|
_ => false,
|
||||||
}
|
};
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -508,10 +516,13 @@ where
|
|||||||
|
|
||||||
// Possible automatic movement when user is holding left or right button.
|
// Possible automatic movement when user is holding left or right button.
|
||||||
if let Some(auto_move_direction) = self.holding_mover.event(ctx, event) {
|
if let Some(auto_move_direction) = self.holding_mover.event(ctx, event) {
|
||||||
match auto_move_direction {
|
let moved = match auto_move_direction {
|
||||||
ButtonPos::Left => self.move_left(ctx),
|
ButtonPos::Left => self.move_left(ctx),
|
||||||
ButtonPos::Right => self.move_right(ctx),
|
ButtonPos::Right => self.move_right(ctx),
|
||||||
_ => {}
|
_ => false,
|
||||||
|
};
|
||||||
|
if !moved {
|
||||||
|
self.holding_mover.stop_moving();
|
||||||
}
|
}
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
@ -535,8 +546,14 @@ where
|
|||||||
}
|
}
|
||||||
} else if let Some(ButtonControllerMsg::Pressed(pos)) = button_event {
|
} else if let Some(ButtonControllerMsg::Pressed(pos)) = button_event {
|
||||||
// Starting the movement when left/right button is pressed.
|
// Starting the movement when left/right button is pressed.
|
||||||
if matches!(pos, ButtonPos::Left | ButtonPos::Right) {
|
match pos {
|
||||||
self.holding_mover.start_moving(ctx, pos);
|
ButtonPos::Left if self.has_previous_choice() || self.is_carousel => {
|
||||||
|
self.holding_mover.start_moving(ctx, ButtonPos::Left);
|
||||||
|
}
|
||||||
|
ButtonPos::Right if self.has_next_choice() || self.is_carousel => {
|
||||||
|
self.holding_mover.start_moving(ctx, ButtonPos::Right);
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user