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
//local shortcuts
use crate::*;

//third-party shortcuts
use bevy::ecs::system::SystemParamItem;
use bevy::ecs::system::lifetimeless::SRes;
use bevy::prelude::*;

//standard shortcuts
use std::marker::PhantomData;

//-------------------------------------------------------------------------------------------------------------------

#[derive(Resource, Debug, Default)]
pub struct MouseLButton<U: LunexUi, C: LunexCursor>
{
    _phantom: PhantomData<(U, C)>,
}

impl<U: LunexUi, C: LunexCursor> InteractionSource for MouseLButton<U, C>
{
    type SourceParam = SRes<Input<MouseButton>>;
    type LunexUi     = U;
    type LunexCursor = C;

    fn just_clicked(&self, source: &SystemParamItem<SRes<Input<MouseButton>>>) -> bool
    {
        source.just_pressed(MouseButton::Left)
    }
    fn is_clicked(&self, source: &SystemParamItem<SRes<Input<MouseButton>>>) -> bool
    {
        source.pressed(MouseButton::Left)
    }
    fn just_unclicked(&self, source: &SystemParamItem<SRes<Input<MouseButton>>>) -> bool
    {
        source.just_released(MouseButton::Left)
    }
}

//-------------------------------------------------------------------------------------------------------------------

#[derive(Resource, Debug, Default)]
pub struct MouseRButton<U: LunexUi, C: LunexCursor>
{
    _phantom: PhantomData<(U, C)>,
}

impl<U: LunexUi, C: LunexCursor> InteractionSource for MouseRButton<U, C>
{
    type SourceParam = SRes<Input<MouseButton>>;
    type LunexUi     = U;
    type LunexCursor = C;

    fn just_clicked(&self, source: &SystemParamItem<SRes<Input<MouseButton>>>) -> bool
    {
        source.just_pressed(MouseButton::Right)
    }
    fn is_clicked(&self, source: &SystemParamItem<SRes<Input<MouseButton>>>) -> bool
    {
        source.pressed(MouseButton::Right)
    }
    fn just_unclicked(&self, source: &SystemParamItem<SRes<Input<MouseButton>>>) -> bool
    {
        source.just_released(MouseButton::Right)
    }
}

//-------------------------------------------------------------------------------------------------------------------