[dali_2.3.24] Merge branch 'devel/master'
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / application-devel.h
1 #ifndef DALI_APPLICATION_DEVEL_H
2 #define DALI_APPLICATION_DEVEL_H
3
4 /*
5  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/adaptor-framework/application.h>
23 #include <dali/public-api/dali-adaptor-common.h>
24
25 // EXTERNAL INCLUDES
26 #include <dali/public-api/signals/dali-signal.h>
27
28 namespace Dali
29 {
30 namespace DevelApplication
31 {
32 using CustomCommandReceivedSignalType = Signal<void(const std::string&)>; ///< Signal signature for CustomCommandReceivedSignal
33
34 /**
35    * @brief This is the constructor for applications.
36    * Especially, it is for keyboard application.
37    * If you want to create Ime window, use this API with WindowType::IME.
38    *
39    * @param[in,out]  argc                A pointer to the number of arguments
40    * @param[in,out]  argv                A pointer to the argument list
41    * @param[in]      stylesheet          The path to user defined theme file
42    * @param[in]      windowMode          A member of WINDOW_MODE
43    * @param[in]      positionSize        A position and a size of the window
44    * @param[in]      type                It is window type for default window.
45    * @return A handle to the Application
46    * @note If the stylesheet is not specified, then the library's default stylesheet will not be overridden.
47    */
48 DALI_ADAPTOR_API Application New(int* argc, char** argv[], const std::string& stylesheet, Application::WINDOW_MODE windowMode, PositionSize positionSize, WindowType type);
49
50 /**
51  * @brief Ensures that the function passed in is called from the main loop when it is idle.
52  * @param[in] application A handle to the Application
53  * @param[in] callback The function to call
54  * @return @c true if added successfully, @c false otherwise
55  *
56  * @note Function must be called from main event thread only
57  *
58  * A callback of the following type should be used:
59  * @code
60  *   bool MyFunction();
61  * @endcode
62  * This callback will be called repeatedly as long as it returns true. A return of 0 deletes this callback.
63  *
64  * @note Ownership of the callback is passed onto this class.
65  */
66 DALI_ADAPTOR_API bool AddIdleWithReturnValue(Application application, CallbackBase* callback);
67
68 /**
69 * @brief Gets the absolute path to the application's data directory which is used to store private data of the application.
70 * @return The absolute path to the application's data directory
71 */
72 DALI_ADAPTOR_API std::string GetDataPath();
73
74 /**
75  * @brief Downcasts a ref object to Application handle
76  *
77  * If handle points to an Application object, the downcast produces valid base handle
78  * If not, the returned base handle is left uninitialized
79  *
80  * @param[in] refObject to an Application
81  * @return handle to an Application object or an uninitialized base handle
82  */
83 DALI_ADAPTOR_API Application DownCast(Dali::RefObject* refObject);
84
85 /**
86  * @brief This signal will be triggered when a custom command is received.
87  *
88  * For this signal to be triggered, the adaptor must be built with -DENABLE_NETWORK_LOGGING=ON
89  * and when running, DALI_NETWORK_CONTROL=1 must also be set.
90  *
91  * A callback of the following type may be connected:
92  * @code
93  *   void YourCallbackName(const std::string&);
94  * @endcode
95  *
96  * @param[in] application A handle to the Application
97  * @return The signal when a custom command is received
98  */
99 DALI_ADAPTOR_API CustomCommandReceivedSignalType& CustomCommandReceivedSignal(Application application);
100
101 /**
102  * @brief Gets the render thread id of DALi.
103  * @note If render thread id getter doesn't supported, it will return 0 as default.
104  * @param application A handle to the Application
105  * @return The render thread id.
106  */
107 DALI_ADAPTOR_API int32_t GetRenderThreadId(Application application);
108
109 /**
110  * @brief Relayout the application and ensure all pending operations are flushed to the update thread.
111  * @param application A handle to the Application
112  */
113 DALI_ADAPTOR_API void FlushUpdateMessages(Application application);
114
115 } // namespace DevelApplication
116
117 } // namespace Dali
118
119 /**
120  * @brief This is used to improve application launch performance.
121  * Initializes some functions in advance and makes a window in advance.
122  * @param[in,out]  argc A pointer to the number of arguments
123  * @param[in,out]  argv A pointer to the argument list
124  *
125  * @note Declared in C style for calling from app-launcher.
126  *
127  */
128 extern "C" DALI_ADAPTOR_API void ApplicationPreInitialize(int* argc, char** argv[]);
129
130 #endif // DALI_APPLICATION_DEVEL_H