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