Use WindowData in the constructors of Application and Window
[platform/core/uifw/dali-adaptor.git] / dali / public-api / adaptor-framework / window.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/window.h>
20
21 // EXTERNAL INCLUDES
22 #include <dali/integration-api/debug.h>
23 #include <dali/public-api/render-tasks/render-task-list.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/internal/window-system/common/orientation-impl.h>
27 #include <dali/internal/window-system/common/window-impl.h>
28 #include <dali/public-api/actors/actor.h>
29
30 namespace Dali
31 {
32 Window Window::New(PositionSize posSize, const std::string& name, bool isTransparent)
33 {
34   return Dali::Window::New(posSize, name, "", isTransparent);
35 }
36
37 Window Window::New(PositionSize posSize, const std::string& name, const std::string& className, bool isTransparent)
38 {
39   WindowData windowData;
40   windowData.SetPositionSize(posSize);
41   windowData.SetTransparency(isTransparent);
42   windowData.SetWindowType(WindowType::NORMAL);
43   return Dali::Window::New(name, "", windowData);
44 }
45
46 Window Window::New(const std::string& name, const std::string& className, const WindowData& windowData)
47 {
48   Window newWindow;
49
50   const bool isAdaptorAvailable = Dali::Adaptor::IsAvailable();
51   bool       isNewWindowAllowed = true;
52
53   if(isAdaptorAvailable)
54   {
55     Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get();
56     isNewWindowAllowed     = Internal::Adaptor::Adaptor::GetImplementation(adaptor).IsMultipleWindowSupported();
57   }
58
59   if(isNewWindowAllowed)
60   {
61     Internal::Adaptor::Window* window = Internal::Adaptor::Window::New(name, className, windowData);
62
63     Integration::SceneHolder sceneHolder = Integration::SceneHolder(window);
64
65     if(isAdaptorAvailable)
66     {
67       Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get();
68       Internal::Adaptor::Adaptor::GetImplementation(adaptor).AddWindow(sceneHolder);
69     }
70     newWindow = Window(window);
71   }
72   else
73   {
74     DALI_LOG_ERROR("This device can't support multiple windows.\n");
75   }
76
77   return newWindow;
78 }
79
80 Window::Window()
81 {
82 }
83
84 Window::~Window()
85 {
86 }
87
88 Window::Window(const Window& copy) = default;
89
90 Window& Window::operator=(const Window& rhs) = default;
91
92 Window::Window(Window&& rhs) noexcept = default;
93
94 Window& Window::operator=(Window&& rhs) noexcept = default;
95
96 Window Window::DownCast(BaseHandle handle)
97 {
98   return Window(dynamic_cast<Dali::Internal::Adaptor::Window*>(handle.GetObjectPtr()));
99 }
100
101 void Window::Add(Dali::Actor actor)
102 {
103   GetImplementation(*this).Add(actor);
104 }
105
106 void Window::Remove(Dali::Actor actor)
107 {
108   GetImplementation(*this).Remove(actor);
109 }
110
111 void Window::SetBackgroundColor(const Vector4& color)
112 {
113   GetImplementation(*this).SetBackgroundColor(color);
114 }
115
116 Vector4 Window::GetBackgroundColor() const
117 {
118   return GetImplementation(*this).GetBackgroundColor();
119 }
120
121 Layer Window::GetRootLayer() const
122 {
123   return GetImplementation(*this).GetRootLayer();
124 }
125
126 Layer Window::GetOverlayLayer()
127 {
128   return GetImplementation(*this).GetOverlayLayer();
129 }
130
131 uint32_t Window::GetLayerCount() const
132 {
133   return GetImplementation(*this).GetLayerCount();
134 }
135
136 Layer Window::GetLayer(uint32_t depth) const
137 {
138   return GetImplementation(*this).GetLayer(depth);
139 }
140
141 Uint16Pair Window::GetDpi() const
142 {
143   return GetImplementation(*this).GetDpi();
144 }
145
146 void Window::SetClass(std::string name, std::string klass)
147 {
148   GetImplementation(*this).SetClass(name, klass);
149 }
150
151 void Window::Raise()
152 {
153   GetImplementation(*this).Raise();
154 }
155
156 void Window::Lower()
157 {
158   GetImplementation(*this).Lower();
159 }
160
161 void Window::Activate()
162 {
163   GetImplementation(*this).Activate();
164 }
165
166 void Window::AddAvailableOrientation(WindowOrientation orientation)
167 {
168   GetImplementation(*this).AddAvailableOrientation(orientation);
169 }
170
171 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
172 {
173   GetImplementation(*this).RemoveAvailableOrientation(orientation);
174 }
175
176 void Window::SetPreferredOrientation(WindowOrientation orientation)
177 {
178   GetImplementation(*this).SetPreferredOrientation(orientation);
179 }
180
181 WindowOrientation Window::GetPreferredOrientation()
182 {
183   return GetImplementation(*this).GetPreferredOrientation();
184 }
185
186 Any Window::GetNativeHandle() const
187 {
188   return GetImplementation(*this).GetNativeHandle();
189 }
190
191 Window::FocusChangeSignalType& Window::FocusChangeSignal()
192 {
193   return GetImplementation(*this).FocusChangeSignal();
194 }
195
196 void Window::SetAcceptFocus(bool accept)
197 {
198   GetImplementation(*this).SetAcceptFocus(accept);
199 }
200
201 bool Window::IsFocusAcceptable() const
202 {
203   return GetImplementation(*this).IsFocusAcceptable();
204 }
205
206 void Window::Show()
207 {
208   GetImplementation(*this).Show();
209 }
210
211 void Window::Hide()
212 {
213   GetImplementation(*this).Hide();
214 }
215
216 bool Window::IsVisible() const
217 {
218   return GetImplementation(*this).IsVisible();
219 }
220
221 unsigned int Window::GetSupportedAuxiliaryHintCount() const
222 {
223   return GetImplementation(*this).GetSupportedAuxiliaryHintCount();
224 }
225
226 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
227 {
228   return GetImplementation(*this).GetSupportedAuxiliaryHint(index);
229 }
230
231 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
232 {
233   return GetImplementation(*this).AddAuxiliaryHint(hint, value);
234 }
235
236 bool Window::RemoveAuxiliaryHint(unsigned int id)
237 {
238   return GetImplementation(*this).RemoveAuxiliaryHint(id);
239 }
240
241 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
242 {
243   return GetImplementation(*this).SetAuxiliaryHintValue(id, value);
244 }
245
246 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
247 {
248   return GetImplementation(*this).GetAuxiliaryHintValue(id);
249 }
250
251 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
252 {
253   return GetImplementation(*this).GetAuxiliaryHintId(hint);
254 }
255
256 void Window::SetInputRegion(const Rect<int>& inputRegion)
257 {
258   return GetImplementation(*this).SetInputRegion(inputRegion);
259 }
260
261 void Window::SetType(WindowType type)
262 {
263   GetImplementation(*this).SetType(type);
264 }
265
266 WindowType Window::GetType() const
267 {
268   return GetImplementation(*this).GetType();
269 }
270
271 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
272 {
273   return GetImplementation(*this).SetNotificationLevel(level);
274 }
275
276 WindowNotificationLevel Window::GetNotificationLevel() const
277 {
278   return GetImplementation(*this).GetNotificationLevel();
279 }
280
281 void Window::SetOpaqueState(bool opaque)
282 {
283   GetImplementation(*this).SetOpaqueState(opaque);
284 }
285
286 bool Window::IsOpaqueState() const
287 {
288   return GetImplementation(*this).IsOpaqueState();
289 }
290
291 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenMode)
292 {
293   return GetImplementation(*this).SetScreenOffMode(screenMode);
294 }
295
296 WindowScreenOffMode Window::GetScreenOffMode() const
297 {
298   return GetImplementation(*this).GetScreenOffMode();
299 }
300
301 WindowOperationResult Window::SetBrightness(int brightness)
302 {
303   return GetImplementation(*this).SetBrightness(brightness);
304 }
305
306 int Window::GetBrightness() const
307 {
308   return GetImplementation(*this).GetBrightness();
309 }
310
311 Window::ResizeSignalType& Window::ResizeSignal()
312 {
313   return GetImplementation(*this).ResizeSignal();
314 }
315
316 void Window::SetSize(Window::WindowSize size)
317 {
318   GetImplementation(*this).SetSize(size);
319 }
320
321 Window::WindowSize Window::GetSize() const
322 {
323   return GetImplementation(*this).GetSize();
324 }
325
326 void Window::SetPosition(Dali::Window::WindowPosition position)
327 {
328   GetImplementation(*this).SetPosition(position);
329 }
330
331 Dali::Window::WindowPosition Window::GetPosition() const
332 {
333   return GetImplementation(*this).GetPosition();
334 }
335
336 void Window::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
337 {
338   return GetImplementation(*this).SetLayout(numCols, numRows, column, row, colSpan, rowSpan);
339 }
340
341 void Window::SetTransparency(bool transparent)
342 {
343   GetImplementation(*this).SetTransparency(transparent);
344 }
345
346 Dali::RenderTaskList Window::GetRenderTaskList()
347 {
348   return GetImplementation(*this).GetRenderTaskList();
349 }
350
351 void Window::KeepRendering(float durationSeconds)
352 {
353   GetImplementation(*this).KeepRendering(durationSeconds);
354 }
355
356 void Window::SetPartialUpdateEnabled(bool enabled)
357 {
358   GetImplementation(*this).SetPartialUpdateEnabled(enabled);
359 }
360
361 bool Window::IsPartialUpdateEnabled() const
362 {
363   return GetImplementation(*this).IsPartialUpdateEnabled();
364 }
365
366 Window::KeyEventSignalType& Window::KeyEventSignal()
367 {
368   return GetImplementation(*this).KeyEventSignal();
369 }
370
371 Window::TouchEventSignalType& Window::TouchedSignal()
372 {
373   return GetImplementation(*this).TouchedSignal();
374 }
375
376 Window::Window(Internal::Adaptor::Window* window)
377 : BaseHandle(window)
378 {
379 }
380
381 } // namespace Dali