fix(core/ui): T3T1 always detect swipes on entire screen

[no changelog]
pull/3874/head
Martin Milata 2 months ago
parent d6152c02e9
commit bd8ce6e55d

@ -51,7 +51,7 @@ where
} }
} }
#[cfg(all(feature = "micropython", feature = "touch"))] #[cfg(all(feature = "micropython", feature = "touch", feature = "new_rendering"))]
impl<T, F> crate::ui::flow::Swipable for MsgMap<T, F> impl<T, F> crate::ui::flow::Swipable for MsgMap<T, F>
where where
T: Component + crate::ui::flow::Swipable, T: Component + crate::ui::flow::Swipable,

@ -24,10 +24,8 @@ impl SwipeDirection {
} }
} }
/// Copy of `model_tt/component/swipe.rs` but without the backlight handling.
#[derive(Clone)] #[derive(Clone)]
pub struct Swipe { pub struct Swipe {
pub area: Rect,
pub allow_up: bool, pub allow_up: bool,
pub allow_down: bool, pub allow_down: bool,
pub allow_left: bool, pub allow_left: bool,
@ -42,7 +40,6 @@ impl Swipe {
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
area: Rect::zero(),
allow_up: false, allow_up: false,
allow_down: false, allow_down: false,
allow_left: false, allow_left: false,
@ -92,8 +89,7 @@ impl Component for Swipe {
type Msg = SwipeDirection; type Msg = SwipeDirection;
fn place(&mut self, bounds: Rect) -> Rect { fn place(&mut self, bounds: Rect) -> Rect {
self.area = bounds; bounds
self.area
} }
fn event(&mut self, _ctx: &mut EventCtx, event: Event) -> Option<Self::Msg> { fn event(&mut self, _ctx: &mut EventCtx, event: Event) -> Option<Self::Msg> {
@ -101,7 +97,7 @@ impl Component for Swipe {
return None; return None;
} }
match (event, self.origin) { match (event, self.origin) {
(Event::Touch(TouchEvent::TouchStart(pos)), _) if self.area.contains(pos) => { (Event::Touch(TouchEvent::TouchStart(pos)), _) => {
// Mark the starting position of this touch. // Mark the starting position of this touch.
self.origin.replace(pos); self.origin.replace(pos);
} }

@ -142,7 +142,7 @@ impl<T: Component + Paginate + Clone> Swipable for SwipePage<T> {
} }
self.transition = Some(Transition { self.transition = Some(Transition {
cloned: unwrap!(Gc::new(self.inner.clone())), cloned: unwrap!(Gc::new(self.inner.clone())),
animation: Animation::new(0.0f32, 1.0f32, util::SLIDE_DURATION, Instant::now()), animation: Animation::new(0.0f32, 1.0f32, util::SLIDE_DURATION_MS, Instant::now()),
direction, direction,
}); });
self.inner.change_page(self.current); self.inner.change_page(self.current);

@ -67,7 +67,7 @@ impl<Q: FlowState, S: FlowStore> SwipeFlow<Q, S> {
} }
self.transition = Transition::External { self.transition = Transition::External {
prev_state: self.state, prev_state: self.state,
animation: Animation::new(0.0f32, 1.0f32, util::SLIDE_DURATION, Instant::now()), animation: Animation::new(0.0f32, 1.0f32, util::SLIDE_DURATION_MS, Instant::now()),
direction, direction,
}; };
self.state = state; self.state = state;

@ -25,7 +25,7 @@ pub trait InvLerp: Copy {
fn inv_lerp(min: Self, max: Self, value: Self) -> f32; fn inv_lerp(min: Self, max: Self, value: Self) -> f32;
} }
macro_rules! impl_lerp_for_int { macro_rules! impl_lerp_for_signed {
($int: ident) => { ($int: ident) => {
impl Lerp for $int { impl Lerp for $int {
fn lerp(a: Self, b: Self, t: f32) -> Self { fn lerp(a: Self, b: Self, t: f32) -> Self {
@ -41,7 +41,7 @@ macro_rules! impl_lerp_for_int {
}; };
} }
macro_rules! impl_lerp_for_uint { macro_rules! impl_lerp_for_unsigned {
($uint: ident) => { ($uint: ident) => {
impl Lerp for $uint { impl Lerp for $uint {
fn lerp(a: Self, b: Self, t: f32) -> Self { fn lerp(a: Self, b: Self, t: f32) -> Self {
@ -65,13 +65,13 @@ macro_rules! impl_lerp_for_uint {
}; };
} }
impl_lerp_for_int!(i16); impl_lerp_for_signed!(i16);
impl_lerp_for_int!(i32); impl_lerp_for_signed!(i32);
impl_lerp_for_uint!(u8); impl_lerp_for_unsigned!(u8);
impl_lerp_for_uint!(u16); impl_lerp_for_unsigned!(u16);
impl_lerp_for_uint!(u32); impl_lerp_for_unsigned!(u32);
impl_lerp_for_int!(f32); impl_lerp_for_signed!(f32);
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {

@ -7,7 +7,7 @@ pub mod component;
pub mod constant; pub mod constant;
pub mod display; pub mod display;
pub mod event; pub mod event;
#[cfg(all(feature = "micropython", feature = "touch"))] #[cfg(all(feature = "micropython", feature = "touch", feature = "new_rendering"))]
pub mod flow; pub mod flow;
pub mod geometry; pub mod geometry;
pub mod lerp; pub mod lerp;

@ -17,7 +17,7 @@ use crate::{
use heapless::{String, Vec}; use heapless::{String, Vec};
const MAX_WORDS: usize = 33; // super-shamir has 33 words, all other have less const MAX_WORDS: usize = 33; // super-shamir has 33 words, all other have less
const ANIMATION_DURATION: Duration = Duration::from_millis(166); const ANIMATION_DURATION_MS: Duration = Duration::from_millis(166);
/// Component showing mnemonic/share words during backup procedure. Model T3T1 /// Component showing mnemonic/share words during backup procedure. Model T3T1
/// contains one word per screen. A user is instructed to swipe up/down to see /// contains one word per screen. A user is instructed to swipe up/down to see
@ -180,7 +180,7 @@ impl<'a> Swipable for ShareWords<'a> {
self.animation = Some(Animation::new( self.animation = Some(Animation::new(
0.0f32, 0.0f32,
1.0f32, 1.0f32,
ANIMATION_DURATION, ANIMATION_DURATION_MS,
Instant::now(), Instant::now(),
)); ));
ctx.request_anim_frame(); ctx.request_anim_frame();

@ -180,7 +180,7 @@ macro_rules! include_icon {
}; };
} }
pub const SLIDE_DURATION: Duration = Duration::from_millis(333); pub const SLIDE_DURATION_MS: Duration = Duration::from_millis(333);
#[cfg(feature = "new_rendering")] #[cfg(feature = "new_rendering")]
pub fn render_slide<'s, F0, F1, R>( pub fn render_slide<'s, F0, F1, R>(

Loading…
Cancel
Save