Skip to content

Commit fd5488d

Browse files
authored
Merge f692bbb into 741ef65
2 parents 741ef65 + f692bbb commit fd5488d

File tree

27 files changed

+435
-63
lines changed

27 files changed

+435
-63
lines changed

.github/workflows/rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: Install linux dependencies
3434
if: runner.os == 'Linux'
3535
run: |
36-
sudo apt update && sudo apt install build-essential libssl-dev pkg-config libglib2.0-dev libgtk-3-dev
36+
sudo apt update && sudo apt install build-essential libssl-dev pkg-config libglib2.0-dev libgtk-3-dev libudev-dev
3737
- name: Check examples
3838
run: cargo check --examples
3939
- name: Lint

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ dioxus-router = { workspace = true }
8686
itertools = "0.13.0"
8787
home = "0.5.9"
8888
dioxus-query = "0.5.1"
89+
gilrs = "0.10.8"
8990

9091
[profile.release]
9192
lto = true

crates/common/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ torin = { workspace = true }
2323
dioxus-core = { workspace = true }
2424

2525
accesskit = { workspace = true }
26-
accesskit_winit = { workspace = true }
2726
winit = { workspace = true }
2827
freya-engine = { workspace = true }
2928
freya-native-core = { workspace = true }

crates/common/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
mod event_messages;
21
mod layers;
32
mod layout;
43
mod paragraphs;
54

6-
pub use event_messages::*;
75
pub use layers::*;
86
pub use layout::*;
97
pub use paragraphs::*;

crates/components/src/native_container.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use dioxus::prelude::*;
2-
use freya_common::EventMessage;
2+
use freya_core::prelude::EventMessage;
33
use freya_elements::{
44
elements as dioxus_elements,
55
events::KeyboardEvent,

crates/core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ dioxus-core = { workspace = true }
3131
tokio = { workspace = true }
3232
winit = { workspace = true }
3333
accesskit = { workspace = true }
34+
accesskit_winit = { workspace = true }
3435

3536
rustc-hash = { workspace = true }
3637
tracing = { workspace = true }

crates/core/src/dom/doms.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use dioxus_core::VirtualDom;
88
use freya_common::{
99
Layers,
1010
ParagraphElements,
11-
TextGroupMeasurement,
1211
};
1312
use freya_native_core::{
1413
prelude::{
@@ -38,7 +37,10 @@ use torin::prelude::*;
3837
use tracing::info;
3938

4039
use super::mutations_writer::MutationsWriter;
41-
use crate::prelude::measure_paragraph;
40+
use crate::prelude::{
41+
measure_paragraph,
42+
TextGroupMeasurement,
43+
};
4244

4345
pub type DioxusDOM = RealDom<CustomAttributeValues>;
4446
pub type DioxusNode<'a> = NodeRef<'a, CustomAttributeValues>;

crates/common/src/event_messages.rs renamed to crates/core/src/event_messages.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ use winit::window::{
66
Window,
77
};
88

9+
use crate::prelude::PlatformEvent;
10+
911
pub struct TextGroupMeasurement {
1012
pub text_id: Uuid,
1113
pub cursor_id: usize,
@@ -39,6 +41,8 @@ pub enum EventMessage {
3941
ExitApp,
4042
/// Callback to access the Window.
4143
WithWindow(Box<dyn FnOnce(&Window) + Send + Sync>),
44+
45+
PlatformEvent(PlatformEvent),
4246
}
4347

4448
impl From<accesskit_winit::Event> for EventMessage {

crates/core/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
pub mod accessibility;
22
pub mod dom;
33
pub mod elements;
4+
pub mod event_messages;
45
pub mod events;
56
pub mod layout;
67
pub mod node;
@@ -16,6 +17,7 @@ pub mod prelude {
1617
accessibility::*,
1718
dom::*,
1819
elements::*,
20+
event_messages::*,
1921
events::*,
2022
layout::*,
2123
node::*,

crates/core/src/plugins.rs

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,41 @@ use freya_engine::prelude::{
44
};
55
use freya_native_core::NodeId;
66
use torin::torin::Torin;
7-
use winit::window::Window;
7+
use winit::{
8+
event_loop::EventLoopProxy,
9+
window::Window,
10+
};
11+
12+
use crate::{
13+
dom::FreyaDOM,
14+
prelude::{
15+
EventMessage,
16+
PlatformEvent,
17+
},
18+
};
19+
20+
#[derive(Clone)]
21+
pub struct PluginHandle {
22+
pub proxy: EventLoopProxy<EventMessage>,
23+
}
824

9-
use crate::dom::FreyaDOM;
25+
impl PluginHandle {
26+
pub fn new(proxy: EventLoopProxy<EventMessage>) -> Self {
27+
Self { proxy }
28+
}
29+
30+
/// Emit a [PlatformEvent]. Useful to simulate certain events.
31+
pub fn send_platform_event(&self, event: PlatformEvent) {
32+
self.proxy
33+
.send_event(EventMessage::PlatformEvent(event))
34+
.ok();
35+
}
36+
37+
/// Emit a [EventMessage].
38+
pub fn send_event_loop_event(&self, event: EventMessage) {
39+
self.proxy.send_event(event).ok();
40+
}
41+
}
1042

1143
/// Manages all loaded plugins.
1244
#[derive(Default)]
@@ -19,9 +51,9 @@ impl PluginsManager {
1951
self.plugins.push(Box::new(plugin))
2052
}
2153

22-
pub fn send(&mut self, event: PluginEvent) {
54+
pub fn send(&mut self, event: PluginEvent, handle: PluginHandle) {
2355
for plugin in &mut self.plugins {
24-
plugin.on_event(&event)
56+
plugin.on_event(&event, handle.clone())
2557
}
2658
}
2759
}
@@ -59,5 +91,5 @@ pub enum PluginEvent<'a> {
5991
/// Skeleton for Freya plugins.
6092
pub trait FreyaPlugin {
6193
/// React on events emitted by Freya.
62-
fn on_event(&mut self, event: &PluginEvent);
94+
fn on_event(&mut self, event: &PluginEvent, handle: PluginHandle);
6395
}

0 commit comments

Comments
 (0)