-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
6 changed files
with
62 additions
and
61 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
[package] | ||
name = "concoct" | ||
version = "0.2.0" | ||
version = "0.4.0" | ||
edition = "2021" | ||
license = "MIT OR Apache-2.0" | ||
description = "Generic UI compiler and runtime library" | ||
repository = "https://github.com/concoct-rs/concoct" | ||
|
||
[features] | ||
full = [] | ||
gl = ["dep:gl", "dep:glutin", "dep:glutin-winit", "dep:raw-window-handle", "dep:slotmap", "dep:winit"] | ||
|
||
[dependencies] | ||
tokio = { version = "1.29.1", features = ["full"] } | ||
accesskit = "0.11.1" | ||
gl = "0.14.0" | ||
glutin = "0.30.9" | ||
glutin-winit = "0.3.0" | ||
raw-window-handle = "0.5.2" | ||
gl = { version = "0.14.0", optional = true } | ||
glutin = { version = "0.30.9", optional = true } | ||
glutin-winit = { version = "0.3.0", optional = true } | ||
raw-window-handle = { version = "0.5.2", optional = true } | ||
skia-safe = { version = "0.64.0", features = ["gl"] } | ||
slotmap = "1.0.6" | ||
slotmap = { version = "1.0.6", optional = true } | ||
taffy = "0.3.12" | ||
winit = "0.28.6" | ||
winit = { version = "0.28.6", optional = true } |
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,51 +1,6 @@ | ||
#[cfg(feature = "gl")] | ||
mod renderer; | ||
|
||
use std::any::Any; | ||
|
||
use accesskit::Role; | ||
#[cfg(feature = "gl")] | ||
pub use renderer::{Event, Renderer}; | ||
use view::{Id, View}; | ||
|
||
pub mod view; | ||
|
||
pub fn clickable<F, V>(_role: Role, on_click: F, view: V) -> EventHandler<F, V> { | ||
EventHandler::new(on_click, view) | ||
} | ||
|
||
pub struct EventHandler<F, V> { | ||
on_event: F, | ||
view: V, | ||
} | ||
|
||
impl<F, V> EventHandler<F, V> { | ||
pub fn new(on_event: F, view: V) -> Self { | ||
Self { on_event, view } | ||
} | ||
} | ||
|
||
impl<T, A, F, V> View<T, A> for EventHandler<F, V> | ||
where | ||
V: View<T, A>, | ||
F: FnMut(&mut T), | ||
{ | ||
fn build(&mut self, cx: &mut view::BuildContext) -> Id { | ||
self.view.build(cx) | ||
} | ||
|
||
fn rebuild(&mut self, cx: &mut view::BuildContext, old: &mut Self) { | ||
self.view.rebuild(cx, &mut old.view) | ||
} | ||
|
||
fn layout(&mut self, cx: &mut view::LayoutContext, id: Id) { | ||
self.view.layout(cx, id) | ||
} | ||
|
||
fn paint(&mut self, taffy: &taffy::Taffy, canvas: &mut skia_safe::Canvas) { | ||
self.view.paint(taffy, canvas) | ||
} | ||
|
||
fn message(&mut self, state: &mut T, id_path: &[Id], message: &dyn Any) -> Option<A> { | ||
(self.on_event)(state); | ||
self.view.message(state, id_path, message) | ||
} | ||
} |
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,46 @@ | ||
use std::any::Any; | ||
use accesskit::Role; | ||
use super::{View, BuildContext, LayoutContext, Id}; | ||
|
||
|
||
pub fn clickable<F, V>(_role: Role, on_click: F, view: V) -> EventHandler<F, V> { | ||
EventHandler::new(on_click, view) | ||
} | ||
|
||
pub struct EventHandler<F, V> { | ||
on_event: F, | ||
view: V, | ||
} | ||
|
||
impl<F, V> EventHandler<F, V> { | ||
pub fn new(on_event: F, view: V) -> Self { | ||
Self { on_event, view } | ||
} | ||
} | ||
|
||
impl<T, A, F, V> View<T, A> for EventHandler<F, V> | ||
where | ||
V: View<T, A>, | ||
F: FnMut(&mut T), | ||
{ | ||
fn build(&mut self, cx: &mut BuildContext) -> Id { | ||
self.view.build(cx) | ||
} | ||
|
||
fn rebuild(&mut self, cx: &mut BuildContext, old: &mut Self) { | ||
self.view.rebuild(cx, &mut old.view) | ||
} | ||
|
||
fn layout(&mut self, cx: &mut LayoutContext, id: Id) { | ||
self.view.layout(cx, id) | ||
} | ||
|
||
fn paint(&mut self, taffy: &taffy::Taffy, canvas: &mut skia_safe::Canvas) { | ||
self.view.paint(taffy, canvas) | ||
} | ||
|
||
fn message(&mut self, state: &mut T, id_path: &[Id], message: &dyn Any) -> Option<A> { | ||
(self.on_event)(state); | ||
self.view.message(state, id_path, message) | ||
} | ||
} |
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