Support int uniform in shader
[platform/core/uifw/dali-adaptor.git] / dali / public-api / adaptor-framework / application.cpp
1 /*
2  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/public-api/adaptor-framework/application.h>
20
21 // EXTERNAL INCLUDES
22 #include <dali/integration-api/debug.h>
23 #include <dali/public-api/object/object-registry.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/internal/adaptor/common/application-impl.h>
27
28 namespace Dali
29 {
30 Application Application::New()
31 {
32   return New(NULL, NULL);
33 }
34
35 Application Application::New(int* argc, char** argv[])
36 {
37   Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
38   if(internal)
39   {
40     // pre-initialized application
41     internal->SetCommandLineOptions(argc, argv);
42   }
43   else
44   {
45     internal = Internal::Adaptor::Application::New(argc, argv, "", OPAQUE, PositionSize(), Internal::Adaptor::Framework::NORMAL, WindowType::NORMAL, false);
46   }
47   return Application(internal.Get());
48 }
49
50 Application Application::New(int* argc, char** argv[], const std::string& stylesheet)
51 {
52   Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
53   if(internal)
54   {
55     // pre-initialized application
56     internal->SetCommandLineOptions(argc, argv);
57     internal->SetStyleSheet(stylesheet);
58   }
59   else
60   {
61     internal = Internal::Adaptor::Application::New(argc, argv, stylesheet, OPAQUE, PositionSize(), Internal::Adaptor::Framework::NORMAL, WindowType::NORMAL, false);
62   }
63   return Application(internal.Get());
64 }
65
66 Application Application::New(int* argc, char** argv[], const std::string& stylesheet, WINDOW_MODE windowMode)
67 {
68   Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
69   if(internal)
70   {
71     // pre-initialized application
72     internal->SetCommandLineOptions(argc, argv);
73     internal->SetStyleSheet(stylesheet);
74
75     internal->GetWindow().SetTransparency((windowMode == Application::OPAQUE ? false : true));
76   }
77   else
78   {
79     internal = Internal::Adaptor::Application::New(argc, argv, stylesheet, windowMode, PositionSize(), Internal::Adaptor::Framework::NORMAL, WindowType::NORMAL, false);
80   }
81   return Application(internal.Get());
82 }
83
84 Application Application::New(int* argc, char** argv[], const std::string& stylesheet, Application::WINDOW_MODE windowMode, PositionSize positionSize)
85 {
86   Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
87   if(internal)
88   {
89     // pre-initialized application
90     internal->SetCommandLineOptions(argc, argv);
91     internal->SetStyleSheet(stylesheet);
92
93     internal->GetWindow().SetTransparency((windowMode == Application::OPAQUE ? false : true));
94
95     //Store only the value before adaptor is created
96     internal->StoreWindowPositionSize(positionSize);
97   }
98   else
99   {
100     internal = Internal::Adaptor::Application::New(argc, argv, stylesheet, windowMode, positionSize, Internal::Adaptor::Framework::NORMAL, WindowType::NORMAL, false);
101   }
102   return Application(internal.Get());
103 }
104
105 Application Application::New(int* argc, char** argv[], const std::string& stylesheet, Application::WINDOW_MODE windowMode, PositionSize positionSize, bool useUiThread)
106 {
107   Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
108   if(internal)
109   {
110     // pre-initialized application
111     internal->SetCommandLineOptions(argc, argv);
112     internal->SetStyleSheet(stylesheet);
113
114     internal->GetWindow().SetTransparency((windowMode == Application::OPAQUE ? false : true));
115
116     //Store only the value before adaptor is created
117     internal->StoreWindowPositionSize(positionSize);
118   }
119   else
120   {
121     internal = Internal::Adaptor::Application::New(argc, argv, stylesheet, windowMode, positionSize, Internal::Adaptor::Framework::NORMAL, WindowType::NORMAL, useUiThread);
122   }
123   return Application(internal.Get());
124 }
125
126 Application Application::New(int* argc, char** argv[], const std::string& stylesheet, bool useUiThread, WindowData& windowData)
127 {
128   Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
129   if(internal)
130   {
131     // pre-initialized application
132     internal->SetCommandLineOptions(argc, argv);
133     internal->SetStyleSheet(stylesheet);
134
135     // Set defaut Window type
136     internal->SetDefaultWindowType(windowData.GetWindowType());
137     internal->GetWindow().SetTransparency(windowData.GetTransparency());
138
139     // Store only the value before adaptor is created
140     internal->StoreWindowPositionSize(windowData.GetPositionSize());
141   }
142   else
143   {
144     // clang-format off
145     internal = Internal::Adaptor::Application::New(argc, argv, stylesheet,
146                   windowData.GetTransparency() ? WINDOW_MODE::TRANSPARENT : WINDOW_MODE::OPAQUE,
147                   windowData.GetPositionSize(), Internal::Adaptor::Framework::NORMAL,
148                   windowData.GetWindowType(), useUiThread);
149     // clang-format on
150   }
151   return Application(internal.Get());
152 }
153
154 Application::~Application()
155 {
156 }
157
158 Application::Application()
159 {
160 }
161
162 Application::Application(const Application& copy) = default;
163
164 Application& Application::operator=(const Application& rhs) = default;
165
166 Application::Application(Application&& rhs) noexcept = default;
167
168 Application& Application::operator=(Application&& rhs) noexcept = default;
169
170 void Application::MainLoop()
171 {
172   Internal::Adaptor::GetImplementation(*this).MainLoop();
173 }
174
175 void Application::Lower()
176 {
177   Internal::Adaptor::GetImplementation(*this).Lower();
178 }
179
180 void Application::Quit()
181 {
182   Internal::Adaptor::GetImplementation(*this).Quit();
183 }
184
185 bool Application::AddIdle(CallbackBase* callback)
186 {
187   return Internal::Adaptor::GetImplementation(*this).AddIdle(callback, false);
188 }
189
190 Window Application::GetWindow()
191 {
192   return Internal::Adaptor::GetImplementation(*this).GetWindow();
193 }
194
195 std::string Application::GetResourcePath()
196 {
197   return Internal::Adaptor::Application::GetResourcePath();
198 }
199
200 std::string Application::GetRegion() const
201 {
202   return Internal::Adaptor::GetImplementation(*this).GetRegion();
203 }
204
205 std::string Application::GetLanguage() const
206 {
207   return Internal::Adaptor::GetImplementation(*this).GetLanguage();
208 }
209
210 ObjectRegistry Application::GetObjectRegistry() const
211 {
212   return Internal::Adaptor::GetImplementation(*this).GetObjectRegistry();
213 }
214
215 Application::AppSignalType& Application::InitSignal()
216 {
217   return Internal::Adaptor::GetImplementation(*this).InitSignal();
218 }
219
220 Application::AppSignalType& Application::TerminateSignal()
221 {
222   return Internal::Adaptor::GetImplementation(*this).TerminateSignal();
223 }
224
225 Application::AppSignalType& Application::PauseSignal()
226 {
227   return Internal::Adaptor::GetImplementation(*this).PauseSignal();
228 }
229
230 Application::AppSignalType& Application::ResumeSignal()
231 {
232   return Internal::Adaptor::GetImplementation(*this).ResumeSignal();
233 }
234
235 Application::AppSignalType& Application::ResetSignal()
236 {
237   return Internal::Adaptor::GetImplementation(*this).ResetSignal();
238 }
239
240 Application::AppControlSignalType& Application::AppControlSignal()
241 {
242   return Internal::Adaptor::GetImplementation(*this).AppControlSignal();
243 }
244
245 Application::AppSignalType& Application::LanguageChangedSignal()
246 {
247   return Internal::Adaptor::GetImplementation(*this).LanguageChangedSignal();
248 }
249
250 Application::AppSignalType& Application::RegionChangedSignal()
251 {
252   return Internal::Adaptor::GetImplementation(*this).RegionChangedSignal();
253 }
254
255 Application::LowBatterySignalType& Application::LowBatterySignal()
256 {
257   return Internal::Adaptor::GetImplementation(*this).LowBatterySignal();
258 }
259
260 Application::LowMemorySignalType& Application::LowMemorySignal()
261 {
262   return Internal::Adaptor::GetImplementation(*this).LowMemorySignal();
263 }
264
265 Application::DeviceOrientationChangedSignalType& Application::DeviceOrientationChangedSignal()
266 {
267   return Internal::Adaptor::GetImplementation(*this).DeviceOrientationChangedSignal();
268 }
269
270 Application::AppSignalType& Application::TaskInitSignal()
271 {
272   return Internal::Adaptor::GetImplementation(*this).TaskInitSignal();
273 }
274
275 Application::AppSignalType& Application::TaskTerminateSignal()
276 {
277   return Internal::Adaptor::GetImplementation(*this).TaskTerminateSignal();
278 }
279
280 Application::AppControlSignalType& Application::TaskAppControlSignal()
281 {
282   return Internal::Adaptor::GetImplementation(*this).TaskAppControlSignal();
283 }
284
285 Application::AppSignalType& Application::TaskLanguageChangedSignal()
286 {
287   return Internal::Adaptor::GetImplementation(*this).TaskLanguageChangedSignal();
288 }
289
290 Application::AppSignalType& Application::TaskRegionChangedSignal()
291 {
292   return Internal::Adaptor::GetImplementation(*this).TaskRegionChangedSignal();
293 }
294
295 Application::LowBatterySignalType& Application::TaskLowBatterySignal()
296 {
297   return Internal::Adaptor::GetImplementation(*this).TaskLowBatterySignal();
298 }
299
300 Application::LowMemorySignalType& Application::TaskLowMemorySignal()
301 {
302   return Internal::Adaptor::GetImplementation(*this).TaskLowMemorySignal();
303 }
304
305 Application::DeviceOrientationChangedSignalType& Application::TaskDeviceOrientationChangedSignal()
306 {
307   return Internal::Adaptor::GetImplementation(*this).TaskDeviceOrientationChangedSignal();
308 }
309
310 Application::Application(Internal::Adaptor::Application* application)
311 : BaseHandle(application)
312 {
313 }
314
315 } // namespace Dali