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>
where
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)]
pub struct Swipe {
pub area: Rect,
pub allow_up: bool,
pub allow_down: bool,
pub allow_left: bool,
@ -42,7 +40,6 @@ impl Swipe {
pub fn new() -> Self {
Self {
area: Rect::zero(),
allow_up: false,
allow_down: false,
allow_left: false,
@ -92,8 +89,7 @@ impl Component for Swipe {
type Msg = SwipeDirection;
fn place(&mut self, bounds: Rect) -> Rect {
self.area = bounds;
self.area
bounds
}
fn event(&mut self, _ctx: &mut EventCtx, event: Event) -> Option<Self::Msg> {
@ -101,7 +97,7 @@ impl Component for Swipe {
return None;
}
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.
self.origin.replace(pos);
}

@ -142,7 +142,7 @@ impl<T: Component + Paginate + Clone> Swipable for SwipePage<T> {
}
self.transition = Some(Transition {
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,
});
self.inner.change_page(self.current);

@ -67,7 +67,7 @@ impl<Q: FlowState, S: FlowStore> SwipeFlow<Q, S> {
}
self.transition = Transition::External {
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,
};
self.state = state;

@ -25,7 +25,7 @@ pub trait InvLerp: Copy {
fn inv_lerp(min: Self, max: Self, value: Self) -> f32;
}
macro_rules! impl_lerp_for_int {
macro_rules! impl_lerp_for_signed {
($int: ident) => {
impl Lerp for $int {
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) => {
impl Lerp for $uint {
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_int!(i32);
impl_lerp_for_uint!(u8);
impl_lerp_for_uint!(u16);
impl_lerp_for_uint!(u32);
impl_lerp_for_signed!(i16);
impl_lerp_for_signed!(i32);
impl_lerp_for_unsigned!(u8);
impl_lerp_for_unsigned!(u16);
impl_lerp_for_unsigned!(u32);
impl_lerp_for_int!(f32);
impl_lerp_for_signed!(f32);
#[cfg(test)]
mod tests {

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

@ -17,7 +17,7 @@ use crate::{
use heapless::{String, Vec};
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
/// 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(
0.0f32,
1.0f32,
ANIMATION_DURATION,
ANIMATION_DURATION_MS,
Instant::now(),
));
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")]
pub fn render_slide<'s, F0, F1, R>(

Loading…
Cancel
Save