1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-07-12 17:48:09 +00:00
trezor-firmware/core/embed/rust/src/ui/component/pad.rs
2022-05-16 13:54:43 +02:00

49 lines
859 B
Rust

use crate::ui::{
display::{self, Color},
geometry::Rect,
};
pub struct Pad {
pub area: Rect,
color: Color,
clear: bool,
}
impl Pad {
pub fn with_background(color: Color) -> Self {
Self {
color,
area: Rect::zero(),
clear: false,
}
}
pub fn place(&mut self, area: Rect) {
self.area = area;
}
pub fn clear(&mut self) {
self.clear = true;
}
pub fn cancel_clear(&mut self) {
self.clear = false;
}
pub fn will_paint(&self) -> Option<(Rect, Color)> {
if self.clear {
Some((self.area, self.color))
} else {
None
}
}
pub fn paint(&mut self) {
if self.clear {
self.clear = false;
display::rect_fill(self.area, self.color);
}
}
}