1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-23 06:48:16 +00:00

feat(core/rust/ui): add new icons

[no changelog]
This commit is contained in:
Martin Milata 2022-01-18 12:46:33 +01:00
parent b46901bc8b
commit c7b33e2bc0
12 changed files with 32 additions and 19 deletions

View File

@ -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))
};
}

View File

@ -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,
);
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -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 {