Add Keyboard repeat setting changed signal to Window
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / window-impl.h
old mode 100644 (file)
new mode 100755 (executable)
index eb7d873..5bc3bb9
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H
 
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
 #include <dali/public-api/object/base-object.h>
 #include <dali/public-api/actors/layer.h>
 #include <dali/public-api/render-tasks/render-task-list.h>
-#include <dali/integration-api/scene.h>
+#include <dali/public-api/object/property-array.h>
 
 // INTERNAL INCLUDES
-#include <dali/internal/adaptor/common/lifecycle-observer.h>
-#include <dali/internal/adaptor/common/adaptor-impl.h>
 #include <dali/public-api/adaptor-framework/window.h>
 #include <dali/public-api/adaptor-framework/key-grab.h>
-#include <dali/devel-api/adaptor-framework/drag-and-drop-detector.h>
+#include <dali/devel-api/adaptor-framework/window-devel.h>
+#include <dali/integration-api/adaptor-framework/scene-holder-impl.h>
+#include <dali/internal/adaptor/common/adaptor-impl.h>
+#include <dali/internal/window-system/common/event-handler.h>
 
 namespace Dali
 {
 class Adaptor;
 class Actor;
+class RenderSurfaceInterface;
 
 namespace Internal
 {
@@ -46,22 +48,26 @@ class WindowRenderSurface;
 class WindowBase;
 
 class Window;
-typedef IntrusivePtr<Window> WindowPtr;
-typedef IntrusivePtr<Orientation> OrientationPtr;
+using WindowPtr = IntrusivePtr< Window >;
+using OrientationPtr = IntrusivePtr< Orientation >;
+using EventHandlerPtr = IntrusivePtr< EventHandler >;
 
 /**
  * Window provides a surface to render onto with orientation & indicator properties.
  */
-class Window : public Dali::BaseObject, public LifeCycleObserver, public ConnectionTracker
+class Window : public Dali::Internal::Adaptor::SceneHolder, public EventHandler::Observer, public ConnectionTracker
 {
 public:
-  typedef Dali::Window::IndicatorSignalType IndicatorSignalType;
-  typedef Dali::Window::FocusSignalType FocusSignalType;
   typedef Dali::Window::ResizedSignalType ResizedSignalType;
+  typedef Dali::Window::FocusChangeSignalType FocusChangeSignalType;
+  typedef Dali::Window::ResizeSignalType ResizeSignalType;
+  typedef Dali::DevelWindow::VisibilityChangedSignalType VisibilityChangedSignalType;
+  typedef Dali::DevelWindow::TransitionEffectEventSignalType TransitionEffectEventSignalType;
+  typedef Dali::DevelWindow::KeyboardRepeatSettingsChangedSignalType KeyboardRepeatSettingsChangedSignalType;
   typedef Signal< void () > SignalType;
 
   /**
-   * Create a new Window. This should only be called once by the Application class
+   * @brief Create a new Window. This should only be called once by the Application class
    * @param[in] positionSize The position and size of the window
    * @param[in] name The window title
    * @param[in] className The window class name
@@ -71,36 +77,26 @@ public:
   static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent = false);
 
   /**
-   * Pass the adaptor back to the overlay. This allows the window to access Core's overlay.
-   * @param[in] adaptor An initialized adaptor
-   */
-  void SetAdaptor(Dali::Adaptor& adaptor);
-
-  /**
-   * Get the window surface
-   * @return The render surface
-   */
-  WindowRenderSurface* GetSurface();
-
-  /**
-   * @copydoc Dali::Window::ShowIndicator()
-   */
-  void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode );
-
-  /**
-   * @copydoc Dali::Window::SetIndicatorBgOpacity()
+   * @brief Create a new Window. This should only be called once by the Application class
+   * @param[in] surface The surface used to render on.
+   * @param[in] positionSize The position and size of the window
+   * @param[in] name The window title
+   * @param[in] className The window class name
+   * @param[in] isTransparent Whether window is transparent
+   * @return A newly allocated Window
    */
-  void SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacity );
+  static Window* New(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent = false);
 
   /**
-   * @copydoc Dali::Window::RotateIndicator()
+   * @copydoc Dali::Window::SetClass()
    */
-  void RotateIndicator( Dali::Window::WindowOrientation orientation );
+  void SetClass( std::string name, std::string className );
 
   /**
-   * @copydoc Dali::Window::SetClass()
+   * @brief Gets the window class name.
+   * @return The class of the window
    */
-  void SetClass( std::string name, std::string className );
+  std::string GetClassName() const;
 
   /**
    * @copydoc Dali::Window::Raise()
@@ -118,31 +114,6 @@ public:
   void Activate();
 
   /**
-   * @copydoc Dali::Window::Add()
-   */
-  void Add( Dali::Actor actor );
-
-  /**
-   * @copydoc Dali::Window::Remove()
-   */
-  void Remove( Dali::Actor remove );
-
-  /**
-   * @copydoc Dali::Window::SetBackgroundColor()
-   */
-  void SetBackgroundColor(Vector4 color);
-
-  /**
-   * @copydoc Dali::Window::GetBackgroundColor()
-   */
-  Vector4 GetBackgroundColor() const;
-
-  /**
-   * @copydoc Dali::Window::GetRootLayer()
-   */
-  Dali::Layer GetRootLayer() const;
-
-  /**
    * @copydoc Dali::Window::GetLayerCount()
    */
   uint32_t GetLayerCount() const;
@@ -153,6 +124,11 @@ public:
   Dali::Layer GetLayer( uint32_t depth ) const;
 
   /**
+   * @copydoc Dali::DevelWindow::GetRenderTaskList()
+   */
+  Dali::RenderTaskList GetRenderTaskList() const;
+
+  /**
    * @copydoc Dali::Window::AddAvailableOrientation()
    */
   void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
@@ -163,16 +139,6 @@ public:
   void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
 
   /**
-   * @copydoc Dali::Window::SetAvailableOrientations()
-   */
-  void SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations);
-
-  /**
-   * @copydoc Dali::Window::GetAvailableOrientations()
-   */
-  const std::vector<Dali::Window::WindowOrientation>& GetAvailableOrientations();
-
-  /**
    * @copydoc Dali::Window::SetPreferredOrientation()
    */
   void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
