1 #ifndef DALI_INTERNAL_EVENT_HANDLER_H
2 #define DALI_INTERNAL_EVENT_HANDLER_H
5 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <cstdint> // uint32_t
23 #include <dali/public-api/common/intrusive-ptr.h>
25 #include <dali/devel-api/adaptor-framework/clipboard.h>
26 #include <dali/devel-api/adaptor-framework/style-monitor.h>
29 #include <dali/internal/clipboard/common/clipboard-event-notifier-impl.h>
30 #include <dali/internal/window-system/common/damage-observer.h>
31 #include <dali/internal/window-system/common/window-base.h>
52 class WindowRenderSurface;
55 * The Event Handler class is responsible for setting up receiving of Ecore events and then converts them
56 * to TouchEvents when it does receive them.
58 * These TouchEvents are then passed on to Core.
60 class EventHandler : public ConnectionTracker, public Dali::RefObject
65 * The observer can be overridden in order to listen to the events.
72 * Deriving classes should override this to be notified when we receive a touch point event.
73 * @param[in] point The touch point
74 * @param[in] timeStamp The time stamp
76 virtual void OnTouchPoint( Dali::Integration::Point& point, int timeStamp ) = 0;
79 * Deriving classes should override this to be notified when we receive a wheel event.
80 * @param[in] wheelEvent The wheel event
82 virtual void OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent ) = 0;
85 * Deriving classes should override this to be notified when we receive a key event.
86 * @param[in] keyEvent The key event holding the key information.
88 virtual void OnKeyEvent( Dali::Integration::KeyEvent& keyEvent ) = 0;
91 * Deriving classes should override this to be notified when the window is rotated.
92 * @param[in] rotation The rotation event.
94 virtual void OnRotation( const RotationEvent& rotation ) = 0;
99 * Protected Constructor.
104 * Protected virtual destructor.
106 virtual ~Observer() {}
113 * @param[in] windowBase The window base to be handled
114 * @param[in] damageObserver The damage observer (to pass damage events to).
116 EventHandler( WindowBase* windowBase, DamageObserver& damageObserver );
121 ~EventHandler() override;
124 * Called when the adaptor is paused.
129 * Called when the adaptor is resumed (from pause).
134 * Adds an observer so that we can observe the events.
135 * @param[in] observer The observer.
137 void AddObserver( Observer& observer );
140 * Removes the observer from the EventHandler.
141 * @param[in] observer The observer to remove.
142 * @note Observers should remove themselves when they are destroyed.
144 void RemoveObserver( Observer& observer );
149 * Send a style change event to the style monitor.
150 * @param[in] styleChange The style that has changed.
152 void SendEvent( StyleChange::Type styleChange );
155 * Send a window damage event to the observer.
156 * @param[in] area Damaged area.
158 void SendEvent( const DamageArea& area );
161 * Called when a touch event is received.
163 void OnTouchEvent( Integration::Point& point, uint32_t timeStamp );
166 * Called when a mouse wheel is received.
168 void OnWheelEvent( Integration::WheelEvent& wheelEvent );
171 * Called when a key event is received.
173 void OnKeyEvent( Integration::KeyEvent& keyEvent );
176 * Called when the window focus is changed.
178 void OnFocusChanged( bool focusIn );
181 * Called when the window is rotated.
182 * @param[in] event The rotation event
184 void OnRotation( const RotationEvent& event );
187 * Called when the window is damaged.
189 void OnWindowDamaged( const DamageArea& area );
192 * Called when the source window notifies us the content in clipboard is selected.
194 void OnSelectionDataSend( void* event );
197 * Called when the source window sends us about the selected content.
199 void OnSelectionDataReceived( void* event );
202 * Called when the style is changed.
204 void OnStyleChanged( StyleChange::Type styleChange );
209 EventHandler( const EventHandler& eventHandler );
212 EventHandler& operator=( const EventHandler& eventHandler );
216 Dali::StyleMonitor mStyleMonitor; ///< Handle to the style monitor, set on construction, to send font size and font change events to.
217 DamageObserver& mDamageObserver; ///< Reference to the DamageObserver, set on construction, to sent damage events to.
219 Dali::ClipboardEventNotifier mClipboardEventNotifier; ///< Pointer to the clipboard event notifier
220 Dali::Clipboard mClipboard;///< Pointer to the clipboard
222 using ObserverContainer = std::vector<Observer*>;
223 ObserverContainer mObservers; ///< A list of event observer pointers
225 bool mPaused; ///< The paused state of the adaptor.
228 } // namespace Adaptor
230 } // namespace Internal
234 #endif // DALI_INTERNAL_EVENT_HANDLER_H