2 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/public-api/adaptor-framework/window.h>
22 #include <dali/integration-api/debug.h>
23 #include <dali/public-api/render-tasks/render-task-list.h>
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>
32 Window Window::New(PositionSize posSize, const std::string& name, bool isTransparent)
34 return Dali::Window::New(posSize, name, "", isTransparent);
37 Window Window::New(PositionSize posSize, const std::string& name, const std::string& className, bool isTransparent)
41 const bool isAdaptorAvailable = Dali::Adaptor::IsAvailable();
42 bool isNewWindowAllowed = true;
44 if(isAdaptorAvailable)
46 Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get();
47 isNewWindowAllowed = Internal::Adaptor::Adaptor::GetImplementation(adaptor).IsMultipleWindowSupported();
50 if(isNewWindowAllowed)
52 Internal::Adaptor::Window* window = Internal::Adaptor::Window::New(posSize, name, className, WindowType::NORMAL, isTransparent);
54 Integration::SceneHolder sceneHolder = Integration::SceneHolder(window);
56 if(isAdaptorAvailable)
58 Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get();
59 Internal::Adaptor::Adaptor::GetImplementation(adaptor).AddWindow(sceneHolder);
61 newWindow = Window(window);
65 DALI_LOG_ERROR("This device can't support multiple windows.\n");
79 Window::Window(const Window& copy) = default;
81 Window& Window::operator=(const Window& rhs) = default;
83 Window::Window(Window&& rhs) noexcept = default;
85 Window& Window::operator=(Window&& rhs) noexcept = default;
87 Window Window::DownCast(BaseHandle handle)
89 return Window(dynamic_cast<Dali::Internal::Adaptor::Window*>(handle.GetObjectPtr()));
92 void Window::Add(Dali::Actor actor)
94 GetImplementation(*this).Add(actor);
97 void Window::Remove(Dali::Actor actor)
99 GetImplementation(*this).Remove(actor);
102 void Window::SetBackgroundColor(const Vector4& color)
104 GetImplementation(*this).SetBackgroundColor(color);
107 Vector4 Window::GetBackgroundColor() const
109 return GetImplementation(*this).GetBackgroundColor();
112 Layer Window::GetRootLayer() const
114 return GetImplementation(*this).GetRootLayer();
117 Layer Window::GetOverlayLayer()
119 return GetImplementation(*this).GetOverlayLayer();
122 uint32_t Window::GetLayerCount() const
124 return GetImplementation(*this).GetLayerCount();
127 Layer Window::GetLayer(uint32_t depth) const
129 return GetImplementation(*this).GetLayer(depth);
132 Uint16Pair Window::GetDpi() const
134 return GetImplementation(*this).GetDpi();
137 void Window::SetClass(std::string name, std::string klass)
139 GetImplementation(*this).SetClass(name, klass);
144 GetImplementation(*this).Raise();
149 GetImplementation(*this).Lower();
152 void Window::Activate()
154 GetImplementation(*this).Activate();
157 void Window::AddAvailableOrientation(WindowOrientation orientation)
159 GetImplementation(*this).AddAvailableOrientation(orientation);
162 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
164 GetImplementation(*this).RemoveAvailableOrientation(orientation);
167 void Window::SetPreferredOrientation(WindowOrientation orientation)
169 GetImplementation(*this).SetPreferredOrientation(orientation);
172 WindowOrientation Window::GetPreferredOrientation()
174 return GetImplementation(*this).GetPreferredOrientation();
177 Any Window::GetNativeHandle() const
179 return GetImplementation(*this).GetNativeHandle();
182 Window::FocusChangeSignalType& Window::FocusChangeSignal()
184 return GetImplementation(*this).FocusChangeSignal();
187 void Window::SetAcceptFocus(bool accept)
189 GetImplementation(*this).SetAcceptFocus(accept);
192 bool Window::IsFocusAcceptable() const
194 return GetImplementation(*this).IsFocusAcceptable();
199 GetImplementation(*this).Show();
204 GetImplementation(*this).Hide();
207 bool Window::IsVisible() const
209 return GetImplementation(*this).IsVisible();
212 unsigned int Window::GetSupportedAuxiliaryHintCount() const
214 return GetImplementation(*this).GetSupportedAuxiliaryHintCount();
217 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
219 return GetImplementation(*this).GetSupportedAuxiliaryHint(index);
222 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
224 return GetImplementation(*this).AddAuxiliaryHint(hint, value);
227 bool Window::RemoveAuxiliaryHint(unsigned int id)
229 return GetImplementation(*this).RemoveAuxiliaryHint(id);
232 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
234 return GetImplementation(*this).SetAuxiliaryHintValue(id, value);
237 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
239 return GetImplementation(*this).GetAuxiliaryHintValue(id);
242 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
244 return GetImplementation(*this).GetAuxiliaryHintId(hint);
247 void Window::SetInputRegion(const Rect<int>& inputRegion)
249 return GetImplementation(*this).SetInputRegion(inputRegion);
252 void Window::SetType(WindowType type)
254 GetImplementation(*this).SetType(type);
257 WindowType Window::GetType() const
259 return GetImplementation(*this).GetType();
262 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
264 return GetImplementation(*this).SetNotificationLevel(level);
267 WindowNotificationLevel Window::GetNotificationLevel() const
269 return GetImplementation(*this).GetNotificationLevel();
272 void Window::SetOpaqueState(bool opaque)
274 GetImplementation(*this).SetOpaqueState(opaque);
277 bool Window::IsOpaqueState() const
279 return GetImplementation(*this).IsOpaqueState();
282 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenMode)
284 return GetImplementation(*this).SetScreenOffMode(screenMode);
287 WindowScreenOffMode Window::GetScreenOffMode() const
289 return GetImplementation(*this).GetScreenOffMode();
292 WindowOperationResult Window::SetBrightness(int brightness)
294 return GetImplementation(*this).SetBrightness(brightness);
297 int Window::GetBrightness() const
299 return GetImplementation(*this).GetBrightness();
302 Window::ResizeSignalType& Window::ResizeSignal()
304 return GetImplementation(*this).ResizeSignal();
307 void Window::SetSize(Window::WindowSize size)
309 GetImplementation(*this).SetSize(size);
312 Window::WindowSize Window::GetSize() const
314 return GetImplementation(*this).GetSize();
317 void Window::SetPosition(Dali::Window::WindowPosition position)
319 GetImplementation(*this).SetPosition(position);
322 Dali::Window::WindowPosition Window::GetPosition() const
324 return GetImplementation(*this).GetPosition();
327 void Window::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
329 return GetImplementation(*this).SetLayout(numCols, numRows, column, row, colSpan, rowSpan);
332 void Window::SetTransparency(bool transparent)
334 GetImplementation(*this).SetTransparency(transparent);
337 Dali::RenderTaskList Window::GetRenderTaskList()
339 return GetImplementation(*this).GetRenderTaskList();
342 void Window::KeepRendering(float durationSeconds)
344 GetImplementation(*this).KeepRendering(durationSeconds);
347 Window::KeyEventSignalType& Window::KeyEventSignal()
349 return GetImplementation(*this).KeyEventSignal();
352 Window::TouchEventSignalType& Window::TouchedSignal()
354 return GetImplementation(*this).TouchedSignal();
357 Window::Window(Internal::Adaptor::Window* window)