From c7b33e2bc051f3e3aeeaf06c28491626e2d3e02b Mon Sep 17 00:00:00 2001 From: Martin Milata Date: Tue, 18 Jan 2022 12:46:33 +0100 Subject: [PATCH] feat(core/rust/ui): add new icons [no changelog] --- core/embed/rust/src/ui/macros.rs | 6 +-- .../rust/src/ui/model_tt/component/page.rs | 39 +++++++++++++----- .../rust/src/ui/model_tt/res/cancel.toif | Bin 0 -> 68 bytes .../rust/src/ui/model_tt/res/confirm.toif | Bin 0 -> 58 bytes core/embed/rust/src/ui/model_tt/res/down.toif | Bin 0 -> 62 bytes core/embed/rust/src/ui/model_tt/res/next.toif | Bin 0 -> 58 bytes .../src/ui/model_tt/res/scroll-active.toif | Bin 0 -> 31 bytes .../rust/src/ui/model_tt/res/scroll-down.toif | Bin 0 -> 70 bytes .../src/ui/model_tt/res/scroll-inactive.toif | Bin 0 -> 27 bytes .../rust/src/ui/model_tt/res/scroll-up.toif | Bin 0 -> 72 bytes .../embed/rust/src/ui/model_tt/res/space.toif | Bin 0 -> 34 bytes core/embed/rust/src/ui/model_tt/theme.rs | 6 +-- 12 files changed, 32 insertions(+), 19 deletions(-) create mode 100644 core/embed/rust/src/ui/model_tt/res/cancel.toif create mode 100644 core/embed/rust/src/ui/model_tt/res/confirm.toif create mode 100644 core/embed/rust/src/ui/model_tt/res/down.toif create mode 100644 core/embed/rust/src/ui/model_tt/res/next.toif create mode 100644 core/embed/rust/src/ui/model_tt/res/scroll-active.toif create mode 100644 core/embed/rust/src/ui/model_tt/res/scroll-down.toif create mode 100644 core/embed/rust/src/ui/model_tt/res/scroll-inactive.toif create mode 100644 core/embed/rust/src/ui/model_tt/res/scroll-up.toif create mode 100644 core/embed/rust/src/ui/model_tt/res/space.toif diff --git a/core/embed/rust/src/ui/macros.rs b/core/embed/rust/src/ui/macros.rs index 87f637049..8ccea9d9c 100644 --- a/core/embed/rust/src/ui/macros.rs +++ b/core/embed/rust/src/ui/macros.rs @@ -1,10 +1,6 @@ #[allow(unused_macros)] // T1 doesn't use icons (yet) macro_rules! include_res { ($filename:expr) => { - include_bytes!(concat!( - env!("CARGO_MANIFEST_DIR"), - "/../../src/trezor/res/", - $filename, - )) + include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/ui/", $filename)) }; } diff --git a/core/embed/rust/src/ui/model_tt/component/page.rs b/core/embed/rust/src/ui/model_tt/component/page.rs index 48cc69cd0..4a862a638 100644 --- a/core/embed/rust/src/ui/model_tt/component/page.rs +++ b/core/embed/rust/src/ui/model_tt/component/page.rs @@ -125,8 +125,13 @@ pub struct ScrollBar { } impl ScrollBar { - pub const DOT_SIZE: Offset = Offset::new(8, 8); - pub const DOT_INTERVAL: i32 = 14; + const DOT_INTERVAL: i32 = 12; + const ARROW_SPACE: i32 = 23; + + const ICON_ACTIVE: &'static [u8] = include_res!("model_tt/res/scroll-active.toif"); + const ICON_INACTIVE: &'static [u8] = include_res!("model_tt/res/scroll-inactive.toif"); + const ICON_UP: &'static [u8] = include_res!("model_tt/res/scroll-up.toif"); + const ICON_DOWN: &'static [u8] = include_res!("model_tt/res/scroll-down.toif"); pub fn vertical_right(area: Rect, page_count: usize, active_page: usize) -> Self { Self { @@ -179,18 +184,30 @@ impl Component for ScrollBar { self.area.center().x, self.area.center().y - (count / 2) * interval, ); - for i in 0..self.page_count { - display::rounded_rect( - Rect::from_center_and_size(dot, Self::DOT_SIZE), - if i == self.active_page { - theme::FG - } else { - theme::GREY_LIGHT - }, + if self.has_previous_page() { + display::icon( + dot - Offset::new(0, Self::ARROW_SPACE), + Self::ICON_UP, + theme::FG, theme::BG, - theme::RADIUS, ); + } + for i in 0..self.page_count { + let icon = if i == self.active_page { + Self::ICON_ACTIVE + } else { + Self::ICON_INACTIVE + }; + display::icon(dot, icon, theme::FG, theme::BG); dot.y += interval; } + if self.has_next_page() { + display::icon( + dot + Offset::new(0, Self::ARROW_SPACE - interval), + Self::ICON_DOWN, + theme::FG, + theme::BG, + ); + } } } diff --git a/core/embed/rust/src/ui/model_tt/res/cancel.toif b/core/embed/rust/src/ui/model_tt/res/cancel.toif new file mode 100644 index 0000000000000000000000000000000000000000..de600f905bb32d45001359f1fb9b1aa74d39d465 GIT binary patch literal 68 zcmWIX_e|$w;A600U|_f`kN^ZZuk1ONq|}}GBbbn2Q!mgV;ovjVzR5u>;K>>J2}U#j XD})AcX>kNHU1hk+XX?Y8WWoRd?nD*| literal 0 HcmV?d00001 diff --git a/core/embed/rust/src/ui/model_tt/res/confirm.toif b/core/embed/rust/src/ui/model_tt/res/confirm.toif new file mode 100644 index 0000000000000000000000000000000000000000..e0a3dee8a64ce2a03c61ac302e0112a8419a031f GIT binary patch literal 58 zcmV-A0LA}QPf2GG01E&v0001EU;qKu-(ZR%{s)BnzX8V83V?9^zd~d={s%y0`@cdI QbNq)Y?uY1QU@HKT0ADE=OaK4? literal 0 HcmV?d00001 diff --git a/core/embed/rust/src/ui/model_tt/res/down.toif b/core/embed/rust/src/ui/model_tt/res/down.toif new file mode 100644 index 0000000000000000000000000000000000000000..f5dd0e17646b29e1325250aefe6cc148fef86556 GIT binary patch literal 62 zcmWIX_e>XH;AAjjU|>iNO<-VJ#_-o$A?myG@%RM{m;bW0)h%dv$Ir&LfT80wg9t;R SBU6H20K=KogamyCAqD_Og%ZyI literal 0 HcmV?d00001 diff --git a/core/embed/rust/src/ui/model_tt/res/next.toif b/core/embed/rust/src/ui/model_tt/res/next.toif new file mode 100644 index 0000000000000000000000000000000000000000..43684424cd1377864ac55d5c51667ebe556f8ad6 GIT binary patch literal 58 zcmV-A0LA}QPf2GG01f~y0001EU|?V{XMlk96CkwiPYBI)A5)kDzkcEW|Kq>^|8H3F|G)paa$W`ix-$-e literal 0 HcmV?d00001 diff --git a/core/embed/rust/src/ui/model_tt/res/scroll-down.toif b/core/embed/rust/src/ui/model_tt/res/scroll-down.toif new file mode 100644 index 0000000000000000000000000000000000000000..db06704c732a4f2ea1f0a2abd79a17489661ce25 GIT binary patch literal 70 zcmWIX_e|$w;9{_1U|=u~O-M)xFiqe}OGsc#5_ESHXI#*+ay27!^KQn;%FR2Oy;n0Z aXLB<*R|p1MdX&1fF;7TI@Jni7W&i+t{u59D literal 0 HcmV?d00001 diff --git a/core/embed/rust/src/ui/model_tt/res/scroll-inactive.toif b/core/embed/rust/src/ui/model_tt/res/scroll-inactive.toif new file mode 100644 index 0000000000000000000000000000000000000000..390f6fa1520fc634deb799fcaa9917000404e3af GIT binary patch literal 27 icmWIX_e^JFU}NBCU|>joS@7XS#!Cifh32J)85sa&;s|2^ literal 0 HcmV?d00001 diff --git a/core/embed/rust/src/ui/model_tt/res/scroll-up.toif b/core/embed/rust/src/ui/model_tt/res/scroll-up.toif new file mode 100644 index 0000000000000000000000000000000000000000..b2c6bb8abe17bb56575ee4e5969bbadf10b1a128 GIT binary patch literal 72 zcmWIX_e|$w;9{_0U|>j2NbpKyVC?TqAdf-Busk6lp@d1> bu#}av!@_76hk*gRF%TQh&|+{6;bi~-DPt9B literal 0 HcmV?d00001 diff --git a/core/embed/rust/src/ui/model_tt/res/space.toif b/core/embed/rust/src/ui/model_tt/res/space.toif new file mode 100644 index 0000000000000000000000000000000000000000..bb4106e5633c849d3c12292265105f80053bdfac GIT binary patch literal 34 qcmWIX_e>XH;A0SDU|>j2Sion&xUj0u;YFRq-{s6a=l-`dF#rIUObU_! literal 0 HcmV?d00001 diff --git a/core/embed/rust/src/ui/model_tt/theme.rs b/core/embed/rust/src/ui/model_tt/theme.rs index 45e73229c..38f2a1aa9 100644 --- a/core/embed/rust/src/ui/model_tt/theme.rs +++ b/core/embed/rust/src/ui/model_tt/theme.rs @@ -38,9 +38,9 @@ pub const RADIUS: u8 = 4; pub const ICON_SIZE: i32 = 16; // UI icons. -pub const ICON_CANCEL: &[u8] = include_res!("cancel.toif"); -pub const ICON_CONFIRM: &[u8] = include_res!("confirm.toif"); -pub const ICON_SPACE: &[u8] = include_res!("space.toif"); +pub const ICON_CANCEL: &[u8] = include_res!("model_tt/res/cancel.toif"); +pub const ICON_CONFIRM: &[u8] = include_res!("model_tt/res/confirm.toif"); +pub const ICON_SPACE: &[u8] = include_res!("model_tt/res/space.toif"); pub fn label_default() -> LabelStyle { LabelStyle {