Merge "Fix VD prevent issues" into devel/master
[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/touch-event-combiner.h>
23 #include <style-monitor.h>
24
25 // INTERNAL INCLUDES
26 #include <damage-observer.h>
27 #include <drag-and-drop-detector-impl.h>
28 #include <accessibility-adaptor-impl.h>
29 #include <clipboard-event-notifier-impl.h>
30 #include <imf-manager-impl.h>
31 #include <rotation-observer.h>
32
33 namespace Dali
34 {
35
36 class RenderSurface;
37
38 namespace Internal
39 {
40
41 namespace Adaptor
42 {
43
44 class CoreEventInterface;
45 class GestureManager;
46 class StyleMonitor;
47
48 /**
49  * The Event Handler class is responsible for setting up receiving of Ecore events and then converts them
50  * to TouchEvents when it does receive them.
51  *
52  * These TouchEvents are then passed on to Core.
53  */
54 class EventHandler
55 {
56 public:
57
58   /**
59    * Constructor.
60    * @param[in]  surface                  The surface where events will be sent to.
61    * @param[in]  coreEventInterface       Used to send events to Core.
62    * @param[in]  gestureManager           The Gesture Manager.
63    * @param[in]  damageObserver           The damage observer (to pass damage events to).
64    * @param[in]  dndDetector              The Drag & Drop listener (to pass DnD events to).
65    */
66   EventHandler( RenderSurface* surface, CoreEventInterface& coreEventInterface, GestureManager& gestureManager, DamageObserver& damageObserver, DragAndDropDetectorPtr dndDetector );
67
68   /**
69    * Destructor.
70    */
71   ~EventHandler();
72
73   /**
74    * Feed (Send) touch event to core and gesture manager
75    * @param[in] touchEvent  The touch event holding the touch point information.
76    */
77   void FeedTouchPoint( TouchPoint& point, int timeStamp );
78
79   /**
80    * Feed (Send) wheel event to core and gesture manager
81    * @param[in]  wheelEvent The wheel event
82    */
83   void FeedWheelEvent( WheelEvent& wheelEvent );
84
85   /**
86    * Feed (Send) key event to core
87    * @param[in] keyEvent The key event holding the key information.
88    */
89   void FeedKeyEvent( KeyEvent& keyEvent );
90
91   /**
92    * Feed (Send) an event to core
93    * @param[in] event  The event information.
94    */
95   void FeedEvent( Integration::Event& event );
96
97   /**
98    * Called when the adaptor is paused.
99    */
100   void Pause();
101
102   /**
103    * Called when the adaptor is resumed (from pause).
104    */
105   void Resume();
106
107   /**
108    * Sets the Drag & Drop detector.
109    * @param[in]  detector  An intrusive pointer to the Drag & Drop listener to set. To unset pass in NULL.
110    */
111   void SetDragAndDropDetector( DragAndDropDetectorPtr detector );
112
113   /**
114    * Set the rotation observer (note, some adaptors may not have a rotation observer)
115    * @param[in] observer The rotation observer
116    */
117   void SetRotationObserver( RotationObserver* observer );
118
119 private:
120
121   /**
122    * Send touch event to core.
123    * @param[in]  point      The touch point information.
124    * @param[in]  timeStamp  The time the touch occurred.
125    */
126   void SendEvent(TouchPoint& point, unsigned long timeStamp);
127
128   /**
129    * Send key event to core.
130    * @param[in]  keyEvent The KeyEvent to send.
131    */
132   void SendEvent(KeyEvent& keyEvent);
133
134   /**
135    * Send wheel event to core.
136    * @param[in]  wheelEvent The wheel event
137    */
138   void SendWheelEvent( WheelEvent& wheelEvent );
139
140   /**
141    * Send a style change event to the style monitor.
142    * @param[in]  styleChange  The style that has changed.
143    */
144   void SendEvent( StyleChange::Type styleChange );
145
146   /**
147    * Send a window damage event to the observer.
148    * @param[in]  area  Damaged area.
149    */
150   void SendEvent( const DamageArea& area );
151
152   /**
153    * Inform rotation observer of rotation prepare event
154    * @param[in] rotation The rotation event
155    */
156   void SendRotationPrepareEvent( const RotationEvent& rotation );
157
158   /**
159    * Inform rotation observer of rotation prepare event
160    */
161   void SendRotationRequestEvent();
162
163   /**
164    * Resets the event handler.
165    * Called when the adaptor is paused or resumed.
166    */
167   void Reset();
168
169 private:
170
171   // Undefined
172   EventHandler( const EventHandler& eventHandler );
173
174   // Undefined
175   EventHandler& operator=( const EventHandler& eventHandler );
176
177 private:
178
179   CoreEventInterface& mCoreEventInterface; ///< Used to send events to Core.
180   Dali::Integration::TouchEventCombiner mCombiner; ///< Combines multi-touch events.
181   GestureManager& mGestureManager; ///< Reference to the GestureManager, set on construction, to send touch events to for analysis.
182   Dali::StyleMonitor mStyleMonitor; ///< Handle to the style monitor, set on construction, to send font size and font change events to.
183   DamageObserver& mDamageObserver; ///< Reference to the DamageObserver, set on construction, to sent damage events to.
184   RotationObserver* mRotationObserver; ///< Pointer to rotation observer, if present.
185
186   DragAndDropDetectorPtr mDragAndDropDetector; ///< Pointer to the drag & drop detector, to send Drag & Drop events to.
187   Dali::AccessibilityAdaptor mAccessibilityAdaptor; ///< Pointer to the accessibility adaptor
188   Dali::ClipboardEventNotifier mClipboardEventNotifier; ///< Pointer to the clipboard event notifier
189   Dali::Clipboard mClipboard;///< Pointer to the clipboard
190
191   struct Impl; ///< Contains Ecore specific information
192   Impl* mImpl; ///< Created on construction and destroyed on destruction.
193
194   bool mPaused; ///< The paused state of the adaptor.
195 };
196
197 } // namespace Adaptor
198
199 } // namespace Internal
200
201 } // namespace Dali
202
203 #endif // __DALI_INTERNAL_EVENT_HANDLER_H__