-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
210 additions
and
32 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,29 @@ | ||
use slotmap::DefaultKey; | ||
use vello::SceneBuilder; | ||
|
||
mod text; | ||
pub use text::{Text, TextMessage}; | ||
|
||
pub trait Element { | ||
type Message; | ||
mod window; | ||
pub use window::Window; | ||
|
||
fn handle(&mut self, msg: Self::Message); | ||
use crate::TreeKey; | ||
|
||
fn render(&mut self, scene: SceneBuilder); | ||
pub struct LifecycleContext { | ||
pub tree_key: TreeKey, | ||
pub key: DefaultKey, | ||
} | ||
|
||
pub enum Lifecycle { | ||
Build, | ||
} | ||
|
||
#[derive(Default)] | ||
pub struct Window {} | ||
pub trait Element { | ||
type Message; | ||
|
||
impl Element for Window { | ||
type Message = (); | ||
fn lifecycle(&mut self, _cx: LifecycleContext, _lifecycle: Lifecycle) {} | ||
|
||
fn handle(&mut self, _msg: Self::Message) {} | ||
fn handle(&mut self, msg: Self::Message); | ||
|
||
fn render(&mut self, _scene: SceneBuilder) {} | ||
fn render(&mut self, scene: SceneBuilder); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use crate::{Element, UserInterface}; | ||
use vello::SceneBuilder; | ||
|
||
use super::LifecycleContext; | ||
|
||
pub struct Window { | ||
ui: UserInterface, | ||
} | ||
|
||
impl Window { | ||
pub fn new(ui: &UserInterface) -> Self { | ||
Self { ui: ui.clone() } | ||
} | ||
} | ||
|
||
impl Element for Window { | ||
type Message = (); | ||
|
||
fn lifecycle(&mut self, cx: LifecycleContext, _lifecycle: super::Lifecycle) { | ||
self.ui.insert_window(cx.tree_key, cx.key) | ||
} | ||
|
||
fn handle(&mut self, _msg: Self::Message) {} | ||
|
||
fn render(&mut self, _scene: SceneBuilder) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.