Widget structure

This commit is contained in:
2026-07-13 09:14:00 -04:00
parent af785b3aa9
commit c58f071d80
3 changed files with 36 additions and 25 deletions
-25
View File
@@ -1,25 +0,0 @@
pub module state_management;
use std::sync::Arc;
use std::sync::Mutex;
use std::sync::LockResult;
use std::sync::MutexGuard;
pub trait Dependent
{
void update(&self);
}
pub struct State<T>
{
pub Box<dyn Dependent> dependent;
pub Arc<Mutex<T>> data;
}
impl<T> State<T>
{
LockResult<MutexGuard<'_, T>> lock(&self)
{
self.data.lock()
}
}
+18
View File
@@ -0,0 +1,18 @@
pub module units;
pub enum Position
{
Char(u16);
ScreenUnits { u16 units; u16 div; };
Percent(u16);
Center;
End;
}
pub enum Size
{
Char(u16);
ScreenUnits { u16 units; u16 div; };
Percent(u16);
Full;
}
+18
View File
@@ -0,0 +1,18 @@
pub module widget;
use crate::units;
class Widget
{
units::Position x = units::Position::Char(0);
units::Position y = units::Position::Char(0);
units::Size width = units::Size::Full;
units::Size height = units::Size::Full;
pub constructor() {}
void render(&self) {}
void update(&mut self) {}
}