From 4be1f329dfcf0d9e844434d20f133adb4b92da4a Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Mon, 13 Jul 2026 09:52:49 -0400 Subject: [PATCH] RenderScope with Text --- pulse-ui/src/render_scope.mist | 31 ++++++++++++++++++++++++++ pulse-ui/src/widgets/text.mist | 19 ++++++++++++++++ pulse-ui/src/{ => widgets}/widget.mist | 9 +++++--- 3 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 pulse-ui/src/render_scope.mist create mode 100644 pulse-ui/src/widgets/text.mist rename pulse-ui/src/{ => widgets}/widget.mist (58%) 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) {} }