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