fix(core/rust/ui): add cargo flag for Component::bounds() support

Rarely used debugging feature.

[no changelog]
pull/2905/head
Martin Milata 1 year ago
parent afe965687f
commit e60ed788f2

@ -15,6 +15,7 @@ protobuf = ["micropython"]
ui = []
dma2d = []
ui_debug = []
ui_bounds = []
bootloader = []
buttons = []
touch = []

@ -54,6 +54,7 @@ pub trait Component {
/// the `Child` wrapper.
fn paint(&mut self);
#[cfg(feature = "ui_bounds")]
/// Report current paint bounds of this component. Used for debugging.
fn bounds(&self, _sink: &mut dyn FnMut(Rect)) {}
}
@ -146,6 +147,7 @@ where
}
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
self.component.bounds(sink)
}
@ -199,6 +201,7 @@ where
self.1.paint();
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
self.0.bounds(sink);
self.1.bounds(sink);
@ -249,6 +252,7 @@ where
self.2.paint();
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
self.0.bounds(sink);
self.1.bounds(sink);
@ -301,6 +305,7 @@ where
}
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
if let Some(ref c) = self {
c.bounds(sink)

@ -39,6 +39,7 @@ where
self.inner.paint()
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
self.inner.bounds(sink);
}

@ -48,6 +48,7 @@ impl Component for Image {
self.draw(self.area.center(), CENTER);
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
sink(Rect::from_center_and_size(
self.area.center(),
@ -123,6 +124,7 @@ impl Component for BlendedImage {
self.paint_image();
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
sink(Rect::from_top_left_and_size(
self.bg_top_left,

@ -80,6 +80,7 @@ where
self.layout.render_text(self.text.as_ref());
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
sink(self.layout.bounds)
}

@ -31,6 +31,7 @@ where
self.inner.paint()
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
self.inner.bounds(sink);
}

@ -93,6 +93,7 @@ where
}
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
sink(self.pad.area);
self.inner.bounds(sink);

@ -39,6 +39,7 @@ where
(self.func)(self.area);
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
sink(self.area)
}

@ -141,6 +141,7 @@ impl Component for Qr {
Self::draw(&qr, area, self.border, scale);
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
sink(self.area)
}

@ -138,6 +138,7 @@ where
self.layout_content(&mut TextRenderer);
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
sink(self.layout.bounds)
}

@ -201,6 +201,7 @@ where
)
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
sink(self.area);
for layout in &self.visible {
@ -595,6 +596,7 @@ where
}
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
sink(self.area);
self.paragraphs.bounds(sink);

