diff --git a/pulse-ui/src/lib.rs b/pulse-ui/src/lib.rs index c06e713..3318231 100644 --- a/pulse-ui/src/lib.rs +++ b/pulse-ui/src/lib.rs @@ -1,4 +1,4 @@ pub mod layout; pub mod render; -pub mod widget; pub mod unit; +pub mod widget; diff --git a/pulse-ui/src/render.rs b/pulse-ui/src/render.rs index 168eb00..f5397ff 100644 --- a/pulse-ui/src/render.rs +++ b/pulse-ui/src/render.rs @@ -41,6 +41,12 @@ impl From<(u16, u16)> for Point { } } +impl From for Point { + fn from(value: u16) -> Self { + Self { x: value, y: value } + } +} + impl From for Point { fn from(value: Rect) -> Self { Self { diff --git a/pulse-ui/src/widget.rs b/pulse-ui/src/widget.rs deleted file mode 100644 index 081d857..0000000 --- a/pulse-ui/src/widget.rs +++ /dev/null @@ -1,5 +0,0 @@ -use crate::render::RenderScope; - -pub trait Widget { - fn render(&self, scope: &mut RenderScope); -} diff --git a/pulse-ui/src/widget/mod.rs b/pulse-ui/src/widget/mod.rs new file mode 100644 index 0000000..d784062 --- /dev/null +++ b/pulse-ui/src/widget/mod.rs @@ -0,0 +1,11 @@ +use crate::render::RenderScope; + +pub trait Widget { + fn render(&self, scope: &mut RenderScope); +} + +impl Widget for str { + fn render(&self, scope: &mut RenderScope) { + scope.draw_text(0, self); + } +} diff --git a/src/main.rs b/src/main.rs index 64f5682..925c9dd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,7 @@ -use pulse_ui::layout::{LayoutItem, Rect, Size, layout}; +use pulse_ui::{ + layout::{LayoutItem, layout}, + unit::{Rect, Size}, +}; fn main() { let layout = layout(vec![