6895baec7c0ba0a2f79f974c3a03bb9d82b0351b
[platform/core/uifw/dali-adaptor.git] / dali / public-api / adaptor-framework / window.cpp
1 /*
2  * Copyright (c) 2020 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, 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 void Window::Add(Dali::Actor actor)
87 {
88   GetImplementation(*this).Add(actor);
89 }
90
91 void Window::Remove(Dali::Actor actor)
92 {
93   GetImplementation(*this).Remove(actor);
94 }
95
96 void Window::SetBackgroundColor(const Vector4& color)
97 {
98   GetImplementation(*this).SetBackgroundColor(color);
99 }
100
101 Vector4 Window::GetBackgroundColor() const
102 {
103   return GetImplementation(*this).GetBackgroundColor();
104 }
105
106 Layer Window::GetRootLayer() const
107 {
108   return GetImplementation(*this).GetRootLayer();
109 }
110
111 uint32_t Window::GetLayerCount() const
112 {
113   return GetImplementation(*this).GetLayerCount();
114 }
115
116 Layer Window::GetLayer(uint32_t depth) const
117 {
118   return GetImplementation(*this).GetLayer(depth);
119 }
120
121 Uint16Pair Window::GetDpi() const
122 {
123   return GetImplementation(*this).GetDpi();
124 }
125
126 void Window::SetClass(std::string name, std::string klass)
127 {
128   GetImplementation(*this).SetClass(name, klass);
129 }
130
131 void Window::Raise()
132 {
133   GetImplementation(*this).Raise();
134 }
135
136 void Window::Lower()
137 {
138   GetImplementation(*this).Lower();
139 }
140
141 void Window::Activate()
142 {
143   GetImplementation(*this).Activate();
144 }
145
146 void Window::AddAvailableOrientation(WindowOrientation orientation)
147 {
148   GetImplementation(*this).AddAvailableOrientation(orientation);
149 }
150
151 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
152 {
153   GetImplementation(*this).RemoveAvailableOrientation(orientation);
154 }
155
156 void Window::SetPreferredOrientation(WindowOrientation orientation)
157 {
158   GetImplementation(*this).SetPreferredOrientation(orientation);
159 }
160
161 Dali::Window::WindowOrientation Window::GetPreferredOrientation()
162 {
163   return GetImplementation(*this).GetPreferredOrientation();
164 }
165
166 Any Window::GetNativeHandle() const
167 {
168   return GetImplementation(*this).GetNativeHandle();
169 }
170
171 Window::FocusChangeSignalType& Window::FocusChangeSignal()
172 {
173   return GetImplementation(*this).FocusChangeSignal();
174 }
175
176 void Window::SetAcceptFocus(bool accept)
177 {
178   GetImplementation(*this).SetAcceptFocus(accept);
179 }
180
181 bool Window::IsFocusAcceptable() const
182 {
183   return GetImplementation(*this).IsFocusAcceptable();
184 }
185
186 void Window::Show()
187 {
188   GetImplementation(*this).Show();
189 }
190
191 void Window::Hide()
192 {
193   GetImplementation(*this).Hide();
194 }
195
196 bool Window::IsVisible() const
197 {
198   return GetImplementation(*this).IsVisible();
199 }
200
201 unsigned int Window::GetSupportedAuxiliaryHintCount() const
202 {
203   return GetImplementation(*this).GetSupportedAuxiliaryHintCount();
204 }
205
206 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
207 {
208   return GetImplementation(*this).GetSupportedAuxiliaryHint(index);
209 }
210
211 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
212 {
213   return GetImplementation(*this).AddAuxiliaryHint(hint, value);
214 }
215
216 bool Window::RemoveAuxiliaryHint(unsigned int id)
217 {
218   return GetImplementation(*this).RemoveAuxiliaryHint(id);
219 }
220
221 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
222 {
223   return GetImplementation(*this).SetAuxiliaryHintValue(id, value);
224 }
225
226 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
227 {
228   return GetImplementation(*this).GetAuxiliaryHintValue(id);
229 }
230
231 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
232 {
233   return GetImplementation(*this).GetAuxiliaryHintId(hint);
234 }
235
236 void Window::SetInputRegion(const Rect<int>& inputRegion)
237 {
238   return GetImplementation(*this).SetInputRegion(inputRegion);
239 }
240
241 void Window::SetType(Window::Type type)
242 {
243   GetImplementation(*this).SetType(type);
244 }
245
246 Window::Type Window::GetType() const
247 {
248   return GetImplementation(*this).GetType();
249 }
250
251 bool Window::SetNotificationLevel(Window::NotificationLevel::Type level)
252 {
253   return GetImplementation(*this).SetNotificationLevel(level);
254 }
255
256 Window::NotificationLevel::Type Window::GetNotificationLevel() const
257 {
258   return GetImplementation(*this).GetNotificationLevel();
259 }
260
261 void Window::SetOpaqueState(bool opaque)
262 {
263   GetImplementation(*this).SetOpaqueState(opaque);
264 }
265
266 bool Window::IsOpaqueState() const
267 {
268   return GetImplementation(*this).IsOpaqueState();
269 }
270
271 bool Window::SetScreenOffMode(Window::ScreenOffMode::Type screenMode)
272 {
273   return GetImplementation(*this).SetScreenOffMode(screenMode);
274 }
275
276 Window::ScreenOffMode::Type Window::GetScreenOffMode() const
277 {
278   return GetImplementation(*this).GetScreenOffMode();
279 }
280
281 bool Window::SetBrightness(int brightness)
282 {
283   return GetImplementation(*this).SetBrightness(brightness);
284 }
285
286 int Window::GetBrightness() const
287 {
288   return GetImplementation(*this).GetBrightness();
289 }
290
291 Window::ResizeSignalType& Window::ResizeSignal()
292 {
293   return GetImplementation(*this).ResizeSignal();
294 }
295
296 void Window::SetSize(Window::WindowSize size)
297 {
298   GetImplementation(*this).SetSize(size);
299 }
300
301 Window::WindowSize Window::GetSize() const
302 {
303   return GetImplementation(*this).GetSize();
304 }
305
306 void Window::SetPosition(Window::WindowPosition position)
307 {
308   GetImplementation(*this).SetPosition(position);
309 }
310
311 Window::WindowPosition Window::GetPosition() const
312 {
313   return GetImplementation(*this).GetPosition();
314 }
315
316 void Window::SetTransparency(bool transparent)
317 {
318   GetImplementation(*this).SetTransparency(transparent);
319 }
320
321 Dali::RenderTaskList Window::GetRenderTaskList()
322 {
323   return GetImplementation(*this).GetRenderTaskList();
324 }
325
326 Window::KeyEventSignalType& Window::KeyEventSignal()
327 {
328   return GetImplementation(*this).KeyEventSignal();
329 }
330
331 Window::TouchEventSignalType& Window::TouchedSignal()
332 {
333   return GetImplementation(*this).TouchedSignal();
334 }
335
336 Window::Window(Internal::Adaptor::Window* window)
337 : BaseHandle(window)
338 {
339 }
340
341 } // namespace Dali