@@ -183,16 +149,6 @@ public:
   Dali::Window::WindowOrientation GetPreferredOrientation();
 
   /**
-   * @copydoc Dali::Window::GetDragAndDropDetector() const
-   */
-  Dali::DragAndDropDetector GetDragAndDropDetector() const;
-
-  /**
-   * @copydoc Dali::Window::GetNativeHandle() const
-   */
-  Dali::Any GetNativeHandle() const;
-
-  /**
    * @copydoc Dali::Window::SetAcceptFocus()
    */
   void SetAcceptFocus( bool accept );
@@ -213,11 +169,6 @@ public:
   void Hide();
 
   /**
-   * @copydoc Dali::Window::IsVisible() const
-   */
-  bool IsVisible() const;
-
-  /**
    * @copydoc Dali::Window::GetSupportedAuxiliaryHintCount()
    */
   unsigned int GetSupportedAuxiliaryHintCount() const;
@@ -333,6 +284,11 @@ public:
   void SetPositionSize( PositionSize positionSize );
 
   /**
+   * @copydoc Dali::Window::GetRootLayer()
+   */
+  Dali::Layer GetRootLayer() const;
+
+  /**
    * @copydoc Dali::Window::SetTransparency()
    */
   void SetTransparency( bool transparent );
@@ -358,19 +314,72 @@ public:
   bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result );
 
   /**
-   * Called from Orientation after the Change signal has been sent
+   * @copydoc Dali::DevelWindow::Get()
+   */
+  static Dali::Window Get( Dali::Actor actor );
+
+  /**
+   * @copydoc Dali::DevelWindow::SetParent()
+   */
+  void SetParent( Dali::Window& parent );
+
+  /**
+   * @copydoc Dali::DevelWindow::Unparent()
+   */
+  void Unparent();
+
+  /**
+   * @copydoc Dali::DevelWindow::GetParent()
+   */
+  Dali::Window GetParent();
+
+  /**
+   * @copydoc Dali::DevelWindow::GetCurrentOrientation()
+   */
+  Dali::Window::WindowOrientation GetCurrentOrientation() const;
+
+  /**
+   * @copydoc Dali::DevelWindow::SetAvailableOrientations()
+   */
+  void SetAvailableOrientations( const Dali::Vector<Dali::Window::WindowOrientation>& orientations );
+
+  /**
+   * @copydoc Dali::DevelWindow::SetDamagedAreas()
+   */
+  void SetDamagedAreas(std::vector<Dali::Rect<int>>& areas);
+
+public: // Dali::Internal::Adaptor::SceneHolder
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::SceneHolder::GetNativeHandle
+   */
+  Dali::Any GetNativeHandle() const override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::SceneHolder::IsVisible
    */
