You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trezor-firmware/core/embed/rust/src/ui/component/painter.rs

39 lines
642 B

use crate::ui::{
component::{Component, Event, EventCtx, Never},
geometry::Rect,
};
pub struct Painter<F> {
area: Rect,
func: F,
}
impl<F> Painter<F> {
pub fn new(func: F) -> Self {
Self {
func,
area: Rect::zero(),
}
}
}
impl<F> Component for Painter<F>
where
F: FnMut(Rect),
{
type Msg = Never;
fn place(&mut self, bounds: Rect) -> Rect {
self.area = bounds;
self.area
}
fn event(&mut self, _ctx: &mut EventCtx, _event: Event) -> Option<Self::Msg> {
None
}
fn paint(&mut self) {
(self.func)(self.area);
}
}