Update app structure
This commit is contained in:
+12
-6
@@ -4,22 +4,28 @@ pub mod unit;
|
||||
pub mod widget;
|
||||
|
||||
pub trait App {
|
||||
// State
|
||||
fn init(&mut self);
|
||||
fn update(&mut self);
|
||||
fn tick(&self);
|
||||
|
||||
// Rendering
|
||||
fn layout(&self) -> layout::Allocation;
|
||||
fn render(&mut self, layout: layout::Allocation);
|
||||
|
||||
// State
|
||||
fn init(&mut self);
|
||||
|
||||
fn update(&mut self);
|
||||
|
||||
fn refresh(&mut self) {
|
||||
self.render(self.layout());
|
||||
}
|
||||
|
||||
// Run
|
||||
// Running
|
||||
fn run(&mut self) {
|
||||
self.init();
|
||||
self.refresh();
|
||||
|
||||
loop {
|
||||
self.tick();
|
||||
self.update();
|
||||
self.refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user