-  void RotationDone( int orientation, int width, int height );
+  bool IsVisible() const override;
 
   /**
-   * @brief Retrieves the unique ID of the window.
-   * @return The ID
+   * @copydoc Dali::DevelWindow::GetNativeId()
    */
-  uint32_t GetId() const;
+  int32_t GetNativeId() const;
 
 private:
 
   /**
+   * @brief Enumeration for orietation mode.
+   * The Orientation Mode is related to screen size.
+   * If screen width is longer than height, the Orientation Mode will have LANDSCAPE.
+   * Otherwise screen width is shorter than height or same, the Orientation Mode will have PORTRAIT.
+   */
+  enum class OrientationMode
+  {
+    PORTRAIT = 0,
+    LANDSCAPE
+  };
+
+  /**
    * Private constructor.
    * @sa Window::New()
    */
@@ -384,7 +393,7 @@ private:
   /**
    * Second stage initialization
    */
-  void Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className);
+  void Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className);
 
   /**
    * Called when the window becomes iconified or deiconified.
@@ -406,84 +415,162 @@ private:
    */
   void OnDeleteRequest();
 
-private: // Adaptor::Observer interface
+  /**
+   * Called when the window receives a Transition effect-start/end event.
+   */
+  void OnTransitionEffectEvent( DevelWindow::EffectState state, DevelWindow::EffectType type );
 
   /**
-   * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStart()
+   * @brief Called when window receives a keyboard repeat event.
    */
-  virtual void OnStart();
+  void OnKeyboardRepeatSettingsChanged();
 
   /**
-   * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnPause()
+   * @brief Set available orientation to window base.
    */
-  virtual void OnPause();
+  void SetAvailableAnlges( const std::vector< int >& angles );
 
   /**
-   * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnResume()
+   * @brief Convert from window orientation to angle using OrientationMode.
    */
-  virtual void OnResume();
+  int ConvertToAngle( Dali::Window::WindowOrientation orientation );
 
   /**
-   * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStop()
+   * @brief Convert from angle to window orientation using OrientationMode.
    */
-  virtual void OnStop();
+  Dali::Window::WindowOrientation ConvertToOrientation( int angle ) const;
 
   /**
-   * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnDestroy()
+   * @brief Check available window orientation for Available orientation.
    */
-  virtual void OnDestroy();
+  bool IsOrientationAvailable( Dali::Window::WindowOrientation orientation ) const;
 