@ -64,7 +64,7 @@ pub trait ObjComponent: MaybeTrace {
fn obj_place(&mut self, bounds: Rect) -> Rect;
fn obj_event(&mut self, ctx: &mut EventCtx, event: Event) -> Result<Obj, Error>;
fn obj_paint(&mut self) -> bool;
fn obj_bounds(&self, sink: &mut dyn FnMut(Rect));
fn obj_bounds(&self, _sink: &mut dyn FnMut(Rect)) {}
fn obj_skip_paint(&mut self) {}
}
@ -90,6 +90,7 @@ where
will_paint
}
#[cfg(feature = "ui_bounds")]
fn obj_bounds(&self, sink: &mut dyn FnMut(Rect)) {
self.bounds(sink)
}
@ -509,7 +510,7 @@ extern "C" fn ui_layout_trace(_this: Obj, _callback: Obj) -> Obj {
Obj::const_none()
}
#[cfg(feature = "ui_debug")]
#[cfg(feature = "ui_bounds")]
extern "C" fn ui_layout_bounds(this: Obj) -> Obj {
let block = || {
let this: Gc<LayoutObj> = this.try_into()?;
@ -519,7 +520,7 @@ extern "C" fn ui_layout_bounds(this: Obj) -> Obj {
unsafe { util::try_or_raise(block) }
}
#[cfg(not(feature = "ui_debug"))]
#[cfg(not(feature = "ui_bounds"))]
extern "C" fn ui_layout_bounds(_this: Obj) -> Obj {
Obj::const_none()
}

@ -188,6 +188,7 @@ impl<'a> Component for Confirm<'a> {
}
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
self.left.bounds(sink);
self.right.bounds(sink);

@ -94,6 +94,7 @@ impl<'a> Component for Intro<'a> {
self.menu.paint();
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
self.menu.bounds(sink);
}

@ -98,6 +98,7 @@ impl Component for Menu {
self.reset.paint();
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
self.close.bounds(sink);
self.reboot.bounds(sink);

@ -181,6 +181,7 @@ where
}
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
match self.current_page {
0 => self.qr_code.bounds(sink),

@ -314,6 +314,7 @@ where
self.paint_content(style);
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
sink(self.area);
}

@ -71,6 +71,7 @@ where
self.controls.paint();
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
self.content.bounds(sink);
self.controls.bounds(sink);
@ -192,6 +193,7 @@ where
self.controls.paint();
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
self.image.bounds(sink);
self.paragraphs.bounds(sink);

@ -191,6 +191,7 @@ where
}
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
self.icon.bounds(sink);
self.app_name.bounds(sink);

@ -152,6 +152,7 @@ where
self.content.paint();
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
self.title.bounds(sink);
self.button.bounds(sink);
@ -242,6 +243,7 @@ where
self.content.paint();
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
sink(self.area);
self.content.bounds(sink);

@ -91,6 +91,7 @@ where
self.buttons.paint();
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
sink(self.pad.area);
if self.loader.is_animating() {
@ -171,6 +172,7 @@ impl Component for CancelHold {
self.hold.paint();
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
self.cancel.bounds(sink);
self.hold.bounds(sink);

@ -212,6 +212,7 @@ where
}
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
self.loader.bounds(sink);
sink(self.pad.area);

@ -124,6 +124,7 @@ where
}
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
sink(self.pad.area);
self.scrollbar.bounds(sink);

@ -144,6 +144,7 @@ impl Component for Bip39Input {
}
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
self.button.bounds(sink);
}

@ -163,6 +163,7 @@ where
}
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
self.prompt.bounds(sink);
self.input.bounds(sink);

@ -264,6 +264,7 @@ impl Component for PassphraseKeyboard {
}
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
self.input.bounds(sink);
self.scrollbar.bounds(sink);
@ -367,6 +368,7 @@ impl Component for Input {
}
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
sink(self.area)
}

@ -270,6 +270,7 @@ where
}
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
self.major_prompt.bounds(sink);
self.minor_prompt.bounds(sink);
@ -454,6 +455,7 @@ impl Component for PinDots {
}
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
sink(self.area);
sink(self.area.inset(HEADER_PADDING));

@ -178,6 +178,7 @@ impl Component for Slip39Input {
}
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
self.button.bounds(sink);
}

@ -57,6 +57,7 @@ impl Component for SelectWordCount {
}
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
for btn in self.button.iter() {
btn.bounds(sink)

@ -118,6 +118,7 @@ where
self.confirm_button.paint();
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
sink(self.area);
self.input.bounds(sink);
@ -226,6 +227,7 @@ impl Component for NumberInput {
self.inc.paint();
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
self.dec.bounds(sink);
self.inc.bounds(sink);

@ -279,6 +279,7 @@ where
}
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
sink(self.pad.area);
self.scrollbar.bounds(sink);
@ -458,6 +459,7 @@ where
}
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
self.loader.bounds(sink);
self.inner.bounds(sink);

@ -119,6 +119,7 @@ where
self.description.paint();
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
sink(Self::AREA);
self.title.bounds(sink);

@ -120,6 +120,7 @@ impl Component for ScrollBar {
bounds
}
#[cfg(feature = "ui_bounds")]
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {
sink(self.area);
}

Loading…
Cancel
Save