A fork of pulp-os for the xteink4 adding custom apps
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

add: ui skeleton

hansmrtn 00049043 3099d4c4

+19 -22
+6 -5
src/ui/button.rs
··· 1 1 //! Button widget for interactive UI elements 2 2 3 3 use embedded_graphics::{ 4 - prelude::*, 5 - pixelcolor::BinaryColor, 6 4 mono_font::MonoFont, 7 5 mono_font::MonoTextStyle, 6 + pixelcolor::BinaryColor, 7 + prelude::*, 8 + primitives::{CornerRadii, PrimitiveStyle, Rectangle, RoundedRectangle}, 8 9 text::Text, 9 - primitives::{Rectangle, PrimitiveStyle, RoundedRectangle, CornerRadii}, 10 10 }; 11 11 12 - use super::widget::{Region, Widget, Alignment, WidgetState}; 12 + use super::widget::{Alignment, Region, Widget, WidgetState}; 13 13 14 14 /// Button visual style 15 15 #[derive(Clone, Copy, Debug, Default, PartialEq)] ··· 112 112 .draw(display)?; 113 113 } 114 114 ButtonStyle::Rounded(radius) => { 115 - let rounded = RoundedRectangle::new(rect, CornerRadii::new(Size::new(radius, radius))); 115 + let rounded = 116 + RoundedRectangle::new(rect, CornerRadii::new(Size::new(radius, radius))); 116 117 // Clear background 117 118 rounded 118 119 .into_styled(PrimitiveStyle::with_fill(bg))
+6 -6
src/ui/label.rs
··· 1 1 use embedded_graphics::{ 2 - prelude::*, 3 - pixelcolor::BinaryColor, 4 2 mono_font::{MonoFont, MonoTextStyle}, 5 - text::Text, 3 + pixelcolor::BinaryColor, 4 + prelude::*, 6 5 primitives::PrimitiveStyle, 6 + text::Text, 7 7 }; 8 8 9 - use super::widget::{Region, Widget, Alignment, WidgetState}; 9 + use super::widget::{Alignment, Region, Widget, WidgetState}; 10 10 11 11 /// A text label widget 12 12 /// Automatically handles background clearing on redraw. ··· 88 88 // Calculate text position 89 89 let text_size = self.text_size(); 90 90 let mut pos = self.alignment.position(self.region, text_size); 91 - 91 + 92 92 // Adjust for text baseline (embedded-graphics draws from baseline) 93 93 pos.y += self.font.character_size.height as i32; 94 94 ··· 226 226 } 227 227 228 228 /// Write formatted text to a DynamicLabel 229 - /// 229 + /// 230 230 /// Usage: 231 231 /// ```ignore 232 232 /// use core::fmt::Write;
+4 -5
src/ui/mod.rs
··· 29 29 //! display.refresh_partial(r.x, r.y, r.w, r.h, &mut delay); 30 30 //! ``` 31 31 32 - mod widget; 33 - mod label; 34 32 mod button; 33 + mod label; 34 + mod widget; 35 35 // mod progress; 36 36 37 - pub use widget::{Region, Widget, Alignment, WidgetState}; 38 - pub use label::{Label, DynamicLabel}; 39 37 pub use button::{Button, ButtonStyle}; 38 + pub use label::{DynamicLabel, Label}; 39 + pub use widget::{Alignment, Region, Widget, WidgetState}; 40 40 // pub use progress::{ProgressBar, BatteryIndicator, Orientation}; 41 41 42 42 use embedded_graphics::{pixelcolor::BinaryColor, prelude::*}; ··· 61 61 widget.draw(self) 62 62 } 63 63 } 64 -
+3 -6
src/ui/widget.rs
··· 1 1 //! Widgets are self-contained UI elements that know their bounds and can 2 2 //! draw themselves. They work in logical coordinates (rotation-aware). 3 3 use embedded_graphics::{ 4 - prelude::*, 5 4 pixelcolor::BinaryColor, 6 - primitives::{Rectangle, PrimitiveStyle}, 5 + prelude::*, 6 + primitives::{PrimitiveStyle, Rectangle}, 7 7 }; 8 8 9 9 /// A rectangular region in logical coordinates. ··· 44 44 } 45 45 46 46 pub fn center(self) -> Point { 47 - Point::new( 48 - (self.x + self.w / 2) as i32, 49 - (self.y + self.h / 2) as i32, 50 - ) 47 + Point::new((self.x + self.w / 2) as i32, (self.y + self.h / 2) as i32) 51 48 } 52 49 53 50 /// Align X to 8-pixel boundary (required for partial refresh)