RenderScope with Text

This commit is contained in:
2026-07-13 09:52:49 -04:00
parent c58f071d80
commit 4be1f329df
3 changed files with 56 additions and 3 deletions
+31
View File
@@ -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<RenderScope> 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())
}
}
+19
View File
@@ -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();
}
}
@@ -1,8 +1,9 @@
pub module widget; pub module widget;
use crate::units; use crate::units;
use crate::render_scope;
class Widget pub class Widget
{ {
units::Position x = units::Position::Char(0); units::Position x = units::Position::Char(0);
units::Position y = units::Position::Char(0); units::Position y = units::Position::Char(0);
@@ -12,7 +13,9 @@ class Widget
pub constructor() {} 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) {}
} }