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