-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port all remaining topbar-UI code to nuon
- Loading branch information
1 parent
074123b
commit d2579bf
Showing
5 changed files
with
128 additions
and
71 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use crate::{Element, LayoutCtx, Node, ParentLayout, RenderCtx, Renderer, Tree, Widget}; | ||
|
||
pub struct Canvas<F> { | ||
draw: F, | ||
} | ||
|
||
impl<F: Fn(&mut dyn Renderer, &Node)> Canvas<F> { | ||
pub fn new(draw: F) -> Self { | ||
Self { draw } | ||
} | ||
} | ||
|
||
impl<MSG: Clone, F: Fn(&mut dyn Renderer, &Node)> Widget<MSG> for Canvas<F> { | ||
type State = (); | ||
|
||
fn layout( | ||
&self, | ||
_tree: &mut Tree<Self::State>, | ||
parent: &ParentLayout, | ||
_ctx: &LayoutCtx, | ||
) -> Node { | ||
Node { | ||
x: parent.x, | ||
y: parent.y, | ||
w: parent.w, | ||
h: parent.h, | ||
children: vec![], | ||
} | ||
} | ||
|
||
fn render( | ||
&self, | ||
renderer: &mut dyn Renderer, | ||
layout: &Node, | ||
_tree: &Tree<Self::State>, | ||
_ctx: &RenderCtx, | ||
) { | ||
(self.draw)(renderer, layout) | ||
} | ||
} | ||
|
||
impl<MSG: Clone + 'static, F: Fn(&mut dyn Renderer, &Node) + 'static> From<Canvas<F>> | ||
for Element<MSG> | ||
{ | ||
fn from(value: Canvas<F>) -> Self { | ||
Element::new(value) | ||
} | ||
} |
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,4 +1,5 @@ | ||
pub mod button; | ||
pub mod canvas; | ||
pub mod column; | ||
pub mod container; | ||
pub mod null; | ||
|