freya_core/events/
platform_event.rs

1use std::path::PathBuf;
2
3use freya_elements::events::keyboard::{
4    Code,
5    Key,
6    Modifiers,
7};
8use freya_native_core::events::EventName;
9use torin::prelude::*;
10use winit::event::{
11    Force,
12    MouseButton,
13    TouchPhase,
14};
15
16/// Events emitted by a Freya platform, such as desktop or freya-testing.
17#[derive(Clone, Debug)]
18pub struct PlatformEvent {
19    pub name: EventName,
20    pub data: PlatformEventData,
21}
22
23/// Data for [PlatformEvent].
24#[derive(Clone, Debug)]
25pub enum PlatformEventData {
26    /// A Mouse Event.
27    Mouse {
28        cursor: CursorPoint,
29        button: Option<MouseButton>,
30    },
31    /// A Wheel event.
32    Wheel {
33        scroll: CursorPoint,
34        cursor: CursorPoint,
35    },
36    /// A Keyboard event.
37    Keyboard {
38        key: Key,
39        code: Code,
40        modifiers: Modifiers,
41    },
42    /// A Touch event.
43    Touch {
44        location: CursorPoint,
45        finger_id: u64,
46        phase: TouchPhase,
47        force: Option<Force>,
48    },
49    /// A File event.
50    File {
51        cursor: CursorPoint,
52        file_path: Option<PathBuf>,
53    },
54}