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 
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(CYIEventTarget *pTarget);
241 
248  CYIEventTarget *GetTarget() const;
249 
256  const std::shared_ptr<CYIEventTargetProxy> &GetTargetProxy() const;
257 
263  void SetCurrentTarget(CYIEventTarget *pTarget);
264 
271  const CYIEventTarget *GetCurrentTarget() const;
272 
274 
281  const std::shared_ptr<CYIEventTargetProxy> &GetCurrentTargetProxy() const;
282 
283  uint64_t m_eventTimeMs;
285  bool m_canCancel;
286  bool m_canBubble;
289  bool m_handled;
291 private:
292  CYIEvent::Type m_Type;
293  std::shared_ptr<CYIEventTargetProxy> m_pTargetProxy;
294  std::shared_ptr<CYIEventTargetProxy> m_pCurrentTargetProxy;
295 };
299 {
300  return m_Type;
301 }
302 
303 inline bool CYIEvent::IsActionEvent() const
304 {
306 }
307 
308 inline bool CYIEvent::IsKeyEvent() const
309 {
310  return m_Type == CYIEvent::Type::KeyDown || m_Type == CYIEvent::Type::KeyUp || m_Type == CYIEvent::Type::KeyInput;
311 }
312 
313 inline bool CYIEvent::IsFocusEvent() const
314 {
315  return m_Type == CYIEvent::Type::FocusIn || m_Type == CYIEvent::Type::FocusOut;
316 }
317 
318 inline bool CYIEvent::IsTrackpadEvent() const
319 {
321 }
322 
324 {
326 }
327 
328 inline bool CYIEvent::IsGestureEvent() const
329 {
331 }
332 
333 inline bool CYIEvent::IsSwipeGestureEvent() const
334 {
335  return m_Type == CYIEvent::Type::GestureSwipe;
336 }
337 
338 inline bool CYIEvent::IsScrubGestureEvent() const
339 {
340  return m_Type == CYIEvent::Type::GestureScrub;
341 }
342 
343 #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:284
Accessibility related events.
Definition: YiAccessibilityEvent.h:26
bool IsGestureEvent() const
Definition: YiEvent.h:328
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:323
void SetTarget(CYIEventTarget *pTarget)
std::unique_ptr< CYIAccessibilityEvent > CloneAsAccessibilityEvent() const
CYIEvent::Type GetType() const
Definition: YiEvent.h:298
virtual ~CYIEvent()
std::unique_ptr< CYIGestureEvent > CloneAsGestureEvent() const
uint64_t m_eventTimeMs
Definition: YiEvent.h:283
std::unique_ptr< CYISwipeGestureEvent > CloneAsSwipeGestureEvent() const
CYIEvent(CYIEvent::Type eventType)
void SetType(CYIEvent::Type eventType)
bool m_canCancel
Definition: YiEvent.h:285
Represents an event target of type CYIEventTarget::SpecialEventTargetType.
Definition: YiEventTarget.h:25
bool IsScrubGestureEvent() const
Definition: YiEvent.h:338
bool IsKeyEvent() const
Definition: YiEvent.h:308
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:333
void SetCurrentTarget(CYIEventTarget *pTarget)
bool IsFocusEvent() const
Definition: YiEvent.h:313
std::unique_ptr< CYIActionEvent > CloneAsActionEvent() const
const CYIEventTarget * GetCurrentTarget() const
bool m_canBubble
Definition: YiEvent.h:286
Swipe gesture event.
Definition: YiSwipeGestureEvent.h:18
const CYIString & GetName() const
virtual std::unique_ptr< CYIEvent > Clone() const
bool m_canCapture
Definition: YiEvent.h:287
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:303
const std::shared_ptr< CYIEventTargetProxy > & GetCurrentTargetProxy() const
CYIEventTarget * GetTarget() const
bool m_stopPropagation
Definition: YiEvent.h:288
Priority
Priority of the event in the event queue.
Definition: YiEvent.h:99
bool IsTrackpadEvent() const
Definition: YiEvent.h:318
A class used to proxy access to a CYIEventTarget.
Definition: YiEventTargetProxy.h:19
bool m_handled
Definition: YiEvent.h:289
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