Support Device orientation and window orientation event. 22/283622/9
authorWonsik Jung <sidein@samsung.com>
Mon, 31 Oct 2022 11:30:10 +0000 (20:30 +0900)
committerWonsik Jung <sidein@samsung.com>
Thu, 10 Nov 2022 07:59:33 +0000 (16:59 +0900)
Supporting  Device orientation and Window Orienation event when device orientation is changed or window orientation is changed.
Window orientation event is emitted by display server.
To emit the Window Orientation event, AddAvailableOrientation() or SetPreferredOrientation() should be called before the device is rotated.
Otherwise, Device Orientation event is emitted by Application framework and any condition is not needed.

Change-Id: I78e8854e74810f31e7aa7403b8e913f50b67f3d2

13 files changed:
automated-tests/src/dali-adaptor/utc-Dali-Application.cpp
automated-tests/src/dali-adaptor/utc-Dali-Window.cpp
dali/devel-api/adaptor-framework/window-devel.cpp
dali/devel-api/adaptor-framework/window-devel.h
dali/internal/adaptor/common/application-impl.cpp
dali/internal/adaptor/common/application-impl.h
dali/internal/adaptor/common/framework.h
dali/internal/adaptor/tizen-wayland/framework-tizen.cpp
dali/internal/window-system/common/window-impl.cpp
dali/internal/window-system/common/window-impl.h
dali/public-api/adaptor-framework/application.cpp
dali/public-api/adaptor-framework/application.h
dali/public-api/adaptor-framework/device-status.h

index 0c0323f..48d11de 100644 (file)
@@ -76,6 +76,10 @@ void LowMemorySignalCallback(Dali::DeviceStatus::Memory::Status status)
 {
 }
 
+void OnDeviceOrientationChangedSignalCallback(DeviceStatus::Orientation::Status status)
+{
+}
+
 int UtcDaliApplicationNew01(void)
 {
   Application application = Application::New();
@@ -536,6 +540,32 @@ int UtcDaliApplicationLowMemorySignalN(void)
   END_TEST;
 }
 
