mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-17 01:52:02 +00:00
feat(core/ui): allow rounded mercury button
[no changelog]
This commit is contained in:
parent
4d462e48f0
commit
f11c2891d8
@ -31,6 +31,7 @@ pub struct Button {
|
|||||||
content: ButtonContent,
|
content: ButtonContent,
|
||||||
styles: ButtonStyleSheet,
|
styles: ButtonStyleSheet,
|
||||||
text_align: Alignment,
|
text_align: Alignment,
|
||||||
|
radius: Option<u8>,
|
||||||
state: State,
|
state: State,
|
||||||
long_press: Option<Duration>,
|
long_press: Option<Duration>,
|
||||||
long_timer: Option<TimerToken>,
|
long_timer: Option<TimerToken>,
|
||||||
@ -49,6 +50,7 @@ impl Button {
|
|||||||
touch_expand: None,
|
touch_expand: None,
|
||||||
styles: theme::button_default(),
|
styles: theme::button_default(),
|
||||||
text_align: Alignment::Start,
|
text_align: Alignment::Start,
|
||||||
|
radius: None,
|
||||||
state: State::Initial,
|
state: State::Initial,
|
||||||
long_press: None,
|
long_press: None,
|
||||||
long_timer: None,
|
long_timer: None,
|
||||||
@ -95,6 +97,11 @@ impl Button {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn with_radius(mut self, radius: u8) -> Self {
|
||||||
|
self.radius = Some(radius);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn enable_if(&mut self, ctx: &mut EventCtx, enabled: bool) {
|
pub fn enable_if(&mut self, ctx: &mut EventCtx, enabled: bool) {
|
||||||
if enabled {
|
if enabled {
|
||||||
self.enable(ctx);
|
self.enable(ctx);
|
||||||
@ -178,10 +185,21 @@ impl Button {
|
|||||||
pub fn render_background<'s>(&self, target: &mut impl Renderer<'s>, style: &ButtonStyle) {
|
pub fn render_background<'s>(&self, target: &mut impl Renderer<'s>, style: &ButtonStyle) {
|
||||||
match &self.content {
|
match &self.content {
|
||||||
ButtonContent::IconBlend(_, _, _) => {}
|
ButtonContent::IconBlend(_, _, _) => {}
|
||||||
_ => shape::Bar::new(self.area)
|
_ => {
|
||||||
.with_bg(style.button_color)
|
if self.radius.is_some() {
|
||||||
.with_fg(style.button_color)
|
shape::Bar::new(self.area)
|
||||||
.render(target),
|
.with_bg(style.background_color)
|
||||||
|
.with_radius(self.radius.unwrap() as i16)
|
||||||
|
.with_thickness(2)
|
||||||
|
.with_fg(style.button_color)
|
||||||
|
.render(target);
|
||||||
|
} else {
|
||||||
|
shape::Bar::new(self.area)
|
||||||
|
.with_bg(style.button_color)
|
||||||
|
.with_fg(style.button_color)
|
||||||
|
.render(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user