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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//! Virtual Events
//! This module provides a wrapping of platform-specific events with a list of events easier to work with.
//!
//! 3rd party renderers are responsible for forming this virtual events from events
//!
//! The goal here is to provide a consistent event interface across all renderer types
use generational_arena::Index;

use crate::innerlude::CbIdx;

#[derive(Debug)]
pub struct EventTrigger {
    pub component_id: Index,
    pub listener_id: usize,
    pub event: VirtualEvent,
}

impl EventTrigger {
    pub fn new(event: VirtualEvent, cb: CbIdx) -> Self {
        let CbIdx {
            gi_id,
            gi_gen,
            listener_idx,
        } = cb;

        let component_id = Index::from_raw_parts(gi_id, gi_gen);
        Self {
            component_id,
            listener_id: listener_idx,
            event,
        }
    }
}

#[derive(Debug)]
pub enum VirtualEvent {
    // Real events
    ClipboardEvent(ClipboardEvent),
    CompositionEvent(CompositionEvent),
    KeyboardEvent(KeyboardEvent),
    FocusEvent(FocusEvent),
    FormEvent(FormEvent),
    GenericEvent(GenericEvent),
    MouseEvent(MouseEvent),
    PointerEvent(PointerEvent),
    SelectionEvent(SelectionEvent),
    TouchEvent(TouchEvent),
    UIEvent(UIEvent),
    WheelEvent(WheelEvent),
    MediaEvent(MediaEvent),
    ImageEvent(ImageEvent),
    AnimationEvent(AnimationEvent),
    TransitionEvent(TransitionEvent),

    OtherEvent,
}

// these should reference the underlying event

#[derive(Debug)]
pub struct ClipboardEvent {}
#[derive(Debug)]
pub struct CompositionEvent {}
#[derive(Debug)]
pub struct KeyboardEvent {}
#[derive(Debug)]
pub struct FocusEvent {}
#[derive(Debug)]
pub struct FormEvent {}
#[derive(Debug)]
pub struct GenericEvent {}
#[derive(Debug)]
pub struct MouseEvent {}
#[derive(Debug)]
pub struct PointerEvent {}
#[derive(Debug)]
pub struct SelectionEvent {}
#[derive(Debug)]
pub struct TouchEvent {}
#[derive(Debug)]
pub struct UIEvent {}
#[derive(Debug)]
pub struct WheelEvent {}
#[derive(Debug)]
pub struct MediaEvent {}
#[derive(Debug)]
pub struct ImageEvent {}
#[derive(Debug)]
pub struct AnimationEvent {}
#[derive(Debug)]
pub struct TransitionEvent {}