-public: // Signals
+private: // Dali::Internal::Adaptor::SceneHolder
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::SceneHolder::OnAdaptorSet
+   */
+  void OnAdaptorSet( Dali::Adaptor& adaptor ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::SceneHolder::OnSurfaceSet
+   */
+  void OnSurfaceSet( Dali::RenderSurfaceInterface* surface ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::SceneHolder::OnPause
+   */
+  void OnPause() override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::SceneHolder::OnResume
+   */
+  void OnResume() override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::SceneHolder::RecalculateTouchPosition
+   */
+  void RecalculateTouchPosition( Integration::Point& point ) override;
+
+private: // Dali::Internal::Adaptor::EventHandler::Observer
 
   /**
-   * The user should connect to this signal to get a timing when indicator was shown / hidden.
+   * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnTouchPoint
    */
-  IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
+  void OnTouchPoint( Dali::Integration::Point& point, int timeStamp ) override;
 
   /**
-   * @copydoc Dali::Window::FocusChangedSignal()
+   * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnWheelEvent
    */
-  FocusSignalType& FocusChangedSignal() { return mFocusChangedSignal; }
+  void OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent ) override;
 
   /**
+   * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnKeyEvent
+   */
+  void OnKeyEvent( Dali::Integration::KeyEvent& keyEvent ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnRotation
+   */
+  void OnRotation( const RotationEvent& rotation ) override;
+
+public: // Signals
+
+  /**
+   * @copydoc Dali::Window::FocusChangeSignal()
+   */
+  FocusChangeSignalType& FocusChangeSignal() { return mFocusChangeSignal; }
+  /**
    * @copydoc Dali::Window::ResizedSignal()
    */
   ResizedSignalType& ResizedSignal() { return mResizedSignal; }
 
   /**
+   * @copydoc Dali::Window::ResizedSignal()
+   */
+  ResizeSignalType& ResizeSignal() { return mResizeSignal; }
+
+  /**
    * This signal is emitted when the window is requesting to be deleted
    */
   SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
 
+  /**
+   * @copydoc Dali::DevelWindow::VisibilityChangedSignal()
+   */
+  VisibilityChangedSignalType& VisibilityChangedSignal() { return mVisibilityChangedSignal; }
+
+  /**
+   * @copydoc Dali::Window::SignalEventProcessingFinished()
+   */
+  Dali::DevelWindow::EventProcessingFinishedSignalType& EventProcessingFinishedSignal() { return mScene.EventProcessingFinishedSignal(); }
+
+  /**
+   * @copydoc Dali::DevelWindow::TransitionEffectEventSignal()
+   */
+  TransitionEffectEventSignalType& TransitionEffectEventSignal() { return mTransitionEffectEventSignal; }
+
+  /**
+   * @copydoc Dali::DevelWindow::KeyboardRepeatSettingsChangedSignal()
+   */
+  KeyboardRepeatSettingsChangedSignalType& KeyboardRepeatSettingsChangedSignal() { return mKeyboardRepeatSettingsChangedSignal; }
+
 private:
 
-  static uint32_t                       mWindowCounter;    ///< A counter to track the window creation
-  uint32_t                              mId;               ///< A unique ID to identify the window starting from 0
-  std::unique_ptr< WindowRenderSurface > mSurface;
-  Dali::Integration::Scene              mScene;
+  WindowRenderSurface*                  mWindowSurface;      ///< The window rendering surface
   WindowBase*                           mWindowBase;
-  bool                                  mStarted:1;
+  std::string                           mName;
+  std::string                           mClassName;
   bool                                  mIsTransparent:1;
   bool                                  mIsFocusAcceptable:1;
-  bool                                  mVisible:1;
   bool                                  mIconified:1;
   bool                                  mOpaqueState:1;
   bool                                  mResizeEnabled:1;
-  Adaptor*                              mAdaptor;
-  Dali::DragAndDropDetector             mDragAndDropDetector;
   Dali::Window::Type                    mType;
+  Dali::Window                          mParentWindow;
+
+  OrientationPtr                        mOrientation;
+  std::vector< int >                    mAvailableAngles;
+  int                                   mPreferredAngle;
+
+  int                                   mRotationAngle;     ///< The angle of the rotation
+  int                                   mWindowWidth;       ///< The width of the window
+  int                                   mWindowHeight;      ///< The height of the window
+
+  EventHandlerPtr                       mEventHandler;      ///< The window events handler
 
-  OrientationPtr                               mOrientation;
-  std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
-  Dali::Window::WindowOrientation              mPreferredOrientation;
+  OrientationMode                       mOrientationMode;
 
-  Vector4                               mBackgroundColor;
+  int                                   mNativeWindowId;          ///< The Native Window Id
 
   // Signals
-  IndicatorSignalType mIndicatorVisibilityChangedSignal;
-  FocusSignalType     mFocusChangedSignal;
-  ResizedSignalType   mResizedSignal;
-  SignalType          mDeleteRequestSignal;
+  ResizedSignalType                       mResizedSignal;
+  SignalType                              mDeleteRequestSignal;
+  FocusChangeSignalType                   mFocusChangeSignal;
+  ResizeSignalType                        mResizeSignal;
+  VisibilityChangedSignalType             mVisibilityChangedSignal;
+  TransitionEffectEventSignalType         mTransitionEffectEventSignal;
+  KeyboardRepeatSettingsChangedSignalType mKeyboardRepeatSettingsChangedSignal;
 };
 
 } // namespace Adaptor