#define DALI_APPLICATION_H
/*
- * Copyright (c) 2020 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.
#include <dali/public-api/signals/callback.h>
// INTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/application-configuration.h>
#include <dali/public-api/adaptor-framework/device-status.h>
#include <dali/public-api/adaptor-framework/window.h>
namespace Dali
{
-
class ObjectRegistry;
/**
{
class Application;
}
-}
+} // namespace DALI_INTERNAL
/**
* @brief An Application class object should be created by every application
* that wishes to use Dali.
* app.ResumeSignal().Connect(&app, &MyApplication::Resume);
* @endcode
*
+ *
+ * #### UI thread
+ * There is the UI thread feature.
+ * UI thread is an additional thread that an Application object creates. The thread is for UI events.
+ *
+ * When the UI thread feature is enabled, you can use the task signals(TaskInit, TaskTerminate, TaskAppControl, TaskLanguageChanged, TaskLowBattery, and TaskLowMemory).
+ * The task signals are emitted on the main thread,
+ * and the normal signals(Init, Terminate, Pause, Resume, Reset, AppControl, LanguageChanged, Region, LowBattery, and LowMemory) are emitted on the UI thread.
+ *
+ * If you want to handle windows or actors in cases like when the memory level of the device is low, you have to use the normal signals, not the task signals.
+ * Callbacks of all signals in DALi except the task signals are emitted on the UI thread. (e.g., Timer callbacks are emitted on the UI thread.)
+ *
+ * To enable the UI Thread, you can use this method. you have to set True to the useUiThread.
+ * Dali::Application::New(int *argc, char **argv[], const std::string &stylesheet, Application::WINDOW_MODE windowMode, PositionSize positionSize, bool useUiThread)
+ *
+ *
* This class accepts command line arguments as well. The following options are supported:
*
* @code
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(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.
*/
enum WINDOW_MODE
{
- OPAQUE = 0, ///< The window will be opaque @SINCE_1_0.0
- TRANSPARENT = 1 ///< The window transparency will match the alpha value set in Dali::Stage::SetBackgroundcolor() @SINCE_1_0.0
+ OPAQUE = 0, ///< The window will be opaque @SINCE_1_0.0
+ TRANSPARENT = 1 ///< The window transparency will match the alpha value set in Dali::Stage::SetBackgroundcolor() @SINCE_1_0.0
};
public:
-
/**
* @brief This is the constructor for applications without an argument list.
* @SINCE_1_0.0
* @param[in,out] argv A pointer to the argument list
* @return A handle to the Application
*/
- static Application New( int* argc, char **argv[] );
+ static Application New(int* argc, char** argv[]);
/**
* @brief This is the constructor for applications with a name.
* @return A handle to the Application
* @note If the stylesheet is not specified, then the library's default stylesheet will not be overridden.
*/
- static Application New( int* argc, char **argv[], const std::string& stylesheet );
+ static Application New(int* argc, char** argv[], const std::string& stylesheet);
/**
* @brief This is the constructor for applications with a name.
* @return A handle to the Application
* @note If the stylesheet is not specified, then the library's default stylesheet will not be overridden.
*/
- static Application New( int* argc, char **argv[], const std::string& stylesheet, WINDOW_MODE windowMode );
+ static Application New(int* argc, char** argv[], const std::string& stylesheet, WINDOW_MODE windowMode);
/**
* @brief This is the constructor for applications.
* @return A handle to the Application
* @note If the stylesheet is not specified, then the library's default stylesheet will not be overridden.
*/
- static Application New( int* argc, char **argv[], const std::string& stylesheet, Application::WINDOW_MODE windowMode, PositionSize positionSize );
+ static Application New(int* argc, char** argv[], const std::string& stylesheet, Application::WINDOW_MODE windowMode, PositionSize positionSize);
+
+ /**
+ * @brief This is the constructor for applications.
+ *
+ * @SINCE_2_1.20
+ * @PRIVLEVEL_PUBLIC
+ * @PRIVILEGE_DISPLAY
+ * @param[in,out] argc A pointer to the number of arguments
+ * @param[in,out] argv A pointer to the argument list
+ * @param[in] stylesheet The path to user defined theme file
+ * @param[in] windowMode A member of WINDOW_MODE
+ * @param[in] positionSize A position and a size of the window
+ * @param[in] useUiThread True if the application would create a UI thread
+ * @return A handle to the Application
+ * @note If the stylesheet is not specified, then the library's default stylesheet will not be overridden.<BR>
+ * UI thread is an additional thread that DALi creates for UI events.
+ * The UI thread isn't blocked from the system events(AppControl, LanguageChanged, RegionChanged, LowMemory, LowBattery task signals).
+ */
+ static Application New(int* argc, char** argv[], const std::string& stylesheet, Application::WINDOW_MODE windowMode, PositionSize positionSize, bool useUiThread);
/**
* @brief Constructs an empty handle.
* @SINCE_1_0.0
* @param[in] application Handle to an object
*/
- Application( const Application& application );
+ Application(const Application& application);
/**
* @brief Assignment operator.
* @param[in] application Handle to an object
* @return A reference to this
*/
- Application& operator=( const Application& application );
+ Application& operator=(const Application& application);
/**
* @brief Move constructor.
* @SINCE_1_9.24
* @param[in] rhs A reference to the moved handle
*/
- Application( Application&& rhs );
+ Application(Application&& rhs);
/**
* @brief Move assignment operator.
* @param[in] rhs A reference to the moved handle
* @return A reference to this handle
*/
- Application& operator=( Application&& rhs );
+ Application& operator=(Application&& rhs);
/**
* @brief Destructor.
/**
* @brief This starts the application.
*
- * Choosing this form of main loop indicates that the default
- * application configuration of APPLICATION_HANDLES_CONTEXT_LOSS is used. On platforms where
- * context loss can occur, the application is responsible for tearing down and re-loading UI.
- * The application should listen to Stage::ContextLostSignal and Stage::ContextRegainedSignal.
- * @SINCE_1_0.0
- */
- void MainLoop();
-
- /**
- * @brief This starts the application, and allows the app to choose a different configuration.
+ * On platforms where context loss can occur, the application is responsible for tearing down and
+ * re-loading UI. The application should listen to Stage::ContextLostSignal and
+ * Stage::ContextRegainedSignal.
*
- * The application should listen to Stage::ContextLostSignal and Stage::ContextRegainedSignal.
* @SINCE_1_0.0
- * @param[in] configuration The context loss configuration
*/
- void MainLoop(Configuration::ContextLoss configuration);
+ void MainLoop();
/**
* @brief This lowers the application to bottom without actually quitting it.
*
* @note Ownership of the callback is passed onto this class.
*/
- bool AddIdle( CallbackBase* callback );
+ bool AddIdle(CallbackBase* callback);
/**
* @brief Retrieves the main window used by the Application class.
*/
ObjectRegistry GetObjectRegistry() const;
-public: // Signals
-
+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.
+ * Otherwise, it is emitted on the main thread.
* @SINCE_1_0.0
* @return The signal to connect to
*/
/**
* @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.
+ * Otherwise, it is emitted on the main thread.
* @SINCE_1_0.0
* @return The signal to connect to
*/
/**
* @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.
+ * Otherwise, it is emitted on the main thread.
* @SINCE_1_0.0
* @return The signal to connect to
*/
/**
* @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.
+ * Otherwise, it is emitted on the main thread.
* @SINCE_1_0.0
* @return The signal to connect to
*/
/**
* @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.
+ * Otherwise, it is emitted on the main thread.
* @SINCE_1_0.0
* @return The signal to connect to
*/
AppSignalType& ResetSignal();
/**
- * @brief This signal is emitted when another application sends a launch request to the application.
- *
- * 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.
- * @SINCE_1_0.0
- * @return The signal to connect to
- */
+ * @brief This signal is emitted when another application sends a launch request to the application.
+ *
+ * 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.
+ * Otherwise, it is emitted on the main thread.
+ * @SINCE_1_0.0
+ * @return The signal to connect to
+ */
AppControlSignalType& AppControlSignal();
/**
* @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.
+ * Otherwise, it is emitted on the main thread.
* @SINCE_1_0.0
* @return The signal to connect to
*/
AppSignalType& LanguageChangedSignal();
/**
- * @brief This signal is emitted when the region of the device is changed.
- * @SINCE_1_0.0
- * @return The signal to connect to
- */
+ * @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.
+ * Otherwise, it is emitted on the main thread.
+ * @SINCE_1_0.0
+ * @return The signal to connect to
+ */
AppSignalType& RegionChangedSignal();
/**
* @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.
+ * Otherwise, it is emitted on the main thread.
* @SINCE_1_2.62
* @return The signal to connect to
*/
/**
* @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.
+ * Otherwise, it is emitted on the main thread.
* @SINCE_1_2.62
* @return The signal to connect to
*/
LowMemorySignalType& LowMemorySignal();
+ // 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.
+ * Otherwise, it is not emitted at all.
+ * @return The signal to connect to
+ */
+ AppSignalType& TaskInitSignal();
+
+ /**
+ * @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.
+ * Otherwise, it is not emitted at all.
+ * @return The signal to connect to
+ */
+ AppSignalType& TaskTerminateSignal();
+
+ /**
+ * @brief This signal is emitted when another application sends a launch request to the application.
+ *
+ * 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.
+ * Otherwise, it is not emitted at all.
+ * @return The signal to connect to
+ */
+ AppControlSignalType& TaskAppControlSignal();
+
+ /**
+ * @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.
+ * Otherwise, it is not emitted at all.
+ * @return The signal to connect to
+ */
+ AppSignalType& TaskLanguageChangedSignal();
+
+ /**
+ * @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.
+ * Otherwise, it is not emitted at all.
+ * @return The signal to connect to
+ */
+ AppSignalType& TaskRegionChangedSignal();
+
+ /**
+ * @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.
+ * Otherwise, it is not emitted at all.
+ * @return The signal to connect to
+ */
+ LowBatterySignalType& TaskLowBatterySignal();
+
+ /**
+ * @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.
+ * Otherwise, it is not emitted at all.
+ * @return The signal to connect to
+ */
+ LowMemorySignalType& TaskLowMemorySignal();
+
public: // Not intended for application developers
/// @cond internal
/**