X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fwindow-system%2Fcommon%2Fevent-handler.h;h=795a919cbb14b95351c61f1cedec304724343a82;hb=15cb030e9396d29dab2de0bd298c1daf810bcf5f;hp=d0f73e77fb8959fdbb9a7c07bce8e3a6732a4ebc;hpb=6f1329b5d2482488625a3b71bdc3be05544b1513;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/window-system/common/event-handler.h b/dali/internal/window-system/common/event-handler.h index d0f73e7..795a919 100755 --- a/dali/internal/window-system/common/event-handler.h +++ b/dali/internal/window-system/common/event-handler.h @@ -1,8 +1,8 @@ -#ifndef __DALI_INTERNAL_EVENT_HANDLER_H__ -#define __DALI_INTERNAL_EVENT_HANDLER_H__ +#ifndef DALI_INTERNAL_EVENT_HANDLER_H +#define DALI_INTERNAL_EVENT_HANDLER_H /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,21 +19,16 @@ */ // EXTERNAL INCLUDES +#include // uint32_t #include -#include -#include -#include #include #include // INTERNAL INCLUDES #include #include -#include -#include #include -#include #include namespace Dali @@ -42,8 +37,10 @@ namespace Dali namespace Integration { -class RenderSurface; -class Scene; +struct Point; +struct KeyEvent; +struct WheelEvent; + } namespace Internal @@ -52,8 +49,8 @@ namespace Internal namespace Adaptor { -class GestureManager; class StyleMonitor; +class WindowRenderSurface; /** * The Event Handler class is responsible for setting up receiving of Ecore events and then converts them @@ -66,42 +63,63 @@ class EventHandler : public ConnectionTracker, public Dali::RefObject public: /** - * Constructor. - * @param[in] scene The scene where events will be sent to. - * @param[in] coreEventInterface Used to send events to Core. - * @param[in] gestureManager The Gesture Manager. - * @param[in] damageObserver The damage observer (to pass damage events to). + * The observer can be overridden in order to listen to the events. */ - EventHandler( Dali::Integration::Scene scene, CoreEventInterface& coreEventInterface, GestureManager& gestureManager, DamageObserver& damageObserver ); + class Observer + { + public: - /** - * Destructor. - */ - ~EventHandler(); + /** + * Deriving classes should override this to be notified when we receive a touch point event. + * @param[in] point The touch point + * @param[in] timeStamp The time stamp + */ + virtual void OnTouchPoint( Dali::Integration::Point& point, int timeStamp ) = 0; - /** - * Feed (Send) touch event to core and gesture manager - * @param[in] touchEvent The touch event holding the touch point information. - */ - void FeedTouchPoint( TouchPoint& point, int timeStamp ); + /** + * Deriving classes should override this to be notified when we receive a wheel event. + * @param[in] wheelEvent The wheel event + */ + virtual void OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent ) = 0; - /** - * Feed (Send) wheel event to core and gesture manager - * @param[in] wheelEvent The wheel event - */ - void FeedWheelEvent( WheelEvent& wheelEvent ); + /** + * Deriving classes should override this to be notified when we receive a key event. + * @param[in] keyEvent The key event holding the key information. + */ + virtual void OnKeyEvent( Dali::Integration::KeyEvent& keyEvent ) = 0; + + /** + * Deriving classes should override this to be notified when the window is rotated. + * @param[in] rotation The rotation event. + */ + virtual void OnRotation( const RotationEvent& rotation ) = 0; + + protected: + + /** + * Protected Constructor. + */ + Observer() {} + + /** + * Protected virtual destructor. + */ + virtual ~Observer() {} + }; + +public: /** - * Feed (Send) key event to core - * @param[in] keyEvent The key event holding the key information. + * Constructor. + * @param[in] surface The render surface of the window. + * @param[in] damageObserver The damage observer (to pass damage events to). */ - void FeedKeyEvent( KeyEvent& keyEvent ); + EventHandler( WindowRenderSurface* surface, DamageObserver& damageObserver ); /** - * Feed (Send) an event to core - * @param[in] event The event information. + * Destructor. */ - void FeedEvent( Integration::Event& event ); + ~EventHandler(); /** * Called when the adaptor is paused. @@ -114,31 +132,19 @@ public: void Resume(); /** - * Set the rotation observer (note, some adaptors may not have a rotation observer) - * @param[in] observer The rotation observer - */ - void SetRotationObserver( RotationObserver* observer ); - -private: - - /** - * Send touch event to core. - * @param[in] point The touch point information. - * @param[in] timeStamp The time the touch occurred. + * Adds an observer so that we can observe the events. + * @param[in] observer The observer. */ - void SendEvent(Integration::Point& point, unsigned long timeStamp); + void AddObserver( Observer& observer ); /** - * Send key event to core. - * @param[in] keyEvent The KeyEvent to send. + * Removes the observer from the EventHandler. + * @param[in] observer The observer to remove. + * @note Observers should remove themselves when they are destroyed. */ - void SendEvent(Integration::KeyEvent& keyEvent); + void RemoveObserver( Observer& observer ); - /** - * Send wheel event to core. - * @param[in] wheelEvent The wheel event - */ - void SendWheelEvent( WheelEvent& wheelEvent ); +private: /** * Send a style change event to the style monitor. @@ -153,26 +159,9 @@ private: void SendEvent( const DamageArea& area ); /** - * Inform rotation observer of rotation prepare event - * @param[in] rotation The rotation event - */ - void SendRotationPrepareEvent( const RotationEvent& rotation ); - - /** - * Inform rotation observer of rotation prepare event - */ - void SendRotationRequestEvent(); - - /** - * Resets the event handler. - * Called when the adaptor is paused or resumed. - */ - void Reset(); - - /** * Called when a touch event is received. */ - void OnTouchEvent( Integration::Point& point, unsigned long timeStamp ); + void OnTouchEvent( Integration::Point& point, uint32_t timeStamp ); /** * Called when a mouse wheel is received. @@ -190,6 +179,12 @@ private: void OnFocusChanged( bool focusIn ); /** + * Called when the window is rotated. + * @param[in] event The rotation event + */ + void OnRotation( const RotationEvent& event ); + + /** * Called when the window is damaged. */ void OnWindowDamaged( const DamageArea& area ); @@ -216,13 +211,6 @@ private: private: - /** - * Convert touch event position - */ - void ConvertTouchPosition( Integration::Point& point ); - -private: - // Undefined EventHandler( const EventHandler& eventHandler ); @@ -231,21 +219,15 @@ private: private: - Dali::Integration::Scene mScene; ///< The scene the event handler is created for. - CoreEventInterface& mCoreEventInterface; ///< Used to send events to Core. - Dali::Integration::TouchEventCombiner mCombiner; ///< Combines multi-touch events. - GestureManager& mGestureManager; ///< Reference to the GestureManager, set on construction, to send touch events to for analysis. Dali::StyleMonitor mStyleMonitor; ///< Handle to the style monitor, set on construction, to send font size and font change events to. DamageObserver& mDamageObserver; ///< Reference to the DamageObserver, set on construction, to sent damage events to. - RotationObserver* mRotationObserver; ///< Pointer to rotation observer, if present. Dali::AccessibilityAdaptor mAccessibilityAdaptor; ///< Pointer to the accessibility adaptor Dali::ClipboardEventNotifier mClipboardEventNotifier; ///< Pointer to the clipboard event notifier Dali::Clipboard mClipboard;///< Pointer to the clipboard - int mRotationAngle; - int mWindowWidth; - int mWindowHeight; + using ObserverContainer = std::vector; + ObserverContainer mObservers; ///< A list of event observer pointers bool mPaused; ///< The paused state of the adaptor. }; @@ -256,4 +238,4 @@ private: } // namespace Dali -#endif // __DALI_INTERNAL_EVENT_HANDLER_H__ +#endif // DALI_INTERNAL_EVENT_HANDLER_H