diff --git a/pulse-ui/src/render_scope.mist b/pulse-ui/src/render_scope.mist new file mode 100644 index 0000000..80a660b --- /dev/null +++ b/pulse-ui/src/render_scope.mist @@ -0,0 +1,31 @@ +pub module render_scope; + +pub class RenderScope +{ + u16 x = 0; + u16 y = 0; + u16 width = 0; + u16 height = 0; + + pub constructor() {} +} + +pub class RenderStack +{ + pub Vec stack; + + pub constructor() + { + self.stack = Vec::new(); + } + + pub RenderScope pop(&mut self) + { + self.stack.pop().expect("Failed to pop, no more items in the stack") + } + + pub RenderScope mut'a& push<'a>(&'a mut self) + { + self.stack.push_mut(RenderScope::new()) + } +} diff --git a/pulse-ui/src/widgets/text.mist b/pulse-ui/src/widgets/text.mist new file mode 100644 index 0000000..ea36234 --- /dev/null +++ b/pulse-ui/src/widgets/text.mist @@ -0,0 +1,19 @@ +pub module text; + +use super::widget::Widget; +use crate::render_scope; + +pub class Text : Widget { + String text; + + pub constructor(str& text) + { + super = Super::new(); + self.text = text.to_string(); + } + + pub virtual void render(&self, render_scope::RenderStack mut& stack) override + { + render_scope::RenderScope mut& scope = stack.push(); + } +} diff --git a/pulse-ui/src/widget.mist b/pulse-ui/src/widgets/widget.mist similarity index 58% rename from pulse-ui/src/widget.mist rename to pulse-ui/src/widgets/widget.mist index 056a576..a2d8c59 100644 --- a/pulse-ui/src/widget.mist +++ b/pulse-ui/src/widgets/widget.mist @@ -1,8 +1,9 @@ pub module widget; use crate::units; +use crate::render_scope; -class Widget +pub class Widget { units::Position x = units::Position::Char(0); units::Position y = units::Position::Char(0); @@ -12,7 +13,9 @@ class Widget pub constructor() {} - void render(&self) {} + pub virtual void render(&self, render_scope::RenderStack mut& stack) { + let _ = stack; + } - void update(&mut self) {} + pub virtual void update(&self) {} }