···11use embedded_graphics::{
22- prelude::*,
33- pixelcolor::BinaryColor,
42 mono_font::{MonoFont, MonoTextStyle},
55- text::Text,
33+ pixelcolor::BinaryColor,
44+ prelude::*,
65 primitives::PrimitiveStyle,
66+ text::Text,
77};
8899-use super::widget::{Region, Widget, Alignment, WidgetState};
99+use super::widget::{Alignment, Region, Widget, WidgetState};
10101111/// A text label widget
1212/// Automatically handles background clearing on redraw.
···8888 // Calculate text position
8989 let text_size = self.text_size();
9090 let mut pos = self.alignment.position(self.region, text_size);
9191-9191+9292 // Adjust for text baseline (embedded-graphics draws from baseline)
9393 pos.y += self.font.character_size.height as i32;
9494···226226}
227227228228/// Write formatted text to a DynamicLabel
229229-///
229229+///
230230/// Usage:
231231/// ```ignore
232232/// use core::fmt::Write;
+4-5
src/ui/mod.rs
···2929//! display.refresh_partial(r.x, r.y, r.w, r.h, &mut delay);
3030//! ```
31313232-mod widget;
3333-mod label;
3432mod button;
3333+mod label;
3434+mod widget;
3535// mod progress;
36363737-pub use widget::{Region, Widget, Alignment, WidgetState};
3838-pub use label::{Label, DynamicLabel};
3937pub use button::{Button, ButtonStyle};
3838+pub use label::{DynamicLabel, Label};
3939+pub use widget::{Alignment, Region, Widget, WidgetState};
4040// pub use progress::{ProgressBar, BatteryIndicator, Orientation};
41414242use embedded_graphics::{pixelcolor::BinaryColor, prelude::*};
···6161 widget.draw(self)
6262 }
6363}
6464-
+3-6
src/ui/widget.rs
···11//! Widgets are self-contained UI elements that know their bounds and can
22//! draw themselves. They work in logical coordinates (rotation-aware).
33use embedded_graphics::{
44- prelude::*,
54 pixelcolor::BinaryColor,
66- primitives::{Rectangle, PrimitiveStyle},
55+ prelude::*,
66+ primitives::{PrimitiveStyle, Rectangle},
77};
8899/// A rectangular region in logical coordinates.
···4444 }
45454646 pub fn center(self) -> Point {
4747- Point::new(
4848- (self.x + self.w / 2) as i32,
4949- (self.y + self.h / 2) as i32,
5050- )
4747+ Point::new((self.x + self.w / 2) as i32, (self.y + self.h / 2) as i32)
5148 }
52495350 /// Align X to 8-pixel boundary (required for partial refresh)