diff --git a/Cargo.toml b/Cargo.toml index 3c4da6672..10367f8ae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -86,6 +86,7 @@ dioxus-router = { workspace = true } itertools = "0.13.0" home = "0.5.9" dioxus-query = "0.5.1" +gilrs = "0.10.8" [profile.release] lto = true diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index dcdea4549..24493b798 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -23,7 +23,6 @@ torin = { workspace = true } dioxus-core = { workspace = true } accesskit = { workspace = true } -accesskit_winit = { workspace = true } winit = { workspace = true } freya-engine = { workspace = true } freya-native-core = { workspace = true } diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index 19513673d..1e1fc030f 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -1,9 +1,7 @@ -mod event_messages; mod layers; mod layout; mod paragraphs; -pub use event_messages::*; pub use layers::*; pub use layout::*; pub use paragraphs::*; diff --git a/crates/components/src/native_container.rs b/crates/components/src/native_container.rs index d1a441c99..94034a2ac 100644 --- a/crates/components/src/native_container.rs +++ b/crates/components/src/native_container.rs @@ -1,5 +1,5 @@ use dioxus::prelude::*; -use freya_common::EventMessage; +use freya_core::prelude::EventMessage; use freya_elements::{ elements as dioxus_elements, events::KeyboardEvent, diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index 61be210bf..e25259a6f 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -31,6 +31,7 @@ dioxus-core = { workspace = true } tokio = { workspace = true } winit = { workspace = true } accesskit = { workspace = true } +accesskit_winit = { workspace = true } rustc-hash = { workspace = true } tracing = { workspace = true } diff --git a/crates/core/src/dom/doms.rs b/crates/core/src/dom/doms.rs index cbf64c31e..b64663a1a 100644 --- a/crates/core/src/dom/doms.rs +++ b/crates/core/src/dom/doms.rs @@ -8,7 +8,6 @@ use dioxus_core::VirtualDom; use freya_common::{ Layers, ParagraphElements, - TextGroupMeasurement, }; use freya_native_core::{ prelude::{ @@ -38,7 +37,10 @@ use torin::prelude::*; use tracing::info; use super::mutations_writer::MutationsWriter; -use crate::prelude::measure_paragraph; +use crate::prelude::{ + measure_paragraph, + TextGroupMeasurement, +}; pub type DioxusDOM = RealDom; pub type DioxusNode<'a> = NodeRef<'a, CustomAttributeValues>; diff --git a/crates/common/src/event_messages.rs b/crates/core/src/event_messages.rs similarity index 95% rename from crates/common/src/event_messages.rs rename to crates/core/src/event_messages.rs index e9aad5a8d..b4a5a8ae7 100644 --- a/crates/common/src/event_messages.rs +++ b/crates/core/src/event_messages.rs @@ -6,6 +6,8 @@ use winit::window::{ Window, }; +use crate::prelude::PlatformEvent; + pub struct TextGroupMeasurement { pub text_id: Uuid, pub cursor_id: usize, @@ -39,6 +41,8 @@ pub enum EventMessage { ExitApp, /// Callback to access the Window. WithWindow(Box), + + PlatformEvent(PlatformEvent), } impl From for EventMessage { diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs index 490c79c81..c28513d1b 100644 --- a/crates/core/src/lib.rs +++ b/crates/core/src/lib.rs @@ -1,6 +1,7 @@ pub mod accessibility; pub mod dom; pub mod elements; +pub mod event_messages; pub mod events; pub mod layout; pub mod node; @@ -16,6 +17,7 @@ pub mod prelude { accessibility::*, dom::*, elements::*, + event_messages::*, events::*, layout::*, node::*, diff --git a/crates/core/src/plugins.rs b/crates/core/src/plugins.rs index 9455a7809..b43ad511f 100644 --- a/crates/core/src/plugins.rs +++ b/crates/core/src/plugins.rs @@ -4,9 +4,41 @@ use freya_engine::prelude::{ }; use freya_native_core::NodeId; use torin::torin::Torin; -use winit::window::Window; +use winit::{ + event_loop::EventLoopProxy, + window::Window, +}; + +use crate::{ + dom::FreyaDOM, + prelude::{ + EventMessage, + PlatformEvent, + }, +}; + +#[derive(Clone)] +pub struct PluginHandle { + pub proxy: EventLoopProxy, +} -use crate::dom::FreyaDOM; +impl PluginHandle { + pub fn new(proxy: EventLoopProxy) -> Self { + Self { proxy } + } + + /// Emit a [PlatformEvent]. Useful to simulate certain events. + pub fn send_platform_event(&self, event: PlatformEvent) { + self.proxy + .send_event(EventMessage::PlatformEvent(event)) + .ok(); + } + + /// Emit a [EventMessage]. + pub fn send_event_loop_event(&self, event: EventMessage) { + self.proxy.send_event(event).ok(); + } +} /// Manages all loaded plugins. #[derive(Default)] @@ -19,9 +51,9 @@ impl PluginsManager { self.plugins.push(Box::new(plugin)) } - pub fn send(&mut self, event: PluginEvent) { + pub fn send(&mut self, event: PluginEvent, handle: PluginHandle) { for plugin in &mut self.plugins { - plugin.on_event(&event) + plugin.on_event(&event, handle.clone()) } } } @@ -59,5 +91,5 @@ pub enum PluginEvent<'a> { /// Skeleton for Freya plugins. pub trait FreyaPlugin { /// React on events emitted by Freya. - fn on_event(&mut self, event: &PluginEvent); + fn on_event(&mut self, event: &PluginEvent, handle: PluginHandle); } diff --git a/crates/core/src/skia/paragraph.rs b/crates/core/src/skia/paragraph.rs index ded717dd0..84af671e1 100644 --- a/crates/core/src/skia/paragraph.rs +++ b/crates/core/src/skia/paragraph.rs @@ -3,7 +3,6 @@ use std::ops::Mul; use freya_common::{ CachedParagraph, CursorLayoutResponse, - TextGroupMeasurement, }; use freya_native_core::prelude::NodeImmutable; use freya_node_state::CursorState; @@ -15,6 +14,7 @@ use torin::prelude::{ use crate::prelude::{ align_main_align_paragraph, DioxusNode, + TextGroupMeasurement, }; /// Merasure the cursor positio and text selection and notify the subscribed component of the element. diff --git a/crates/freya/src/lib.rs b/crates/freya/src/lib.rs index cf2aab0e5..641caff6c 100644 --- a/crates/freya/src/lib.rs +++ b/crates/freya/src/lib.rs @@ -77,6 +77,11 @@ pub mod common { pub use freya_common::*; } +/// Core APIs. +pub mod core { + pub use freya_core::*; +} + /// Elements, attributes and events definitions. pub use freya_elements::elements; /// Events data. diff --git a/crates/freya/src/plugins/performance_overlay.rs b/crates/freya/src/plugins/performance_overlay.rs index c50257d97..11d257808 100644 --- a/crates/freya/src/plugins/performance_overlay.rs +++ b/crates/freya/src/plugins/performance_overlay.rs @@ -3,9 +3,12 @@ use std::time::{ Instant, }; -use freya_core::plugins::{ - FreyaPlugin, - PluginEvent, +use freya_core::{ + plugins::{ + FreyaPlugin, + PluginEvent, + }, + prelude::PluginHandle, }; use freya_engine::prelude::{ Color, @@ -35,7 +38,7 @@ pub struct PerformanceOverlayPlugin { } impl FreyaPlugin for PerformanceOverlayPlugin { - fn on_event(&mut self, event: &PluginEvent) { + fn on_event(&mut self, event: &PluginEvent, _handle: PluginHandle) { match event { PluginEvent::StartedLayout(_) => self.started_layout = Some(Instant::now()), PluginEvent::FinishedLayout(_) => { diff --git a/crates/hooks/src/use_editable.rs b/crates/hooks/src/use_editable.rs index 41a9d7d92..8ecfc4ad0 100644 --- a/crates/hooks/src/use_editable.rs +++ b/crates/hooks/src/use_editable.rs @@ -11,8 +11,8 @@ use dioxus_signals::{ Signal, Writable, }; -use freya_common::{ - CursorLayoutResponse, +use freya_common::CursorLayoutResponse; +use freya_core::prelude::{ EventMessage, TextGroupMeasurement, }; diff --git a/crates/hooks/src/use_focus.rs b/crates/hooks/src/use_focus.rs index 715784cfa..53c44b4f6 100644 --- a/crates/hooks/src/use_focus.rs +++ b/crates/hooks/src/use_focus.rs @@ -12,10 +12,10 @@ use dioxus_signals::{ Signal, Writable, }; -use freya_common::EventMessage; use freya_core::{ accessibility::ACCESSIBILITY_ROOT_ID, platform_state::NavigationMode, + prelude::EventMessage, types::AccessibilityId, }; use freya_elements::events::{ diff --git a/crates/hooks/src/use_platform.rs b/crates/hooks/src/use_platform.rs index a1d57f272..1b4c29a3f 100644 --- a/crates/hooks/src/use_platform.rs +++ b/crates/hooks/src/use_platform.rs @@ -9,7 +9,7 @@ use dioxus_signals::{ Readable, Signal, }; -use freya_common::EventMessage; +use freya_core::prelude::EventMessage; use tokio::sync::{ broadcast, mpsc::UnboundedSender, diff --git a/crates/renderer/src/accessibility.rs b/crates/renderer/src/accessibility.rs index 9bef78c53..9df07ca4d 100644 --- a/crates/renderer/src/accessibility.rs +++ b/crates/renderer/src/accessibility.rs @@ -1,9 +1,9 @@ use accesskit_winit::Adapter; -use freya_common::EventMessage; use freya_core::{ prelude::{ AccessibilityFocusDirection, AccessibilityManager, + EventMessage, SharedAccessibilityManager, ACCESSIBILITY_ROOT_ID, }, diff --git a/crates/renderer/src/app.rs b/crates/renderer/src/app.rs index 007034eb6..ecb8abc4a 100644 --- a/crates/renderer/src/app.rs +++ b/crates/renderer/src/app.rs @@ -4,10 +4,6 @@ use dioxus_core::{ Template, VirtualDom, }; -use freya_common::{ - EventMessage, - TextGroupMeasurement, -}; use freya_core::prelude::*; use freya_engine::prelude::*; use freya_native_core::{ @@ -76,7 +72,7 @@ impl Application { devtools: Option, window: &Window, fonts_config: EmbeddedFonts, - mut plugins: PluginsManager, + plugins: PluginsManager, default_fonts: Vec, ) -> Self { let accessibility = AccessKitManager::new(window, proxy.clone()); @@ -104,9 +100,7 @@ impl Application { scale_factor: window.scale_factor(), }); - plugins.send(PluginEvent::WindowCreated(window)); - - Self { + let mut app = Self { sdom, vdom, events: EventsQueue::new(), @@ -126,7 +120,14 @@ impl Application { measure_layout_on_next_render: false, default_fonts, queued_focus_node: None, - } + }; + + app.plugins.send( + PluginEvent::WindowCreated(window), + PluginHandle::new(app.proxy.clone()), + ); + + app } /// Provide the launch state and few other utilities like the EventLoopProxy @@ -144,24 +145,36 @@ impl Application { /// Make the first build of the VirtualDOM and sync it with the RealDOM. pub fn init_doms(&mut self, scale_factor: f32, app_state: Option) { - self.plugins.send(PluginEvent::StartedUpdatingDOM); + self.plugins.send( + PluginEvent::StartedUpdatingDOM, + PluginHandle::new(self.proxy.clone()), + ); self.provide_vdom_contexts(app_state); self.sdom.get_mut().init_dom(&mut self.vdom, scale_factor); - self.plugins.send(PluginEvent::FinishedUpdatingDOM); + self.plugins.send( + PluginEvent::FinishedUpdatingDOM, + PluginHandle::new(self.proxy.clone()), + ); } /// Update the RealDOM, layout and others with the latest changes from the VirtualDOM pub fn render_mutations(&mut self, scale_factor: f32) -> (bool, bool) { - self.plugins.send(PluginEvent::StartedUpdatingDOM); + self.plugins.send( + PluginEvent::StartedUpdatingDOM, + PluginHandle::new(self.proxy.clone()), + ); let (repaint, relayout) = self .sdom .get_mut() .render_mutations(&mut self.vdom, scale_factor); - self.plugins.send(PluginEvent::FinishedUpdatingDOM); + self.plugins.send( + PluginEvent::FinishedUpdatingDOM, + PluginHandle::new(self.proxy.clone()), + ); if repaint { if let Some(devtools) = &self.devtools { @@ -264,11 +277,14 @@ impl Application { /// Render the App into the Window Canvas pub fn render(&mut self, hovered_node: &HoveredNode, canvas: &Canvas, window: &Window) { - self.plugins.send(PluginEvent::BeforeRender { - canvas, - font_collection: &self.font_collection, - freya_dom: &self.sdom.get(), - }); + self.plugins.send( + PluginEvent::BeforeRender { + canvas, + font_collection: &self.font_collection, + freya_dom: &self.sdom.get(), + }, + PluginHandle::new(self.proxy.clone()), + ); self.start_render( hovered_node, @@ -280,11 +296,14 @@ impl Application { self.accessibility .render_accessibility(window.title().as_str()); - self.plugins.send(PluginEvent::AfterRender { - canvas, - font_collection: &self.font_collection, - freya_dom: &self.sdom.get(), - }); + self.plugins.send( + PluginEvent::AfterRender { + canvas, + font_collection: &self.font_collection, + freya_dom: &self.sdom.get(), + }, + PluginHandle::new(self.proxy.clone()), + ); } /// Resize the Window @@ -336,8 +355,10 @@ impl Application { { let fdom = self.sdom.get(); - self.plugins - .send(PluginEvent::StartedLayout(&fdom.layout())); + self.plugins.send( + PluginEvent::StartedLayout(&fdom.layout()), + PluginHandle::new(self.proxy.clone()), + ); process_layout( &fdom, @@ -350,8 +371,10 @@ impl Application { &self.default_fonts, ); - self.plugins - .send(PluginEvent::FinishedLayout(&fdom.layout())); + self.plugins.send( + PluginEvent::FinishedLayout(&fdom.layout()), + PluginHandle::new(self.proxy.clone()), + ); } if let Some(devtools) = &self.devtools { diff --git a/crates/renderer/src/renderer.rs b/crates/renderer/src/renderer.rs index 97462bdba..1c412b04b 100644 --- a/crates/renderer/src/renderer.rs +++ b/crates/renderer/src/renderer.rs @@ -4,7 +4,6 @@ use std::{ }; use dioxus_core::VirtualDom; -use freya_common::EventMessage; use freya_core::{ accessibility::AccessibilityFocusDirection, dom::SafeDOM, @@ -12,7 +11,10 @@ use freya_core::{ EventName, PlatformEvent, }, - prelude::NavigationMode, + prelude::{ + EventMessage, + NavigationMode, + }, }; use freya_elements::events::{ map_winit_key, @@ -218,6 +220,7 @@ impl<'a, State: Clone> ApplicationHandler for DesktopRenderer<'a, app.queue_focus_node(node_id); } EventMessage::ExitApp => event_loop.exit(), + EventMessage::PlatformEvent(platform_event) => self.send_event(platform_event), ev => { if let EventMessage::UpdateTemplate(template) = ev { app.vdom_replace_template(template); diff --git a/crates/renderer/src/window_state.rs b/crates/renderer/src/window_state.rs index fc53b2faf..a695ffb6c 100644 --- a/crates/renderer/src/window_state.rs +++ b/crates/renderer/src/window_state.rs @@ -5,8 +5,10 @@ use std::{ }; use dioxus_core::VirtualDom; -use freya_common::EventMessage; -use freya_core::dom::SafeDOM; +use freya_core::{ + dom::SafeDOM, + prelude::EventMessage, +}; use freya_engine::prelude::*; use gl::{ types::*, diff --git a/crates/renderer/src/winit_waker.rs b/crates/renderer/src/winit_waker.rs index 1c3a205d6..a87917673 100644 --- a/crates/renderer/src/winit_waker.rs +++ b/crates/renderer/src/winit_waker.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use freya_common::EventMessage; +use freya_core::prelude::EventMessage; use futures_task::{ waker, ArcWake, diff --git a/crates/testing/src/launch.rs b/crates/testing/src/launch.rs index 62d9bccd1..bf67dbf8b 100644 --- a/crates/testing/src/launch.rs +++ b/crates/testing/src/launch.rs @@ -4,9 +4,11 @@ use dioxus_core::{ VirtualDom, }; use dioxus_core_macro::rsx; -use freya_common::EventMessage; use freya_components::NativeContainer; -use freya_core::prelude::*; +use freya_core::prelude::{ + EventMessage, + *, +}; use freya_engine::prelude::*; use tokio::sync::{ broadcast, diff --git a/crates/testing/src/test_handler.rs b/crates/testing/src/test_handler.rs index 4cbb8d66a..1b9e1757d 100644 --- a/crates/testing/src/test_handler.rs +++ b/crates/testing/src/test_handler.rs @@ -7,11 +7,11 @@ use std::{ }; use dioxus_core::VirtualDom; -use freya_common::{ +use freya_core::prelude::{ EventMessage, TextGroupMeasurement, + *, }; -use freya_core::prelude::*; use freya_engine::prelude::{ raster_n32_premul, Color, diff --git a/examples/gamepad_focus.rs b/examples/gamepad_focus.rs new file mode 100644 index 000000000..eb436e691 --- /dev/null +++ b/examples/gamepad_focus.rs @@ -0,0 +1,115 @@ +#![cfg_attr( + all(not(debug_assertions), target_os = "windows"), + windows_subsystem = "windows" +)] + +use std::thread; + +use freya::prelude::*; +use freya_core::prelude::{ + EventMessage, + EventName, + FreyaPlugin, + PlatformEvent, + PluginEvent, + PluginHandle, +}; +use gilrs::{ + EventType, + Gilrs, +}; + +fn main() { + launch_cfg( + app, + LaunchConfig::<()>::new().with_plugin(GamePadPlugin::default()), + ) +} + +#[derive(Default)] +pub struct GamePadPlugin; + +impl GamePadPlugin { + pub fn listen_gamepad(handle: PluginHandle) { + thread::spawn(move || { + println!("Listening for gamepads"); + + let mut gilrs_instance = Gilrs::new().unwrap(); + + loop { + while let Some(ev) = gilrs_instance.next_event() { + match ev.event { + EventType::ButtonReleased(_, code) => { + // NOTE: You might need to tweak these codes + match code.into_u32() { + 4 => { + handle.send_event_loop_event( + EventMessage::FocusPrevAccessibilityNode, + ); + } + 6 => { + handle.send_event_loop_event( + EventMessage::FocusNextAccessibilityNode, + ); + } + 13 => { + handle.send_platform_event(PlatformEvent::Keyboard { + name: EventName::KeyDown, + key: Key::Enter, + code: Code::Enter, + modifiers: Modifiers::default(), + }); + } + _ => {} + } + } + _ => {} + } + } + } + }); + } +} + +impl FreyaPlugin for GamePadPlugin { + fn on_event(&mut self, event: &PluginEvent, handle: PluginHandle) { + match event { + PluginEvent::WindowCreated(_) => { + Self::listen_gamepad(handle); + } + _ => {} + } + } +} + +fn app() -> Element { + let mut count = use_signal(|| 0); + let mut enabled = use_signal(|| true); + + rsx!( + rect { + height: "fill", + width: "fill", + main_align: "center", + cross_align: "center", + Button { + onpress: move |_| count += 1, + label { + "Increase -> {count}" + } + } + Switch { + enabled: *enabled.read(), + ontoggled: move |_| { + enabled.toggle(); + } + } + Button { + onpress: move |_| count -= 1, + label { + "Decrease -> {count}" + } + } + } + ) +} diff --git a/examples/gamepad_trace.rs b/examples/gamepad_trace.rs new file mode 100644 index 000000000..af4e4eb10 --- /dev/null +++ b/examples/gamepad_trace.rs @@ -0,0 +1,177 @@ +#![cfg_attr( + all(not(debug_assertions), target_os = "windows"), + windows_subsystem = "windows" +)] + +use std::{ + thread::{ + self, + sleep, + }, + time::{ + Duration, + UNIX_EPOCH, + }, +}; + +use freya::prelude::*; +use freya_core::prelude::{ + EventName, + FreyaPlugin, + PlatformEvent, + PluginEvent, + PluginHandle, +}; +use gilrs::{ + Axis, + EventType, + Gilrs, +}; + +fn main() { + launch_cfg( + app, + LaunchConfig::<()>::new().with_plugin(GamePadPlugin::default()), + ) +} + +#[derive(Default)] +pub struct GamePadPlugin; + +impl GamePadPlugin { + pub fn listen_gamepad(handle: PluginHandle) { + thread::spawn(move || { + println!("Listening for gamepads"); + + let mut gilrs = Gilrs::new().unwrap(); + + loop { + let (mut x, mut y) = (200.0f64, 200.0f64); + let (mut diff_x, mut diff_y) = (0., 0.); + + let mut event = gilrs.next_event(); + while let Some(ev) = event { + loop { + sleep(Duration::from_millis(16)); + match ev.event { + EventType::AxisChanged(Axis::LeftStickX, diff, _) => { + diff_x = diff as f64; + } + EventType::AxisChanged(Axis::LeftStickY, diff, _) => { + diff_y = diff as f64; + } + _ => {} + } + + if diff_x != 0.0 { + x += diff_x as f64 * 10.; + handle.send_platform_event(PlatformEvent::Mouse { + name: EventName::MouseOver, + cursor: (x, y).into(), + button: None, + }); + } + + if diff_x != 0.0 { + y -= diff_y as f64 * 10.; + handle.send_platform_event(PlatformEvent::Mouse { + name: EventName::MouseOver, + cursor: (x, y).into(), + button: None, + }); + } + + let new_event = gilrs.next_event(); + + if let Some(new_ev) = new_event { + if new_ev != ev { + event = new_event; + break; + } + } + } + } + } + }); + } +} + +impl FreyaPlugin for GamePadPlugin { + fn on_event(&mut self, event: &PluginEvent, handle: PluginHandle) { + match event { + PluginEvent::WindowCreated(_) => { + Self::listen_gamepad(handle); + } + _ => {} + } + } +} + +const MOVEMENT_MARGIN: f64 = 75.0; +const BOX_COUNT: usize = 80; + +#[allow(non_snake_case)] +fn Box() -> Element { + rsx!( + rect { + background: "rgb(65, 53, 67)", + width: "250", + height: "250", + main_align: "center", + cross_align: "center", + corner_radius: "100", + rect { + background: "rgb(143, 67, 238)", + width: "180", + height: "180", + main_align: "center", + cross_align: "center", + corner_radius: "100", + rect { + background: "rgb(240, 235, 141)", + width: "100", + height: "100", + corner_radius: "100", + } + } + } + ) +} + +fn app() -> Element { + let mut positions = use_signal::>(Vec::new); + + let onmouseover = move |e: MouseEvent| { + let coordinates = e.get_screen_coordinates(); + positions.with_mut(|positions| { + if let Some(pos) = positions.first() { + if (pos.x + MOVEMENT_MARGIN < coordinates.x + && pos.x - MOVEMENT_MARGIN > coordinates.x) + && (pos.y + MOVEMENT_MARGIN < coordinates.y + && pos.y - MOVEMENT_MARGIN > coordinates.y) + { + return; + } + } + positions.insert(0, (coordinates.x - 125.0, coordinates.y - 125.0).into()); + positions.truncate(BOX_COUNT); + }) + }; + + rsx!( + rect { + onmouseover, + width: "100%", + height: "100%", + {positions.read().iter().map(|pos| rsx!( + rect { + width: "0", + height: "0", + offset_x: "{pos.x}", + offset_y: "{pos.y}", + Box {} + } + ))} + } + ) +} diff --git a/examples/plugin.rs b/examples/plugin.rs index c2849d380..3be516e87 100644 --- a/examples/plugin.rs +++ b/examples/plugin.rs @@ -4,15 +4,18 @@ )] use freya::prelude::*; -use freya_core::plugins::{ - FreyaPlugin, - PluginEvent, +use freya_core::{ + plugins::{ + FreyaPlugin, + PluginEvent, + }, + prelude::PluginHandle, }; struct DummyPlugin; impl FreyaPlugin for DummyPlugin { - fn on_event(&mut self, event: &PluginEvent) { + fn on_event(&mut self, event: &PluginEvent, handle: PluginHandle) { if let PluginEvent::AfterRender { .. } = event { println!("The app just got rendered to the canvas."); } diff --git a/examples/render_canvas.rs b/examples/render_canvas.rs index 18e1da6a4..f8264c98e 100644 --- a/examples/render_canvas.rs +++ b/examples/render_canvas.rs @@ -4,7 +4,7 @@ )] use freya::{ - common::EventMessage, + core::prelude::EventMessage, prelude::*, }; use skia_safe::{