WIP - merge - integration - fixes

cepetr/drawlib-integration
cepetr 2 months ago
parent 9eb9620669
commit cca1e579f7

@ -128,10 +128,12 @@ impl Marquee {
target.in_window(self.area, &mut |target| {
let text_height = self.font.text_height();
let pos = self.area.top_left() + Offset::new(offset, text_height - 1);
shape::Text::new(pos, self.text.as_ref())
.with_font(self.font)
.with_fg(self.fg)
.render(target);
self.text.map(|t| {
shape::Text::new(pos, t)
.with_font(self.font)
.with_fg(self.fg)
.render(target);
});
});
}
}

@ -6,7 +6,7 @@ use crate::{
layout::simplified::ReturnToC,
shape,
shape::Renderer,
},
},
};
use super::super::{

@ -221,7 +221,7 @@ impl Component for Confirm<'_> {
fn render<'s>(&'s self, target: &mut impl Renderer<'s>) {
self.bg.render(target);
let mut display_top_left = |text: TString<'static>| {
let mut display_top_left = |text: TString| {
text.map(|t| {
shape::Text::new(Point::zero(), t)
.with_font(Font::BOLD)

@ -170,7 +170,7 @@ impl Component for CoinJoinProgress {
text_multiline_bottom2(
target,
rest.inset(Insets::bottom(FOOTER_TEXT_MARGIN)),
self.text.as_ref().into(),
self.text,
Font::NORMAL,
theme::FG,
theme::BG,

@ -8,7 +8,7 @@ use crate::{
model_tr::cshape,
shape,
shape::Renderer,
},
},
};
use super::super::{

@ -181,11 +181,12 @@ impl Homescreen {
.with_bg(theme::BG)
.render(target);
notification.map(|c| shape::Text::new(baseline, c)
notification.map(|c| {
shape::Text::new(baseline, c)
.with_align(Alignment::Center)
.with_font(NOTIFICATION_FONT)
.render(target)
);
});
// Painting warning icons in top corners when the text is short enough not to
// collide with them
@ -433,8 +434,7 @@ pub struct ConfirmHomescreen {
buttons: Child<ButtonController>,
}
impl ConfirmHomescreen
{
impl ConfirmHomescreen {
pub fn new(title: TString<'static>, image: Obj) -> Self {
let btn_layout = ButtonLayout::cancel_none_text(TR::buttons__change.into());
ConfirmHomescreen {
@ -445,8 +445,7 @@ impl ConfirmHomescreen
}
}
impl<'a> Component for ConfirmHomescreen
{
impl<'a> Component for ConfirmHomescreen {
type Msg = CancelConfirmMsg;
fn place(&mut self, bounds: Rect) -> Rect {

@ -62,13 +62,19 @@ impl Title {
}
/// Display title/header at the top left of the given area.
pub fn render_header_left<'s>(target: &mut impl Renderer<'s>, title: &T, area: Rect) {
pub fn render_header_left<'s>(
target: &mut impl Renderer<'s>,
title: &TString<'static>,
area: Rect,
) {
let text_height = theme::FONT_HEADER.text_height();
let title_baseline = area.top_left() + Offset::y(text_height - 1);
shape::Text::new(title_baseline, title.as_ref())
.with_font(theme::FONT_HEADER)
.with_fg(theme::FG)
.render(target);
title.map(|s| {
shape::Text::new(title_baseline, s)
.with_font(theme::FONT_HEADER)
.with_fg(theme::FG)
.render(target);
});
}
/// Display title/header centered at the top of the given area.
@ -81,14 +87,20 @@ impl Title {
}
/// Display title/header centered at the top of the given area.
pub fn render_header_centered<'s>(target: &mut impl Renderer<'s>, title: &T, area: Rect) {
pub fn render_header_centered<'s>(
target: &mut impl Renderer<'s>,
title: &TString<'static>,
area: Rect,
) {
let text_height = theme::FONT_HEADER.text_height();
let title_baseline = area.top_center() + Offset::y(text_height - 1);
shape::Text::new(title_baseline, title.as_ref())
.with_align(Alignment::Center)
.with_font(theme::FONT_HEADER)
.with_fg(theme::FG)
.render(target);
title.map(|s| {
shape::Text::new(title_baseline, s)
.with_align(Alignment::Center)
.with_font(theme::FONT_HEADER)
.with_fg(theme::FG)
.render(target);
});
}
}

@ -1,4 +1,3 @@
use crate::micropython::buffer::StrBuffer;
use crate::ui::{component::base::Component, constant::screen, model_tr::component::WelcomeScreen};
#[cfg(not(feature = "new_rendering"))]

@ -13,8 +13,8 @@ use crate::{
CONTENT_PADDING, CORNER_BUTTON_AREA, MENU32, TEXT_NORMAL, TEXT_WARNING, TITLE_AREA,
},
},
shape::Renderer,
},
shape::Renderer,
};
#[repr(u32)]

@ -18,9 +18,9 @@ use crate::{
WHITE,
},
},
shape,
shape::Renderer,
},
shape,
shape::Renderer,
};
const ICON_TOP: i16 = 17;

@ -240,21 +240,21 @@ impl Button {
}
}
pub fn render_content<'s>(&self, target: &mut impl Renderer<'s>, style: &ButtonStyle)
{
pub fn render_content<'s>(&self, target: &mut impl Renderer<'s>, style: &ButtonStyle) {
match &self.content {
ButtonContent::Empty => {}
ButtonContent::Text(text) => {
let text = text.as_ref();
let width = style.font.text_width(text);
let width = text.map(|c| style.font.text_width(c));
let height = style.font.text_height();
let start_of_baseline = self.area.center()
+ Offset::new(-width / 2, height / 2)
+ Offset::y(Self::BASELINE_OFFSET);
shape::Text::new(start_of_baseline, text)
.with_font(style.font)
.with_fg(style.text_color)
.render(target);
text.map(|text| {
shape::Text::new(start_of_baseline, text)
.with_font(style.font)
.with_fg(style.text_color)
.render(target);
});
}
ButtonContent::Icon(icon) => {
shape::ToifImage::new(self.area.center(), icon.toif)

@ -9,9 +9,9 @@ use crate::{
swipe::{Swipe, SwipeDirection},
theme, ScrollBar,
},
shape,
shape::Renderer,
},
shape,
shape::Renderer,
};
use super::CancelConfirmMsg;
@ -231,8 +231,8 @@ where
// Account name is optional.
// Showing it only if it differs from app name.
// (Dummy requests usually have some text as both app_name and account_name.)
let account_name = self.account_name.text().as_ref();
let app_name = self.app_name.text().as_ref();
let account_name = self.account_name.text();
let app_name = self.app_name.text();
if !account_name.is_empty() && account_name != app_name {
self.account_name.render(target);
}

@ -7,8 +7,8 @@ use crate::{
component::{Button, ButtonMsg, Swipe, SwipeDirection},
theme,
},
shape::Renderer,
},
shape::Renderer,
};
pub const MNEMONIC_KEY_COUNT: usize = 9;

@ -241,7 +241,7 @@ impl Component for NumberInput {
if let Some(text) = strutil::format_i64(self.value as i64, &mut buf) {
let digit_font = Font::DEMIBOLD;
let y_offset = digit_font.text_height() / 2 + Button::<&str>::BASELINE_OFFSET;
let y_offset = digit_font.text_height() / 2 + Button::BASELINE_OFFSET;
shape::Bar::new(self.area).with_bg(theme::BG).render(target);
shape::Text::new(self.area.center() + Offset::y(y_offset), text)

Loading…
Cancel
Save