Widget structure
This commit is contained in:
@@ -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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -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) {}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user