1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use std::path::PathBuf;

use freya_elements::events::keyboard::{
    Code,
    Key,
    Modifiers,
};
use torin::prelude::*;
use winit::event::{
    Force,
    MouseButton,
    TouchPhase,
};

use crate::prelude::EventName;

/// Events emitted by a Freya platform, such as desktop or freya-testing.
#[derive(Clone, Debug)]
pub struct PlatformEvent {
    pub name: EventName,
    pub data: PlatformEventData,
}

/// Data for [PlatformEvent].
#[derive(Clone, Debug)]
pub enum PlatformEventData {
    /// A Mouse Event.
    Mouse {
        cursor: CursorPoint,
        button: Option<MouseButton>,
    },
    /// A Wheel event.
    Wheel {
        scroll: CursorPoint,
        cursor: CursorPoint,
    },
    /// A Keyboard event.
    Keyboard {
        key: Key,
        code: Code,
        modifiers: Modifiers,
    },
    /// A Touch event.
    Touch {
        location: CursorPoint,
        finger_id: u64,
        phase: TouchPhase,
        force: Option<Force>,
    },
    /// A File event.
    File {
        cursor: CursorPoint,
        file_path: Option<PathBuf>,
    },
}