[Tizen] Support Device orientation and window orientation event.
[platform/core/uifw/dali-adaptor.git] / dali / internal / adaptor / common / framework.h
index 5ab74ac..cf8760f 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_FRAMEWORK_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
@@ -28,6 +28,7 @@
 // INTERNAL INCLUDES
 #include <dali/internal/system/common/abort-handler.h>
 #include <dali/public-api/adaptor-framework/device-status.h>
+
 #ifdef COMPONENT_APPLICATION_SUPPORT
 #include <dali/devel-api/adaptor-framework/component-application.h>
 #endif
@@ -59,6 +60,8 @@ public:
 
   /**
    * Observer class for the framework.
+   * @brief When the UI thread is enabled, the events are emitted on the UI thread.
+   * When it is disabled, the events are emitted on the main thread.
    */
   class Observer
   {
@@ -99,9 +102,9 @@ public:
     }
 
     /**
-    * Invoked when the AppControl message is received.
-    * @param[in] The bundle data of AppControl message.
-    */
+     * Invoked when the AppControl message is received.
+     * @param[in] The bundle data of AppControl message.
+     */
     virtual void OnAppControl(void*)
     {
     }
@@ -158,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)
@@ -182,15 +192,86 @@ public:
 #endif
   };
 
+  /**
+   * TaskObserver class for the framework.
+   * @brief This is used only when UiThread is enabled. the events are emitted on the main thread.
+   */
+  class TaskObserver
+  {
+  public:
+    /**
+     * Invoked when the application is to be initialised.
+     */
+    virtual void OnTaskInit()
+    {
+    }
+
+    /**
+     * Invoked when the application is to be terminated.
+     */
+    virtual void OnTaskTerminate()
+    {
+    }
+
+    /**
+     * Invoked when the AppControl message is received.
+     * @param[in] The bundle data of AppControl message.
+     */
+    virtual void OnTaskAppControl(void*)
+    {
+    }
+
+    /**
+     * Invoked when the language of the device is changed.
+     */
+    virtual void OnTaskLanguageChanged()
+    {
+    }
+
+    /**
+     * Invoked when the region is changed.
+     */
+    virtual void OnTaskRegionChanged()
+    {
+    }
+
+    /**
+     * Invoked when the battery level of the device is low.
+     */
+    virtual void OnTaskBatteryLow(Dali::DeviceStatus::Battery::Status status)
+    {
+    }
+
+    /**
+     * Invoked when the memory level of the device is low.
+     */
+    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:
   /**
    * Constructor
-   * @param[in]  observer  The observer of the Framework.
-   * @param[in]  argc      A pointer to the number of arguments.
-   * @param[in]  argv      A pointer the the argument list.
-   * @param[in]  type      The type of application
+   * @param[in]  observer      The observer of the Framework.
+   * @param[in]  taskObserver  The task observer of the Framework.
+   * @param[in]  argc          A pointer to the number of arguments.
+   * @param[in]  argv          A pointer the the argument list.
+   * @param[in]  type          The type of application
+   * @param[in]  useUiThread   True if the application would create a UI thread
    */
-  Framework(Observer& observer, int* argc, char*** argv, Type type = NORMAL);
+  Framework(Observer& observer, TaskObserver& taskObserver, int* argc, char*** argv, Type type, bool useUiThread);
 
   /**
    * Destructor
@@ -328,15 +409,16 @@ private:
   void InitThreads();
 
 private:
-  Observer&    mObserver;
-  bool         mInitialised;
-  bool         mPaused;
-  bool         mRunning;
-  int*         mArgc;
-  char***      mArgv;
-  std::string  mBundleName;
-  std::string  mBundleId;
-  AbortHandler mAbortHandler;
+  Observer&     mObserver;
+  TaskObserver& mTaskObserver;
+  bool          mInitialised;
+  bool          mPaused;
+  bool          mRunning;
+  int*          mArgc;
+  char***       mArgv;
+  std::string   mBundleName;
+  std::string   mBundleId;
+  AbortHandler  mAbortHandler;
 
 private: // impl members
   struct Impl;