Kiwano Engine  v1.2.x
MouseEvent.h
1 // Copyright (c) 2016-2018 Kiwano - Nomango
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 // THE SOFTWARE.
20 
21 #pragma once
22 #include <kiwano/platform/Keys.h>
23 #include <kiwano/event/Event.h>
24 #include <kiwano/math/Math.h>
25 
26 namespace kiwano
27 {
28 KGE_DECLARE_SMART_PTR(MouseEvent);
29 KGE_DECLARE_SMART_PTR(MouseMoveEvent);
30 KGE_DECLARE_SMART_PTR(MouseDownEvent);
31 KGE_DECLARE_SMART_PTR(MouseUpEvent);
32 KGE_DECLARE_SMART_PTR(MouseClickEvent);
33 KGE_DECLARE_SMART_PTR(MouseHoverEvent);
34 KGE_DECLARE_SMART_PTR(MouseOutEvent);
35 KGE_DECLARE_SMART_PTR(MouseWheelEvent);
36 
42 class KGE_API MouseEvent : public Event
45 {
46 public:
48 
49  MouseEvent(const EventType& type);
50 };
51 
54 class KGE_API MouseMoveEvent : public MouseEvent
55 {
56 public:
58 };
59 
62 class KGE_API MouseDownEvent : public MouseEvent
63 {
64 public:
65  MouseButton button;
66 
68 };
69 
72 class KGE_API MouseUpEvent : public MouseEvent
73 {
74 public:
75  MouseButton button;
76 
77  MouseUpEvent();
78 };
79 
82 class KGE_API MouseClickEvent : public MouseEvent
83 {
84 public:
85  MouseButton button;
86 
88 };
89 
92 class KGE_API MouseHoverEvent : public MouseEvent
93 {
94 public:
96 };
97 
100 class KGE_API MouseOutEvent : public MouseEvent
101 {
102 public:
103  MouseOutEvent();
104 };
105 
108 class KGE_API MouseWheelEvent : public MouseEvent
109 {
110 public:
111  float wheel;
112 
113  MouseWheelEvent();
114 };
115 
116 template <>
118 {
119  inline bool operator()(const Event* evt) const
120  {
121  return evt->GetType() == KGE_EVENT(MouseMoveEvent) || evt->GetType() == KGE_EVENT(MouseDownEvent)
122  || evt->GetType() == KGE_EVENT(MouseUpEvent) || evt->GetType() == KGE_EVENT(MouseClickEvent)
123  || evt->GetType() == KGE_EVENT(MouseHoverEvent) || evt->GetType() == KGE_EVENT(MouseOutEvent)
124  || evt->GetType() == KGE_EVENT(MouseWheelEvent);
125  }
126 };
127 
130 } // namespace kiwano
鼠标移入事件
Definition: MouseEvent.h:92
MouseButton button
鼠标键值
Definition: MouseEvent.h:85
const EventType & GetType() const
获取类型事件
Definition: Event.h:92
鼠标滚轮事件
Definition: MouseEvent.h:108
事件特性:判断事件类型是否相同
Definition: Event.h:81
鼠标移出事件
Definition: MouseEvent.h:100
事件类型
Definition: EventType.h:35
鼠标移动事件
Definition: MouseEvent.h:54
鼠标按键按下事件
Definition: MouseEvent.h:62
鼠标事件
Definition: MouseEvent.h:44
float wheel
滚轮值
Definition: MouseEvent.h:111
MouseButton button
鼠标键值
Definition: MouseEvent.h:75
MouseButton button
鼠标键值
Definition: MouseEvent.h:65
Definition: Actor.cpp:26
Point pos
鼠标位置
Definition: MouseEvent.h:47
鼠标点击事件
Definition: MouseEvent.h:82
事件
Definition: Event.h:43
鼠标按键抬起事件
Definition: MouseEvent.h:72