mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-26 00:18:15 +00:00
WIP - decrease Unifont height to 12 pixels
This commit is contained in:
parent
c96ce4e13e
commit
03a1c28969
@ -3,8 +3,8 @@
|
|||||||
#if TREZOR_FONT_BPP != 1
|
#if TREZOR_FONT_BPP != 1
|
||||||
#error Wrong TREZOR_FONT_BPP (expected 1)
|
#error Wrong TREZOR_FONT_BPP (expected 1)
|
||||||
#endif
|
#endif
|
||||||
#define Font_Unifont_Bold_16_HEIGHT 16
|
#define Font_Unifont_Bold_16_HEIGHT 12 // <--- 12 from 16
|
||||||
#define Font_Unifont_Bold_16_MAX_HEIGHT 15
|
#define Font_Unifont_Bold_16_MAX_HEIGHT 12 // <--- 12 from 15
|
||||||
#define Font_Unifont_Bold_16_BASELINE 2
|
#define Font_Unifont_Bold_16_BASELINE 2
|
||||||
extern const uint8_t* const Font_Unifont_Bold_16[126 + 1 - 32];
|
extern const uint8_t* const Font_Unifont_Bold_16[126 + 1 - 32];
|
||||||
extern const uint8_t Font_Unifont_Bold_16_glyph_nonprintable[];
|
extern const uint8_t Font_Unifont_Bold_16_glyph_nonprintable[];
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
#if TREZOR_FONT_BPP != 1
|
#if TREZOR_FONT_BPP != 1
|
||||||
#error Wrong TREZOR_FONT_BPP (expected 1)
|
#error Wrong TREZOR_FONT_BPP (expected 1)
|
||||||
#endif
|
#endif
|
||||||
#define Font_Unifont_Regular_16_HEIGHT 16
|
#define Font_Unifont_Regular_16_HEIGHT 12 // <--- 12 from 16
|
||||||
#define Font_Unifont_Regular_16_MAX_HEIGHT 15
|
#define Font_Unifont_Regular_16_MAX_HEIGHT 12 // <--- 12 from 15
|
||||||
#define Font_Unifont_Regular_16_BASELINE 2
|
#define Font_Unifont_Regular_16_BASELINE 2
|
||||||
extern const uint8_t* const Font_Unifont_Regular_16[126 + 1 - 32];
|
extern const uint8_t* const Font_Unifont_Regular_16[126 + 1 - 32];
|
||||||
extern const uint8_t Font_Unifont_Regular_16_glyph_nonprintable[];
|
extern const uint8_t Font_Unifont_Regular_16_glyph_nonprintable[];
|
||||||
|
@ -136,7 +136,7 @@ impl Bip39Entry {
|
|||||||
let choices = ChoiceFactoryBIP39::letters(letter_choices.clone());
|
let choices = ChoiceFactoryBIP39::letters(letter_choices.clone());
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
choice_page: ChoicePage::new(choices).with_incomplete(),
|
choice_page: ChoicePage::new(choices).with_incomplete(true),
|
||||||
chosen_letters: Child::new(ChangingTextLine::center_mono(String::from(PROMPT))),
|
chosen_letters: Child::new(ChangingTextLine::center_mono(String::from(PROMPT))),
|
||||||
letter_choices,
|
letter_choices,
|
||||||
textbox: TextBox::empty(),
|
textbox: TextBox::empty(),
|
||||||
|
@ -661,6 +661,11 @@ impl ButtonLayout<&'static str> {
|
|||||||
Some(ButtonDetails::text(text).with_duration(duration)),
|
Some(ButtonDetails::text(text).with_duration(duration)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Only right arrow facing down.
|
||||||
|
pub fn only_arrow_down() -> Self {
|
||||||
|
Self::new(None, None, Some(ButtonDetails::down_arrow_icon_wide()))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// What happens when a button is triggered.
|
/// What happens when a button is triggered.
|
||||||
@ -789,6 +794,11 @@ impl ButtonActions {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Only going to the next page with right
|
||||||
|
pub fn only_next() -> Self {
|
||||||
|
Self::new(None, None, Some(ButtonAction::NextPage))
|
||||||
|
}
|
||||||
|
|
||||||
/// Cancelling with left, confirming with right
|
/// Cancelling with left, confirming with right
|
||||||
pub fn cancel_confirm() -> Self {
|
pub fn cancel_confirm() -> Self {
|
||||||
Self::new(
|
Self::new(
|
||||||
|
@ -58,6 +58,8 @@ where
|
|||||||
/// Whether we should show items on left/right even when they cannot
|
/// Whether we should show items on left/right even when they cannot
|
||||||
/// be painted entirely (they would be cut off).
|
/// be painted entirely (they would be cut off).
|
||||||
show_incomplete: bool,
|
show_incomplete: bool,
|
||||||
|
/// Whether to show only the currently selected item, nothing left/right.
|
||||||
|
show_only_one_item: bool,
|
||||||
/// Whether the middle selected item should be painted with
|
/// Whether the middle selected item should be painted with
|
||||||
/// inverse colors - black on white.
|
/// inverse colors - black on white.
|
||||||
inverse_selected_item: bool,
|
inverse_selected_item: bool,
|
||||||
@ -79,6 +81,7 @@ where
|
|||||||
items_distance: DEFAULT_ITEMS_DISTANCE,
|
items_distance: DEFAULT_ITEMS_DISTANCE,
|
||||||
is_carousel: false,
|
is_carousel: false,
|
||||||
show_incomplete: false,
|
show_incomplete: false,
|
||||||
|
show_only_one_item: false,
|
||||||
inverse_selected_item: false,
|
inverse_selected_item: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,14 +93,20 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Enabling the carousel mode.
|
/// Enabling the carousel mode.
|
||||||
pub fn with_carousel(mut self) -> Self {
|
pub fn with_carousel(mut self, carousel: bool) -> Self {
|
||||||
self.is_carousel = true;
|
self.is_carousel = carousel;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Show incomplete items, even when they cannot render in their entirety.
|
/// Show incomplete items, even when they cannot render in their entirety.
|
||||||
pub fn with_incomplete(mut self) -> Self {
|
pub fn with_incomplete(mut self, show_incomplete: bool) -> Self {
|
||||||
self.show_incomplete = true;
|
self.show_incomplete = show_incomplete;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Show only the currently selected item, nothing left/right.
|
||||||
|
pub fn with_only_one_item(mut self, only_one_item: bool) -> Self {
|
||||||
|
self.show_only_one_item = only_one_item;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,6 +161,11 @@ where
|
|||||||
// Drawing the current item in the middle.
|
// Drawing the current item in the middle.
|
||||||
self.show_current_choice(available_area);
|
self.show_current_choice(available_area);
|
||||||
|
|
||||||
|
// Not drawing the rest when not wanted
|
||||||
|
if self.show_only_one_item {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Getting the remaining left and right areas.
|
// Getting the remaining left and right areas.
|
||||||
let (left_area, _center_area, right_area) =
|
let (left_area, _center_area, right_area) =
|
||||||
available_area.split_center(self.current_choice().width_center());
|
available_area.split_center(self.current_choice().width_center());
|
||||||
|
@ -84,7 +84,7 @@ impl ChoiceItem {
|
|||||||
area.bottom_center() + Offset::new(-self.width_center() / 2 - bound, bound + 1);
|
area.bottom_center() + Offset::new(-self.width_center() / 2 - bound, bound + 1);
|
||||||
let outline_size = Offset::new(
|
let outline_size = Offset::new(
|
||||||
self.width_center() + 2 * bound,
|
self.width_center() + 2 * bound,
|
||||||
self.font.text_height() + 2 * bound - 3, // -3 because font is actually smaller
|
self.font.text_height() + 2 * bound,
|
||||||
);
|
);
|
||||||
let outline = Rect::from_bottom_left_and_size(left_bottom, outline_size);
|
let outline = Rect::from_bottom_left_and_size(left_bottom, outline_size);
|
||||||
if inverse {
|
if inverse {
|
||||||
|
@ -99,7 +99,7 @@ impl PinEntry {
|
|||||||
// Starting at the digit 0
|
// Starting at the digit 0
|
||||||
choice_page: ChoicePage::new(choices)
|
choice_page: ChoicePage::new(choices)
|
||||||
.with_initial_page_counter(PROMPT_INDEX as u8 + 1)
|
.with_initial_page_counter(PROMPT_INDEX as u8 + 1)
|
||||||
.with_carousel(),
|
.with_carousel(true),
|
||||||
pin_dots: Child::new(ChangingTextLine::center_mono(String::new())),
|
pin_dots: Child::new(ChangingTextLine::center_mono(String::new())),
|
||||||
show_real_pin: false,
|
show_real_pin: false,
|
||||||
textbox: TextBox::empty(),
|
textbox: TextBox::empty(),
|
||||||
|
@ -15,14 +15,15 @@ pub enum SimpleChoiceMsg {
|
|||||||
|
|
||||||
struct ChoiceFactorySimple<T, const N: usize> {
|
struct ChoiceFactorySimple<T, const N: usize> {
|
||||||
choices: Vec<T, N>,
|
choices: Vec<T, N>,
|
||||||
|
carousel: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, const N: usize> ChoiceFactorySimple<T, N>
|
impl<T, const N: usize> ChoiceFactorySimple<T, N>
|
||||||
where
|
where
|
||||||
T: AsRef<str>,
|
T: AsRef<str>,
|
||||||
{
|
{
|
||||||
fn new(choices: Vec<T, N>) -> Self {
|
fn new(choices: Vec<T, N>, carousel: bool) -> Self {
|
||||||
Self { choices }
|
Self { choices, carousel }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,11 +35,13 @@ where
|
|||||||
let text = &self.choices[choice_index as usize];
|
let text = &self.choices[choice_index as usize];
|
||||||
let mut choice_item = ChoiceItem::new(text, ButtonLayout::default_three_icons());
|
let mut choice_item = ChoiceItem::new(text, ButtonLayout::default_three_icons());
|
||||||
|
|
||||||
// Disabling prev/next buttons for the first/last choice.
|
// Disabling prev/next buttons for the first/last choice when not in carousel.
|
||||||
if choice_index == 0 {
|
if !self.carousel {
|
||||||
choice_item.set_left_btn(None);
|
if choice_index == 0 {
|
||||||
} else if choice_index as usize == N - 1 {
|
choice_item.set_left_btn(None);
|
||||||
choice_item.set_right_btn(None);
|
} else if choice_index as usize == N - 1 {
|
||||||
|
choice_item.set_right_btn(None);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
choice_item
|
choice_item
|
||||||
@ -65,11 +68,13 @@ where
|
|||||||
T: AsRef<str>,
|
T: AsRef<str>,
|
||||||
T: Clone,
|
T: Clone,
|
||||||
{
|
{
|
||||||
pub fn new(str_choices: Vec<T, N>) -> Self {
|
pub fn new(str_choices: Vec<T, N>, carousel: bool, show_incomplete: bool) -> Self {
|
||||||
let choices = ChoiceFactorySimple::new(str_choices.clone());
|
let choices = ChoiceFactorySimple::new(str_choices.clone(), carousel);
|
||||||
Self {
|
Self {
|
||||||
choices: str_choices,
|
choices: str_choices,
|
||||||
choice_page: ChoicePage::new(choices),
|
choice_page: ChoicePage::new(choices)
|
||||||
|
.with_carousel(carousel)
|
||||||
|
.with_incomplete(show_incomplete),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -473,11 +473,11 @@ extern "C" fn show_share_words(n_args: usize, args: *const Obj, kwargs: *mut Map
|
|||||||
)
|
)
|
||||||
.text_bold("Write all words in order on recovery seed card.".into())
|
.text_bold("Write all words in order on recovery seed card.".into())
|
||||||
.newline()
|
.newline()
|
||||||
.newline()
|
.newline_half()
|
||||||
.text_mono("Do NOT make digital copies.".into()),
|
.text_mono("Do NOT make digital copies.".into()),
|
||||||
1 => Page::<10>::new(
|
1 => Page::<10>::new(
|
||||||
ButtonLayout::cancel_and_arrow_down(),
|
ButtonLayout::only_arrow_down(),
|
||||||
ButtonActions::cancel_next(),
|
ButtonActions::only_next(),
|
||||||
Font::NORMAL,
|
Font::NORMAL,
|
||||||
)
|
)
|
||||||
.text_normal(share_words.clone()),
|
.text_normal(share_words.clone()),
|
||||||
@ -506,7 +506,10 @@ extern "C" fn select_word(n_args: usize, args: *const Obj, kwargs: *mut Map) ->
|
|||||||
let words: Vec<StrBuffer, 3> = iter_into_vec(words_iterable)?;
|
let words: Vec<StrBuffer, 3> = iter_into_vec(words_iterable)?;
|
||||||
|
|
||||||
// TODO: should return int, to be consistent with TT's select_word
|
// TODO: should return int, to be consistent with TT's select_word
|
||||||
let obj = LayoutObj::new(Frame::new(title, SimpleChoice::new(words).into_child()))?;
|
let obj = LayoutObj::new(Frame::new(
|
||||||
|
title,
|
||||||
|
SimpleChoice::new(words, true, true).into_child(),
|
||||||
|
))?;
|
||||||
Ok(obj.into())
|
Ok(obj.into())
|
||||||
};
|
};
|
||||||
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
|
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
|
||||||
@ -518,7 +521,10 @@ extern "C" fn request_word_count(n_args: usize, args: *const Obj, kwargs: *mut M
|
|||||||
|
|
||||||
let choices: Vec<&str, 5> = ["12", "18", "20", "24", "33"].into_iter().collect();
|
let choices: Vec<&str, 5> = ["12", "18", "20", "24", "33"].into_iter().collect();
|
||||||
|
|
||||||
let obj = LayoutObj::new(Frame::new(title, SimpleChoice::new(choices).into_child()))?;
|
let obj = LayoutObj::new(Frame::new(
|
||||||
|
title,
|
||||||
|
SimpleChoice::new(choices, true, false).into_child(),
|
||||||
|
))?;
|
||||||
Ok(obj.into())
|
Ok(obj.into())
|
||||||
};
|
};
|
||||||
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
|
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
|
||||||
|
@ -3,7 +3,7 @@ from typing import Sequence
|
|||||||
from trezor import ui, utils, wire
|
from trezor import ui, utils, wire
|
||||||
from trezor.crypto import random
|
from trezor.crypto import random
|
||||||
from trezor.enums import ButtonRequestType
|
from trezor.enums import ButtonRequestType
|
||||||
from trezor.ui.layouts import confirm_action, confirm_blob, show_success, show_warning
|
from trezor.ui.layouts import confirm_blob, show_success, show_warning
|
||||||
from trezor.ui.layouts.reset import ( # noqa: F401
|
from trezor.ui.layouts.reset import ( # noqa: F401
|
||||||
select_word,
|
select_word,
|
||||||
show_share_words,
|
show_share_words,
|
||||||
|
@ -590,7 +590,7 @@ async def confirm_backup(ctx: wire.GenericContext) -> bool:
|
|||||||
confirmed = await get_bool(
|
confirmed = await get_bool(
|
||||||
ctx=ctx,
|
ctx=ctx,
|
||||||
title="WARNING",
|
title="WARNING",
|
||||||
data="Are you sure you want to skip the backup?\n\n",
|
data="Are you sure you want to skip the backup?\n",
|
||||||
description="You can back up your Trezor once, at any time.",
|
description="You can back up your Trezor once, at any time.",
|
||||||
verb="BACK UP",
|
verb="BACK UP",
|
||||||
verb_cancel="SKIP",
|
verb_cancel="SKIP",
|
||||||
|
Loading…
Reference in New Issue
Block a user