You.i Engine
YiEvent.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2020. All rights reserved.
2 #ifndef _YI_EVENT_H_
3 #define _YI_EVENT_H_
4 
5 #include "utility/YiString.h"
6 
8 class CYIActionEvent;
9 class CYIEventTarget;
10 class CYIFocusEvent;
11 class CYIGestureEvent;
12 class CYIKeyEvent;
14 class CYITrackpadEvent;
16 
21 
27 class CYIEvent
28 {
29 public:
33  enum class Type : uint8_t
34  {
35  None = 0,
36  ActionMove,
37  ActionDown,
39  ActionUp,
44  ActionOut,
45  ActionIn,
48  ActionPick,
51  KeyDown,
52  KeyUp,
53  KeyInput,
54  SignalEmit,
55  StateMachineWrapped, // Unused
56  StateMachineSignal, // Unused
62  FocusIn,
63  FocusOut,
66  TrackpadUp,
68  Task,
74  GestureTap,
79 
80  // Leave this marker as last event.
82  };
83 
87  enum class Phase : uint8_t
88  {
89  None = 0,
90  Capture,
91  AtTarget,
92  Bubble,
93  Broadcast
94  };
95 
99  enum class Priority
100  {
101  Highest = 2,
102  High = 1,
103  Normal = 0,
104  Low = -1,
105  Lowest = -2,
106 
107  Default = Normal
108  };
109 
110  CYIEvent(CYIEvent::Type eventType);
111  CYIEvent(const CYIEvent &rOther);
112  virtual ~CYIEvent();
113  virtual std::unique_ptr<CYIEvent> Clone() const;
114 
118  const CYIString &GetName() const;
119 
123  CYIEvent::Type GetType() const;
124 
128  void SetType(CYIEvent::Type eventType);
129 
135  bool IsActionEvent() const;
136 
142  std::unique_ptr<CYIActionEvent> CloneAsActionEvent() const;
143 
149  bool IsKeyEvent() const;
150 
156  std::unique_ptr<CYIKeyEvent> CloneAsKeyEvent() const;
157 
163  bool IsFocusEvent() const;
164 
170  std::unique_ptr<CYIFocusEvent> CloneAsFocusEvent() const;
171 
177  bool IsTrackpadEvent() const;
178 
184  std::unique_ptr<CYITrackpadEvent> CloneAsTrackpadEvent() const;
185 
191  bool IsAccessibilityEvent() const;
192 
198  std::unique_ptr<CYIAccessibilityEvent> CloneAsAccessibilityEvent() const;
199 
205  bool IsGestureEvent() const;
206 
212  std::unique_ptr<CYIGestureEvent> CloneAsGestureEvent() const;
213 
219  bool IsSwipeGestureEvent() const;
220 
226  bool IsScrubGestureEvent() const;
227 
233  std::unique_ptr<CYISwipeGestureEvent> CloneAsSwipeGestureEvent() const;
234 
240  void SetTarget(const CYIEventTarget *pTarget);
241 
248  const std::shared_ptr<CYIEventTargetProxy> &GetTargetProxy() const;
249 
252  uint64_t m_eventTimeMs;
254  bool m_canCancel;
255  bool m_canBubble;
258  bool m_handled;
260 private:
261  CYIEvent::Type m_Type;
262  std::shared_ptr<CYIEventTargetProxy> m_pTargetProxy;
263 };
267 {
268  return m_Type;
269 }
270 
271 inline bool CYIEvent::IsActionEvent() const
272 {
274 }
275 
276 inline bool CYIEvent::IsKeyEvent() const
277 {
278  return m_Type == CYIEvent::Type::KeyDown || m_Type == CYIEvent::Type::KeyUp || m_Type == CYIEvent::Type::KeyInput;
279 }
280 
281 inline bool CYIEvent::IsFocusEvent() const
282 {
283  return m_Type == CYIEvent::Type::FocusIn || m_Type == CYIEvent::Type::FocusOut;
284 }
285 
286 inline bool CYIEvent::IsTrackpadEvent() const
287 {
289 }
290 
292 {
294 }
295 
296 inline bool CYIEvent::IsGestureEvent() const
297 {
299 }
300 
301 inline bool CYIEvent::IsSwipeGestureEvent() const
302 {
303  return m_Type == CYIEvent::Type::GestureSwipe;
304 }
305 
306 inline bool CYIEvent::IsScrubGestureEvent() const
307 {
308  return m_Type == CYIEvent::Type::GestureScrub;
309 }
310 
311 #endif // _YI_EVENT_H_
Stores data related to trackpad input.
Definition: YiTrackpadEvent.h:22
Class for key events.
Definition: YiKeyEvent.h:15
Phase m_phase
Definition: YiEvent.h:253
Accessibility related events.
Definition: YiAccessibilityEvent.h:26
bool IsGestureEvent() const
Definition: YiEvent.h:296
std::unique_ptr< CYIKeyEvent > CloneAsKeyEvent() const
Base class for events.
Definition: YiEvent.h:27
Container class for Unicode strings. Conceptually, a CYIString object is a sequence of Unicode charac...
Definition: YiString.h:36
bool IsAccessibilityEvent() const
Definition: YiEvent.h:291
std::unique_ptr< CYIAccessibilityEvent > CloneAsAccessibilityEvent() const
CYIEventTarget * m_pTarget
Definition: YiEvent.h:250
CYIEvent::Type GetType() const
Definition: YiEvent.h:266
virtual ~CYIEvent()
std::unique_ptr< CYIGestureEvent > CloneAsGestureEvent() const
uint64_t m_eventTimeMs
Definition: YiEvent.h:252
std::unique_ptr< CYISwipeGestureEvent > CloneAsSwipeGestureEvent() const
CYIEvent(CYIEvent::Type eventType)
void SetType(CYIEvent::Type eventType)
bool m_canCancel
Definition: YiEvent.h:254
Represents an event target of type CYIEventTarget::SpecialEventTargetType.
Definition: YiEventTarget.h:25
bool IsScrubGestureEvent() const
Definition: YiEvent.h:306
void SetTarget(const CYIEventTarget *pTarget)
bool IsKeyEvent() const
Definition: YiEvent.h:276
Focus events represent when a view receives or loses focus.
Definition: YiFocusEvent.h:27
std::unique_ptr< CYIFocusEvent > CloneAsFocusEvent() const
bool IsSwipeGestureEvent() const
Definition: YiEvent.h:301
bool IsFocusEvent() const
Definition: YiEvent.h:281
std::unique_ptr< CYIActionEvent > CloneAsActionEvent() const
bool m_canBubble
Definition: YiEvent.h:255
Swipe gesture event.
Definition: YiSwipeGestureEvent.h:18
const CYIString & GetName() const
virtual std::unique_ptr< CYIEvent > Clone() const
bool m_canCapture
Definition: YiEvent.h:256
Phase
The current processing phase of the event.
Definition: YiEvent.h:87
Gesture related events.
Definition: YiGestureEvent.h:28
bool IsActionEvent() const
Definition: YiEvent.h:271
CYIEventTarget * m_pCurrentTarget
Definition: YiEvent.h:251
bool m_stopPropagation
Definition: YiEvent.h:257
Priority
Priority of the event in the event queue.
Definition: YiEvent.h:99
bool IsTrackpadEvent() const
Definition: YiEvent.h:286
A class used to proxy access to a CYIEventTarget.
Definition: YiEventTargetProxy.h:19
bool m_handled
Definition: YiEvent.h:258
std::unique_ptr< CYITrackpadEvent > CloneAsTrackpadEvent() const
const std::shared_ptr< CYIEventTargetProxy > & GetTargetProxy() const
Stores data related to a user Action event.
Definition: YiActionEvent.h:18
Type
The event type of the CYIEvent class instance.
Definition: YiEvent.h:33