+int UtcDaliApplicationOrientationChangedSignalP(void)
+{
+  Application application = Application::New();
+  application.DeviceOrientationChangedSignal().Connect(&OnDeviceOrientationChangedSignalCallback);
+  DALI_TEST_CHECK(application);
+
+  END_TEST;
+}
+
+int UtcDaliApplicationOrientationChangedSignalN(void)
+{
+  Application application;
+
+  try
+  {
+    application.DeviceOrientationChangedSignal().Connect(&OnDeviceOrientationChangedSignalCallback);
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true);
+  }
+
+  END_TEST;
+}
+
 int UtcDaliApplicationGetResourcePathP(void)
 {
   Application application = Application::New();
index 1873913..2cab8de 100644 (file)
@@ -202,7 +202,7 @@ int UtcDaliWindowMaximizeN(void)
 {
   try
   {
-    Dali::Window    instance;
+    Dali::Window instance;
     DevelWindow::Maximize(instance, true);
     DALI_TEST_CHECK(false); // Should not reach here!
   }
@@ -218,7 +218,7 @@ int UtcDaliWindowIsMaximizedN(void)
 {
   try
   {
-    Dali::Window    instance;
+    Dali::Window instance;
     DevelWindow::IsMaximized(instance);
     DALI_TEST_CHECK(false); // Should not reach here!
   }
@@ -234,7 +234,7 @@ int UtcDaliWindowSetMaximumSizeN(void)
 {
   try
   {
-    Dali::Window    instance;
+    Dali::Window             instance;
     Dali::Window::WindowSize size(100, 100);
     DevelWindow::SetMaximumSize(instance, size);
     DALI_TEST_CHECK(false); // Should not reach here!
@@ -251,7 +251,7 @@ int UtcDaliWindowMinimizeN(void)
 {
   try
   {
-    Dali::Window    instance;
+    Dali::Window instance;
     DevelWindow::Minimize(instance, true);
     DALI_TEST_CHECK(false); // Should not reach here!
   }
@@ -267,7 +267,7 @@ int UtcDaliWindowIsMinimizedN(void)
 {
   try
   {
-    Dali::Window    instance;
+    Dali::Window instance;
     DevelWindow::IsMinimized(instance);
     DALI_TEST_CHECK(false); // Should not reach here!
   }
@@ -283,7 +283,7 @@ int UtcDaliWindowSetMimimumSizeN(void)
 {
   try
   {
-    Dali::Window    instance;
+    Dali::Window             instance;
     Dali::Window::WindowSize size(100, 100);
     DevelWindow::SetMimimumSize(instance, size);
     DALI_TEST_CHECK(false); // Should not reach here!
@@ -1470,7 +1470,7 @@ int UtcDaliWindowAddInputRegion(void)
   Dali::Window instance;
   try
   {
-    Rect<int> includedInputRegion(0,0,720,640);
+    Rect<int> includedInputRegion(0, 0, 720, 640);
     DevelWindow::IncludeInputRegion(instance, includedInputRegion);
     DALI_TEST_CHECK(false); // Should not get here
   }
@@ -1486,10 +1486,10 @@ int UtcDaliWindowSubtractInputRegion(void)
   Dali::Window instance;
   try
   {
-    Rect<int> includedInputRegion(0,0,720,1280);
+    Rect<int> includedInputRegion(0, 0, 720, 1280);
     DevelWindow::IncludeInputRegion(instance, includedInputRegion);
 
-    Rect<int> excludedInputRegion(0,641,720,640);
+    Rect<int> excludedInputRegion(0, 641, 720, 640);
     DevelWindow::ExcludeInputRegion(instance, excludedInputRegion);
 
     DALI_TEST_CHECK(false); // Should not get here
@@ -1501,7 +1501,6 @@ int UtcDaliWindowSubtractInputRegion(void)
   END_TEST;
 }
 
-
 int UtcDaliWindowSetNeedsRotationCompletedAcknowledgementNegative(void)
 {
   try
@@ -1547,3 +1546,33 @@ int UtcDaliWindowSendRotationCompletedAcknowledgementNegative(void)
   }
   END_TEST;
 }
+
+int UtcDaliWindowMovedSignalNegative(void)
+{
+  Dali::Window instance;
+  try
+  {
+    DevelWindow::MovedSignal(instance);
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true); // We expect an assert
+  }
+  END_TEST;
+}
+
+int UtcDaliWindowOrientationChangedSignalNegative(void)
+{
+  Dali::Window instance;
+  try
+  {
+    DevelWindow::OrientationChangedSignal(instance);
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true); // We expect an assert
+  }
+  END_TEST;
+}
index 10a1642..25f5bd1 100644 (file)
@@ -116,6 +116,11 @@ MovedSignalType& MovedSignal(Window window)
   return GetImplementation(window).MovedSignal();
 }
 
+OrientationChangedSignalType& OrientationChangedSignal(Window window)
+{
+  return GetImplementation(window).OrientationChangedSignal();
+}
+
 void SetParent(Window window, Window parent)
 {
   GetImplementation(window).SetParent(parent);
index 81cc05c..372c548 100644 (file)
@@ -47,6 +47,7 @@ typedef Signal<void(const std::string&, const std::string&, const Property::Arra
 typedef Signal<void(Window, bool)>                                                   AccessibilityHighlightSignalType;        ///< Accessibility Highlight signal type
 typedef Signal<bool(const KeyEvent&)>                                                InterceptKeyEventSignalType;             ///< Intercept Key event signal type
 typedef Signal<void(Window, Dali::Window::WindowPosition)>                           MovedSignalType;                         ///< Window Moved signal type
+typedef Signal<void(Window, Dali::WindowOrientation)>                                OrientationChangedSignalType;            ///< Window orientation changed signal type
 
 /**
  * @brief Creates an initialized handle to a new Window.
@@ -57,7 +58,7 @@ typedef Signal<void(Window, Dali::Window::WindowPosition)>
  * @param[in] isTransparent Whether Window is transparent
  * @return A new window
  * @note This creates an extra window in addition to the default main window
-*/
+ */
 DALI_ADAPTOR_API Window New(Any surface, PositionSize windowPosition, const std::string& name, bool isTransparent = false);
 
 /**
@@ -540,6 +541,24 @@ DALI_ADAPTOR_API InterceptKeyEventSignalType& InterceptKeyEventSignal(Window win
  */
 DALI_ADAPTOR_API MovedSignalType& MovedSignal(Window window);
 
+/**
+ * @brief This signal is emitted when the window orientation is changed.
+ *
+ * To emit Window Orientation signal, AddAvailableOrientation() or SetPreferredOrientation() should be called before device is rotated.
+ * Most of cases, AddAvailableOrientation() or SetPreferredOrientation() is callled in onCreate().
+ *
+ * A callback of the following type may be connected:
+ * @code
+ *   void YourCallbackName( Window window, Dali::WindowOrientation orientation );
+ * @endcode
+ * The parameter is the changed window orientation.
+ * and window means this signal was called from what window
+ *
+ * @param[in] window The window instance.
+ * @return The signal to connect to
+ */
+DALI_ADAPTOR_API OrientationChangedSignalType& OrientationChangedSignal(Window window);
+
 } // namespace DevelWindow
 
 } // namespace Dali
index 13a3fbe..1032b3a 100644 (file)
@@ -390,6 +390,12 @@ void Application::OnMemoryLow(Dali::DeviceStatus::Memory::Status status)
   mLowMemorySignal.Emit(status);
 }
 
+void Application::OnDeviceOrientationChanged(Dali::DeviceStatus::Orientation::Status status)
+{
+  Dali::Application application(this);
+  mDeviceOrientationChangedSignal.Emit(status);
+}
+
 void Application::OnSurfaceCreated(Any newSurface)
 {
   void* newWindow = AnyCast<void*>(newSurface);
@@ -449,6 +455,12 @@ void Application::OnTaskMemoryLow(Dali::DeviceStatus::Memory::Status status)
   mTaskLowMemorySignal.Emit(status);
 }
 
+void Application::OnTaskDeviceOrientationChanged(Dali::DeviceStatus::Orientation::Status status)
+{
+  Dali::Application application(this);
+  mTaskDeviceOrientationChangedSignal.Emit(status);
+}
+
 bool Application::AddIdle(CallbackBase* callback, bool hasReturnValue)
 {
   return mAdaptor->AddIdle(callback, hasReturnValue);
index 7a1f603..700f3a2 100644 (file)
@@ -67,11 +67,12 @@ typedef IntrusivePtr<Application> ApplicationPtr;
 class Application : public BaseObject, public Framework::Observer, public Framework::TaskObserver
 {
 public:
-  typedef Dali::Application::LowBatterySignalType LowBatterySignalType;
-  typedef Dali::Application::LowMemorySignalType  LowMemorySignalType;
-  typedef Dali::Application::AppSignalType        AppSignalType;
-  typedef Dali::Application::AppControlSignalType AppControlSignalType;
-  typedef Dali::Application::WINDOW_MODE          WINDOW_MODE;
+  typedef Dali::Application::LowBatterySignalType               LowBatterySignalType;
+  typedef Dali::Application::LowMemorySignalType                LowMemorySignalType;
+  typedef Dali::Application::DeviceOrientationChangedSignalType DeviceOrientationChangedSignalType;
+  typedef Dali::Application::AppSignalType                      AppSignalType;
+  typedef Dali::Application::AppControlSignalType               AppControlSignalType;
+  typedef Dali::Application::WINDOW_MODE                        WINDOW_MODE;
 
   /**
    * Create a new application
@@ -212,6 +213,11 @@ public: // From Framework::Observer
   void OnMemoryLow(Dali::DeviceStatus::Memory::Status status) override;
 
   /**
+   * Called when the framework informs the application that device orientation is changed.
+   */
+  void OnDeviceOrientationChanged(Dali::DeviceStatus::Orientation::Status status) override;
+
+  /**
    * Called when the framework informs the application that the platform surface is created.
    */
   void OnSurfaceCreated(Any newSurface) override;
@@ -258,6 +264,15 @@ public: // From Framework::TaskObserver
    */
   void OnTaskMemoryLow(Dali::DeviceStatus::Memory::Status status) override;
 
+  /**
+   * Called when the framework informs the application that the device orientation is changed.
+   *
+   * Device orientation changed event is from Application Framework(Sensor Framework), it means it is system event.
+   * If UIThreading is enable, DALI application has the main thread and UI thread.
+   * This event is emitted in main thread, then it is posted to the UI thread in this callback function.
+   */
+  void OnTaskDeviceOrientationChanged(Dali::DeviceStatus::Orientation::Status status) override;
+
 public:
   /**
    * Sets a user defined theme file.
@@ -363,6 +378,14 @@ public: // Signals
   }
 
   /**
+   * @copydoc Dali::Application:::DeviceOrientationChangedSignalType()
+   */
+  Dali::Application::DeviceOrientationChangedSignalType& DeviceOrientationChangedSignal()
+  {
+    return mDeviceOrientationChangedSignal;
+  }
+
+  /**
    * @copydoc Dali::Application::TaskInitSignal()
    */
   Dali::Application::AppSignalType& TaskInitSignal()
@@ -418,6 +441,14 @@ public: // Signals
     return mTaskLowMemorySignal;
   }
 
+  /**
+   * @copydoc Dali::Application::TaskDeviceOrientationChangedSignal()
+   */
+  Dali::Application::DeviceOrientationChangedSignalType& TaskDeviceOrientationChangedSignal()
+  {
+    return mTaskDeviceOrientationChangedSignal;
+  }
+
 protected:
   /**
    * Private Constructor
@@ -467,24 +498,26 @@ protected:
   void ChangePreInitializedWindowSize();
 
 private:
-  AppSignalType        mInitSignal;
-  AppSignalType        mTerminateSignal;
-  AppSignalType        mPauseSignal;
-  AppSignalType        mResumeSignal;
-  AppSignalType        mResetSignal;
-  AppControlSignalType mAppControlSignal;
-  AppSignalType        mLanguageChangedSignal;
-  AppSignalType        mRegionChangedSignal;
-  LowBatterySignalType mLowBatterySignal;
-  LowMemorySignalType  mLowMemorySignal;
-
-  AppSignalType        mTaskInitSignal;
-  AppSignalType        mTaskTerminateSignal;
-  AppControlSignalType mTaskAppControlSignal;
-  AppSignalType        mTaskLanguageChangedSignal;
-  AppSignalType        mTaskRegionChangedSignal;
-  LowBatterySignalType mTaskLowBatterySignal;
-  LowMemorySignalType  mTaskLowMemorySignal;
+  AppSignalType                      mInitSignal;
+  AppSignalType                      mTerminateSignal;
+  AppSignalType                      mPauseSignal;
+  AppSignalType                      mResumeSignal;
+  AppSignalType                      mResetSignal;
+  AppControlSignalType               mAppControlSignal;
+  AppSignalType                      mLanguageChangedSignal;
+  AppSignalType                      mRegionChangedSignal;
+  LowBatterySignalType               mLowBatterySignal;
+  LowMemorySignalType                mLowMemorySignal;
+  DeviceOrientationChangedSignalType mDeviceOrientationChangedSignal;
+
+  AppSignalType                      mTaskInitSignal;
+  AppSignalType                      mTaskTerminateSignal;
+  AppControlSignalType               mTaskAppControlSignal;
+  AppSignalType                      mTaskLanguageChangedSignal;
+  AppSignalType                      mTaskRegionChangedSignal;
+  LowBatterySignalType               mTaskLowBatterySignal;
+  LowMemorySignalType                mTaskLowMemorySignal;
+  DeviceOrientationChangedSignalType mTaskDeviceOrientationChangedSignal;
 
   EventLoop* mEventLoop;
   Framework* mFramework;
index e04ecb6..cf8760f 100644 (file)
@@ -161,6 +161,13 @@ public:
     }
 
     /**
+     * Invoked when the device orientation is changed.
+     */
+    virtual void OnDeviceOrientationChanged(Dali::DeviceStatus::Orientation::Status status)
+    {
+    }
+
+    /**
      * Invoked when the platform surface is created.
      */
     virtual void OnSurfaceCreated(Any newSurface)
@@ -241,6 +248,17 @@ public:
     virtual void OnTaskMemoryLow(Dali::DeviceStatus::Memory::Status status)
     {
     }
+
+    /**
+     * Invoked when the device orientation is changed.
+     *
+     * Device orientation changed event is from Application Framework(Sensor Framework), it means it is system event.
+     * If UIThreading is enable, DALI application has the main thread and UI thread.
+     * This event is emitted in main thread, then it is posted to the UI thread in this callback function.
+     */
+    virtual void OnTaskDeviceOrientationChanged(Dali::DeviceStatus::Orientation::Status status)
+    {
+    }
   };
 
 public:
index 6ff64ec..e734e64 100644 (file)
@@ -217,6 +217,33 @@ DeviceStatus::Battery::Status GetBatteryStatus(app_event_low_battery_status_e ba
   }
 }
 
+DeviceStatus::Orientation::Status GetOrientationStatus(app_device_orientation_e orientationStatus)
+{
+  switch(orientationStatus)
+  {
+    case APP_DEVICE_ORIENTATION_0:
+    {
+      return Dali::DeviceStatus::Orientation::Status::ORIENTATION_0;
+    }
+    case APP_DEVICE_ORIENTATION_90:
+    {
+      return Dali::DeviceStatus::Orientation::Status::ORIENTATION_90;
+    }
+    case APP_DEVICE_ORIENTATION_180:
+    {
+      return Dali::DeviceStatus::Orientation::Status::ORIENTATION_180;
+    }
+    case APP_DEVICE_ORIENTATION_270:
+    {
+      return Dali::DeviceStatus::Orientation::Status::ORIENTATION_270;
+    }
+    default:
+    {
+      return Dali::DeviceStatus::Orientation::Status::ORIENTATION_0;
+    }
+  }
+}
+
 } // namespace AppCore
 
 /**
@@ -233,7 +260,8 @@ struct Framework::Impl
       explicit Task(Framework* framework)
       : mFramework(framework),
         mNewBatteryStatus(Dali::DeviceStatus::Battery::Status::NORMAL),
-        mNewMemoryStatus(Dali::DeviceStatus::Memory::NORMAL)
+        mNewMemoryStatus(Dali::DeviceStatus::Memory::NORMAL),
+        mNewDeviceOrientationStatus(Dali::DeviceStatus::Orientation::ORIENTATION_0)
       {
       }
 
@@ -300,7 +328,8 @@ struct Framework::Impl
         mNewMemoryStatus = AppCore::GetMemoryStatus(static_cast<app_event_low_memory_status_e>(state));
 
         PostToUiThread(
-          [](gpointer userData) -> gboolean {
+          [](gpointer userData) -> gboolean
+          {
             auto* task      = static_cast<Task*>(userData);
             auto* framework = static_cast<Framework*>(task->mFramework);
             framework->mObserver.OnMemoryLow(task->mNewMemoryStatus);
@@ -310,13 +339,33 @@ struct Framework::Impl
         AppCoreTaskBase::OnLowMemory(state);
       }
 
+      void OnDeviceOrientationChanged(AppCoreTaskBase::DeviceOrientationState state) override
+      {
+        print_log(DLOG_INFO, "DALI", "%s: %s(%d) > OnDeviceOrientationChanged() emitted, orientation :%d", __MODULE__, __func__, __LINE__, state);
+
+        mNewDeviceOrientationStatus = AppCore::GetOrientationStatus(static_cast<app_device_orientation_e>(state));
+
+        PostToUiThread(
+          [](gpointer userData) -> gboolean
+          {
+            auto* task      = static_cast<Task*>(userData);
+            auto* framework = static_cast<Framework*>(task->mFramework);
+            framework->mObserver.OnDeviceOrientationChanged(task->mNewDeviceOrientationStatus);
+            return G_SOURCE_REMOVE;
+          });
+
+        mFramework->mTaskObserver.OnTaskDeviceOrientationChanged(mNewDeviceOrientationStatus);
+
+        AppCoreTaskBase::OnDeviceOrientationChanged(state);
+      }
       void OnLowBattery(AppCoreTaskBase::LowBatteryState state) override
       {
         print_log(DLOG_INFO, "DALI", "%s: %s(%d) > OnLowBattery() emitted", __MODULE__, __func__, __LINE__);
         mNewBatteryStatus = AppCore::GetBatteryStatus(static_cast<app_event_low_battery_status_e>(state));
 
         PostToUiThread(
-          [](gpointer userData) -> gboolean {
+          [](gpointer userData) -> gboolean
+          {
             auto* task      = static_cast<Task*>(userData);
             auto* framework = static_cast<Framework*>(task->mFramework);
             framework->mObserver.OnBatteryLow(task->mNewBatteryStatus);
@@ -333,7 +382,8 @@ struct Framework::Impl
         mFramework->SetLanguage(mNewLanguage);
 
         PostToUiThread(
-          [](gpointer userData) -> gboolean {
+          [](gpointer userData) -> gboolean
+          {
             auto* task      = static_cast<Task*>(userData);
             auto* framework = static_cast<Framework*>(task->mFramework);
             framework->mObserver.OnLanguageChanged();
@@ -351,7 +401,8 @@ struct Framework::Impl
         mFramework->SetRegion(mNewRegion);
 
         PostToUiThread(
-          [](gpointer userData) -> gboolean {
+          [](gpointer userData) -> gboolean
+          {
             auto* task      = static_cast<Task*>(userData);
             auto* framework = static_cast<Framework*>(task->mFramework);
             framework->mObserver.OnRegionChanged();
@@ -362,13 +413,6 @@ struct Framework::Impl
         AppCoreTaskBase::OnRegionChanged(mNewRegion);
       }
 
-      void OnDeviceOrientationChanged(AppCoreTaskBase::DeviceOrientationState state) override
-      {
-        print_log(DLOG_INFO, "DALI", "%s: %s(%d) > OnDeviceOrientationChanged() emitted", __MODULE__, __func__, __LINE__);
-        // Note: This isn't emitted to the App.
-        AppCoreTaskBase::OnDeviceOrientationChanged(state);
-      }
-
     private:
       GMainContext* GetTizenGlibContext()
       {
@@ -395,11 +439,12 @@ struct Framework::Impl
       }
 
     private:
-      Framework*                          mFramework;
-      std::string                         mNewLanguage;
-      std::string                         mNewRegion;
-      Dali::DeviceStatus::Battery::Status mNewBatteryStatus;
-      Dali::DeviceStatus::Memory::Status  mNewMemoryStatus;
+      Framework*                              mFramework;
+      std::string                             mNewLanguage;
+      std::string                             mNewRegion;
+      Dali::DeviceStatus::Battery::Status     mNewBatteryStatus;
+      Dali::DeviceStatus::Memory::Status      mNewMemoryStatus;
+      Dali::DeviceStatus::Orientation::Status mNewDeviceOrientationStatus;
     };
 
     explicit UiAppContext(unsigned int hint, Framework* framework)
@@ -575,10 +620,6 @@ struct Framework::Impl
       }
     }
 
-    static void OnDeviceOrientationChanged(app_event_info_h event_info, void* user_data)
-    {
-    }
-
     static void OnRegionFormatChanged(app_event_info_h event_info, void* user_data)
     {
       auto*     context   = static_cast<UiAppContext*>(user_data);
@@ -623,6 +664,18 @@ struct Framework::Impl
       observer->OnMemoryLow(result);
     }
 
+    static void OnDeviceOrientationChanged(app_event_info_h event_info, void* user_data)
+    {
+      auto*     context   = static_cast<UiAppContext*>(user_data);
+      auto*     framework = context->mFramework;
+      Observer* observer  = &framework->mObserver;
+
+      app_device_orientation_e status;
+      app_event_get_device_orientation(event_info, &status);
+      Dali::DeviceStatus::Orientation::Status result = AppCore::GetOrientationStatus(status);
+      observer->OnDeviceOrientationChanged(result);
+    }
+
     void ProcessBundle(Framework* framework, bundle* bundleData)
     {
       if(bundleData == nullptr)
@@ -886,10 +939,6 @@ struct Framework::Impl
     }
   }
 
-  static void AppDeviceRotated(AppCore::AppEventInfoPtr event_info, void* data)
-  {
-  }
-
   static void AppRegionChanged(AppCore::AppEventInfoPtr event, void* data)
   {
     Framework* framework = static_cast<Framework*>(data);
@@ -910,7 +959,7 @@ struct Framework::Impl
   {
     Observer*                           observer = &static_cast<Framework*>(data)->mObserver;
     int                                 status   = *static_cast<int*>(event->value);
-    Dali::DeviceStatus::Battery::Status result   = Dali::DeviceStatus::Battery::NORMAL;
+    Dali::DeviceStatus::Battery::Status result   = Dali::DeviceStatus::Battery::Status::NORMAL;
 
     // convert to dali battery status
     switch(status)
@@ -935,7 +984,7 @@ struct Framework::Impl
   {
     Observer*                          observer = &static_cast<Framework*>(data)->mObserver;
     int                                status   = *static_cast<int*>(event->value);
-    Dali::DeviceStatus::Memory::Status result   = Dali::DeviceStatus::Memory::NORMAL;
+    Dali::DeviceStatus::Memory::Status result   = Dali::DeviceStatus::Memory::Status::NORMAL;
 
     // convert to dali memmory status
     switch(status)
@@ -961,6 +1010,41 @@ struct Framework::Impl
     observer->OnMemoryLow(result);
   }
 
+  static void AppDeviceOrientationChanged(AppCore::AppEventInfoPtr event, void* data)
+  {
+    Observer*                               observer = &static_cast<Framework*>(data)->mObserver;
+    int                                     status   = *static_cast<int*>(event->value);
+    Dali::DeviceStatus::Orientation::Status result   = Dali::DeviceStatus::Orientation::Status::ORIENTATION_0;
+
+    switch(status)
+    {
+      case APP_DEVICE_ORIENTATION_0:
+      {
+        result = Dali::DeviceStatus::Orientation::Status::ORIENTATION_0;
+        break;
+      }
+      case APP_DEVICE_ORIENTATION_90:
+      {
+        result = Dali::DeviceStatus::Orientation::Status::ORIENTATION_90;
+        break;
+      }
+      case APP_DEVICE_ORIENTATION_180:
+      {
+        result = Dali::DeviceStatus::Orientation::Status::ORIENTATION_180;
+        break;
+      }
+      case APP_DEVICE_ORIENTATION_270:
+      {
+        result = Dali::DeviceStatus::Orientation::Status::ORIENTATION_270;
+        break;
+      }
+
+      default:
+        break;
+    }
+    observer->OnDeviceOrientationChanged(result);
+  }
+
   int AppNormalMain()
   {
     if(mUiAppContext.get() == nullptr)
@@ -1038,7 +1122,7 @@ struct Framework::Impl
 
     AppCore::AppAddEventHandler(&handlers[AppCore::LOW_BATTERY], AppCore::LOW_BATTERY, AppBatteryLow, mFramework);
     AppCore::AppAddEventHandler(&handlers[AppCore::LOW_MEMORY], AppCore::LOW_MEMORY, AppMemoryLow, mFramework);
-    AppCore::AppAddEventHandler(&handlers[AppCore::DEVICE_ORIENTATION_CHANGED], AppCore::DEVICE_ORIENTATION_CHANGED, AppDeviceRotated, mFramework);
+    AppCore::AppAddEventHandler(&handlers[AppCore::DEVICE_ORIENTATION_CHANGED], AppCore::DEVICE_ORIENTATION_CHANGED, AppDeviceOrientationChanged, mFramework);
     AppCore::AppAddEventHandler(&handlers[AppCore::LANGUAGE_CHANGED], AppCore::LANGUAGE_CHANGED, AppLanguageChanged, mFramework);
     AppCore::AppAddEventHandler(&handlers[AppCore::REGION_FORMAT_CHANGED], AppCore::REGION_FORMAT_CHANGED, AppRegionChanged, mFramework);
 
index e4c2cd5..519aeef 100644 (file)
@@ -93,6 +93,7 @@ Window::Window()
   mKeyboardRepeatSettingsChangedSignal(),
   mAuxiliaryMessageSignal(),
   mMovedSignal(),
+  mOrientationChangedSignal(),
   mLastKeyEvent(),
   mLastTouchEvent(),
   mIsTransparent(false),
@@ -1014,6 +1015,7 @@ void Window::OnRotation(const RotationEvent& rotation)
 
   Dali::Window handle(this);
   mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
+  mOrientationChangedSignal.Emit(handle, GetCurrentOrientation());
 
   mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
 }
index eb3aac6..d04e438 100644 (file)
@@ -68,6 +68,7 @@ public:
   typedef Dali::DevelWindow::AuxiliaryMessageSignalType              AuxiliaryMessageSignalType;
   typedef Dali::DevelWindow::AccessibilityHighlightSignalType        AccessibilityHighlightSignalType;
   typedef Dali::DevelWindow::MovedSignalType                         MovedSignalType;
+  typedef Dali::DevelWindow::OrientationChangedSignalType            OrientationChangedSignalType;
   typedef Signal<void()>                                             SignalType;
 
   /**
@@ -744,6 +745,14 @@ public: // Signals
     return mMovedSignal;
   }
 
+  /**
+   * @copydoc Dali::DevelWindow::OrientationChangedSignal()
+   */
+  OrientationChangedSignalType& OrientationChangedSignal()
+  {
+    return mOrientationChangedSignal;
+  }
+
 private:
   WindowRenderSurface* mWindowSurface; ///< The window rendering surface
   WindowBase*          mWindowBase;
@@ -773,6 +782,7 @@ private:
   AuxiliaryMessageSignalType              mAuxiliaryMessageSignal;
   AccessibilityHighlightSignalType        mAccessibilityHighlightSignal;
   MovedSignalType                         mMovedSignal;
+  OrientationChangedSignalType            mOrientationChangedSignal;
 
   Dali::KeyEvent   mLastKeyEvent;
   Dali::TouchEvent mLastTouchEvent;
index 20099eb..5daf923 100644 (file)
@@ -254,6 +254,11 @@ Application::LowMemorySignalType& Application::LowMemorySignal()
   return Internal::Adaptor::GetImplementation(*this).LowMemorySignal();
 }
 
+Application::DeviceOrientationChangedSignalType& Application::DeviceOrientationChangedSignal()
+{
+  return Internal::Adaptor::GetImplementation(*this).DeviceOrientationChangedSignal();
+}
+
 Application::AppSignalType& Application::TaskInitSignal()
 {
   return Internal::Adaptor::GetImplementation(*this).TaskInitSignal();
@@ -289,6 +294,11 @@ Application::LowMemorySignalType& Application::TaskLowMemorySignal()
   return Internal::Adaptor::GetImplementation(*this).TaskLowMemorySignal();
 }
 
+Application::DeviceOrientationChangedSignalType& Application::TaskDeviceOrientationChangedSignal()
+{
+  return Internal::Adaptor::GetImplementation(*this).TaskDeviceOrientationChangedSignal();
+}
+
 Application::Application(Internal::Adaptor::Application* application)
 : BaseHandle(application)
 {
index 4861e71..25ce168 100644 (file)
@@ -121,10 +121,11 @@ class Application;
 class DALI_ADAPTOR_API Application : public BaseHandle
 {
 public:
-  typedef Signal<void(DeviceStatus::Battery::Status)> LowBatterySignalType; ///< Application device signal type @SINCE_1_2.62
-  typedef Signal<void(DeviceStatus::Memory::Status)>  LowMemorySignalType;  ///< Application device signal type @SINCE_1_2.62
-  typedef Signal<void(Application&)>                  AppSignalType;        ///< Application lifecycle signal and system signal callback type @SINCE_1_0.0
-  typedef Signal<void(Application&, void*)>           AppControlSignalType; ///< Application control signal callback type @SINCE_1_0.0
+  typedef Signal<void(DeviceStatus::Battery::Status)>     LowBatterySignalType;               ///< Application device signal type @SINCE_1_2.62
+  typedef Signal<void(DeviceStatus::Memory::Status)>      LowMemorySignalType;                ///< Application device signal type @SINCE_1_2.62
+  typedef Signal<void(DeviceStatus::Orientation::Status)> DeviceOrientationChangedSignalType; ///< Application device orientation changed signal type @SINCE_2_2.1
+  typedef Signal<void(Application&)>                      AppSignalType;                      ///< Application lifecycle signal and system signal callback type @SINCE_1_0.0
+  typedef Signal<void(Application&, void*)>               AppControlSignalType;               ///< Application control signal callback type @SINCE_1_0.0
 
   /**
    * @brief Enumeration for deciding whether a Dali application window is opaque or transparent.
@@ -357,7 +358,7 @@ public: // Signals
   /**
    * @brief The user should connect to this signal to determine when they should initialize
    * their application.
-   * Only when the user uses the UiThread, this signal is emitted on the UI thread.
+   * Only when the user uses the UI thread, this signal is emitted on the UI thread.
    * Otherwise, it is emitted on the main thread.
    * @SINCE_1_0.0
    * @return The signal to connect to
@@ -367,7 +368,7 @@ public: // Signals
   /**
    * @brief The user should connect to this signal to determine when they should terminate
    * their application.
-   * Only when the user uses the UiThread, this signal is emitted on the UI thread.
+   * Only when the user uses the UI thread, this signal is emitted on the UI thread.
    * Otherwise, it is emitted on the main thread.
    * @SINCE_1_0.0
    * @return The signal to connect to
@@ -377,7 +378,7 @@ public: // Signals
   /**
    * @brief The user should connect to this signal if they need to perform any special
    * activities when the application is about to be paused.
-   * Only when the user uses the UiThread, this signal is emitted on the UI thread.
+   * Only when the user uses the UI thread, this signal is emitted on the UI thread.
    * Otherwise, it is emitted on the main thread.
    * @SINCE_1_0.0
    * @return The signal to connect to
@@ -387,7 +388,7 @@ public: // Signals
   /**
    * @brief The user should connect to this signal if they need to perform any special
    * activities when the application has resumed.
-   * Only when the user uses the UiThread, this signal is emitted on the UI thread.
+   * Only when the user uses the UI thread, this signal is emitted on the UI thread.
    * Otherwise, it is emitted on the main thread.
    * @SINCE_1_0.0
    * @return The signal to connect to
@@ -396,7 +397,7 @@ public: // Signals
 
   /**
    * @brief This signal is sent when the system requires the user to reinitialize itself.
-   * Only when the user uses the UiThread, this signal is emitted on the UI thread.
+   * Only when the user uses the UI thread, this signal is emitted on the UI thread.
    * Otherwise, it is emitted on the main thread.
    * @SINCE_1_0.0
    * @return The signal to connect to
@@ -408,7 +409,7 @@ public: // Signals
    *
    * When the application is launched, this signal is emitted after the main loop of the application starts up.
    * The passed parameter describes the launch request and contains the information about why the application is launched.
-   * Only when the user uses the UiThread, this signal is emitted on the UI thread.
+   * Only when the user uses the UI thread, this signal is emitted on the UI thread.
    * Otherwise, it is emitted on the main thread.
    * @SINCE_1_0.0
    * @return The signal to connect to
@@ -417,7 +418,7 @@ public: // Signals
 
   /**
    * @brief This signal is emitted when the language is changed on the device.
-   * Only when the user uses the UiThread, this signal is emitted on the UI thread.
+   * Only when the user uses the UI thread, this signal is emitted on the UI thread.
    * Otherwise, it is emitted on the main thread.
    * @SINCE_1_0.0
    * @return The signal to connect to
@@ -426,7 +427,7 @@ public: // Signals
 
   /**
    * @brief This signal is emitted when the region of the device is changed.
-   * Only when the user uses the UiThread, this signal is emitted on the UI thread.
+   * Only when the user uses the UI thread, this signal is emitted on the UI thread.
    * Otherwise, it is emitted on the main thread.
    * @SINCE_1_0.0
    * @return The signal to connect to
@@ -435,7 +436,7 @@ public: // Signals
 
   /**
    * @brief This signal is emitted when the battery level of the device is low.
-   * Only when the user uses the UiThread, this signal is emitted on the UI thread.
+   * Only when the user uses the UI thread, this signal is emitted on the UI thread.
    * Otherwise, it is emitted on the main thread.
    * @SINCE_1_2.62
    * @return The signal to connect to
@@ -444,18 +445,29 @@ public: // Signals
 
   /**
    * @brief This signal is emitted when the memory level of the device is low.
-   * Only when the user uses the UiThread, this signal is emitted on the UI thread.
+   * Only when the user uses the UI thread, this signal is emitted on the UI thread.
    * Otherwise, it is emitted on the main thread.
    * @SINCE_1_2.62
    * @return The signal to connect to
    */
   LowMemorySignalType& LowMemorySignal();
 
+  /**
+   * @brief This signal is emitted when the device orientation is changed
+   * Only when the user uses the UI thread, this signal is emitted on the UI thread.
+   * Otherwise, it is emitted on the main thread.
+   *
+   * This signal is only used in Application, it is different to Window's orientation signal.
+   * @SINCE_2_2.1
+   * @return The signal to connect to
+   */
+  DeviceOrientationChangedSignalType& DeviceOrientationChangedSignal();
+
   // TaskSignal
   /**
    * @brief The user should connect to this signal to determine when they should initialize
    * their application.
-   * Only when the user uses the UiThread, this signal is emitted on the main thread.
+   * Only when the user uses the UI thread, this signal is emitted on the main thread.
    * Otherwise, it is not emitted at all.
    * @return The signal to connect to
    */
@@ -464,7 +476,7 @@ public: // Signals
   /**
    * @brief The user should connect to this signal to determine when they should terminate
    * their application.
-   * Only when the user uses the UiThread, this signal is emitted on the main thread.
+   * Only when the user uses the UI thread, this signal is emitted on the main thread.
    * Otherwise, it is not emitted at all.
    * @return The signal to connect to
    */
@@ -475,7 +487,7 @@ public: // Signals
    *
    * When the application is launched, this signal is emitted after the main loop of the application starts up.
    * The passed parameter describes the launch request and contains the information about why the application is launched.
-   * Only when the user uses the UiThread, this signal is emitted on the main thread.
+   * Only when the user uses the UI thread, this signal is emitted on the main thread.
    * Otherwise, it is not emitted at all.
    * @return The signal to connect to
    */
@@ -483,7 +495,7 @@ public: // Signals
 
   /**
    * @brief This signal is emitted when the language is changed on the device.
-   * Only when the user uses the UiThread, this signal is emitted on the main thread.
+   * Only when the user uses the UI thread, this signal is emitted on the main thread.
    * Otherwise, it is not emitted at all.
    * @return The signal to connect to
    */
@@ -491,7 +503,7 @@ public: // Signals
 
   /**
    * @brief This signal is emitted when the region of the device is changed.
-   * Only when the user uses the UiThread, this signal is emitted on the main thread.
+   * Only when the user uses the UI thread, this signal is emitted on the main thread.
    * Otherwise, it is not emitted at all.
    * @return The signal to connect to
    */
@@ -499,7 +511,7 @@ public: // Signals
 
   /**
    * @brief This signal is emitted when the battery level of the device is low.
-   * Only when the user uses the UiThread, this signal is emitted on the main thread.
+   * Only when the user uses the UI thread, this signal is emitted on the main thread.
    * Otherwise, it is not emitted at all.
    * @return The signal to connect to
    */
@@ -507,11 +519,20 @@ public: // Signals
 
   /**
    * @brief This signal is emitted when the memory level of the device is low.
-   * Only when the user uses the UiThread, this signal is emitted on the main thread.
+   * Only when the user uses the UI thread, this signal is emitted on the main thread.
+   * Otherwise, it is not emitted at all.
+   * @return The signal to connect to
+   */
+  LowMemorySignalType& TaskLowMemorySignal();
+
+  /**
+   * @brief This signal is emitted when the device orientation is changed.
+   * Only when the user uses the UI thread, this signal is emitted on the main thread.
    * Otherwise, it is not emitted at all.
+   * @SINCE_2_2.1
    * @return The signal to connect to
    */
-  LowMemorySignalType&  TaskLowMemorySignal();
+  DeviceOrientationChangedSignalType& TaskDeviceOrientationChangedSignal();
 
 public: // Not intended for application developers
   /// @cond internal
index 6c38a18..6daa76d 100644 (file)
@@ -63,6 +63,25 @@ struct Memory
   };
 };
 
+/**
+ * @brief Struct for orientation of the device.
+ * @SINCE_2_2.1
+ */
+struct Orientation
+{
+  /**
+   * @brief Enumeration for orientation status.
+   * @SINCE_2_2.1
+   */
+  enum Status
+  {
+    ORIENTATION_0 = 0,       ///< The device is oriented in a natural position @SINCE_2_2.1
+    ORIENTATION_90 = 90,     ///< The device's left side is at the top @SINCE_2_2.1
+    ORIENTATION_180 = 180,   ///< The device is upside down @SINCE_2_2.1
+    ORIENTATION_270 = 270    ///< The device's right side is at the top @SINCE_2_2.1
+  };
+};
+
 } // namespace DeviceStatus
 
 /**