c7b7684c04267a0dc8ef0b4be1ee7dfd517ba0e5
[platform/core/uifw/dali-adaptor.git] / adaptors / common / events / event-handler.h
1 #ifndef __DALI_INTERNAL_EVENT_HANDLER_H__
2 #define __DALI_INTERNAL_EVENT_HANDLER_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/integration-api/events/point.h>
23 #include <dali/integration-api/events/touch-event-combiner.h>
24 #include <style-monitor.h>
25
26 // INTERNAL INCLUDES
27 #include <damage-observer.h>
28 #include <drag-and-drop-detector-impl.h>
29 #include <accessibility-adaptor-impl.h>
30 #include <clipboard-event-notifier-impl.h>
31 #include <imf-manager-impl.h>
32 #include <rotation-observer.h>
33
34 namespace Dali
35 {
36
37 class RenderSurface;
38
39 namespace Internal
40 {
41
42 namespace Adaptor
43 {
44
45 class CoreEventInterface;
46 class GestureManager;
47 class StyleMonitor;
48
49 /**
50  * The Event Handler class is responsible for setting up receiving of Ecore events and then converts them
51  * to TouchEvents when it does receive them.
52  *
53  * These TouchEvents are then passed on to Core.
54  */
55 class EventHandler
56 {
57 public:
58
59   /**
60    * Constructor.
61    * @param[in]  surface                  The surface where events will be sent to.
62    * @param[in]  coreEventInterface       Used to send events to Core.
63    * @param[in]  gestureManager           The Gesture Manager.
64    * @param[in]  damageObserver           The damage observer (to pass damage events to).
65    * @param[in]  dndDetector              The Drag & Drop listener (to pass DnD events to).
66    */
67   EventHandler( RenderSurface* surface, CoreEventInterface& coreEventInterface, GestureManager& gestureManager, DamageObserver& damageObserver, DragAndDropDetectorPtr dndDetector );
68
69   /**
70    * Destructor.
71    */
72   ~EventHandler();
73
74   /**
75    * Feed (Send) touch event to core and gesture manager
76    * @param[in] touchEvent  The touch event holding the touch point information.
77    */
78   void FeedTouchPoint( TouchPoint& point, int timeStamp );
79
80   /**
81    * Feed (Send) wheel event to core and gesture manager
82    * @param[in]  wheelEvent The wheel event
83    */
84   void FeedWheelEvent( WheelEvent& wheelEvent );
85
86   /**
87    * Feed (Send) key event to core
88    * @param[in] keyEvent The key event holding the key information.
89    */
90   void FeedKeyEvent( KeyEvent& keyEvent );
91
92   /**
93    * Feed (Send) an event to core
94    * @param[in] event  The event information.
95    */
96   void FeedEvent( Integration::Event& event );
97
98   /**
99    * Called when the adaptor is paused.
100    */
101   void Pause();
102
103   /**
104    * Called when the adaptor is resumed (from pause).
105    */
106   void Resume();
107
108   /**
109    * Sets the Drag & Drop detector.
110    * @param[in]  detector  An intrusive pointer to the Drag & Drop listener to set. To unset pass in NULL.
111    */
112   void SetDragAndDropDetector( DragAndDropDetectorPtr detector );
113
114   /**
115    * Set the rotation observer (note, some adaptors may not have a rotation observer)
116    * @param[in] observer The rotation observer
117    */
118   void SetRotationObserver( RotationObserver* observer );
119
120 private:
121
122   /**
123    * Send touch event to core.
124    * @param[in]  point      The touch point information.
125    * @param[in]  timeStamp  The time the touch occurred.
126    */
127   void SendEvent(Integration::Point& point, unsigned long timeStamp);
128
129   /**
130    * Send key event to core.
131    * @param[in]  keyEvent The KeyEvent to send.
132    */
133   void SendEvent(KeyEvent& keyEvent);
134
135   /**
136    * Send wheel event to core.
137    * @param[in]  wheelEvent The wheel event
138    */
139   void SendWheelEvent( WheelEvent& wheelEvent );
140
141   /**
142    * Send a style change event to the style monitor.
143    * @param[in]  styleChange  The style that has changed.
144    */
145   void SendEvent( StyleChange::Type styleChange );
146
147   /**
148    * Send a window damage event to the observer.
149    * @param[in]  area  Damaged area.
150    */
151   void SendEvent( const DamageArea& area );
152
153   /**
154    * Inform rotation observer of rotation prepare event
155    * @param[in] rotation The rotation event
156    */
157   void SendRotationPrepareEvent( const RotationEvent& rotation );
158
159   /**
160    * Inform rotation observer of rotation prepare event
161    */
162   void SendRotationRequestEvent();
163
164   /**
165    * Resets the event handler.
166    * Called when the adaptor is paused or resumed.
167    */
168   void Reset();
169
170 private:
171
172   // Undefined
173   EventHandler( const EventHandler& eventHandler );
174
175   // Undefined
176   EventHandler& operator=( const EventHandler& eventHandler );
177
178 private:
179
180   CoreEventInterface& mCoreEventInterface; ///< Used to send events to Core.
181   Dali::Integration::TouchEventCombiner mCombiner; ///< Combines multi-touch events.
182   GestureManager& mGestureManager; ///< Reference to the GestureManager, set on construction, to send touch events to for analysis.
183   Dali::StyleMonitor mStyleMonitor; ///< Handle to the style monitor, set on construction, to send font size and font change events to.
184   DamageObserver& mDamageObserver; ///< Reference to the DamageObserver, set on construction, to sent damage events to.
185   RotationObserver* mRotationObserver; ///< Pointer to rotation observer, if present.
186
187   DragAndDropDetectorPtr mDragAndDropDetector; ///< Pointer to the drag & drop detector, to send Drag & Drop events to.
188   Dali::AccessibilityAdaptor mAccessibilityAdaptor; ///< Pointer to the accessibility adaptor
189   Dali::ClipboardEventNotifier mClipboardEventNotifier; ///< Pointer to the clipboard event notifier
190   Dali::Clipboard mClipboard;///< Pointer to the clipboard
191
192   struct Impl; ///< Implementation
193   Impl* mImpl; ///< Created on construction and destroyed on destruction.
194
195   bool mPaused; ///< The paused state of the adaptor.
196 };
197
198 } // namespace Adaptor
199
200 } // namespace Internal
201
202 } // namespace Dali
203
204 #endif // __DALI_INTERNAL_EVENT_HANDLER_H__