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)
39 WindowData windowData;
40 windowData.SetPositionSize(posSize);
41 windowData.SetTransparency(isTransparent);
42 windowData.SetWindowType(WindowType::NORMAL);
43 return Dali::Window::New(name, "", windowData);
46 Window Window::New(const std::string& name, const std::string& className, const WindowData& windowData)
50 const bool isAdaptorAvailable = Dali::Adaptor::IsAvailable();
51 bool isNewWindowAllowed = true;
53 if(isAdaptorAvailable)
55 Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get();
56 isNewWindowAllowed = Internal::Adaptor::Adaptor::GetImplementation(adaptor).IsMultipleWindowSupported();
59 if(isNewWindowAllowed)
61 Internal::Adaptor::Window* window = Internal::Adaptor::Window::New(name, className, windowData);
63 Integration::SceneHolder sceneHolder = Integration::SceneHolder(window);
65 if(isAdaptorAvailable)
67 Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get();
68 Internal::Adaptor::Adaptor::GetImplementation(adaptor).AddWindow(sceneHolder);
70 newWindow = Window(window);
74 DALI_LOG_ERROR("This device can't support multiple windows.\n");
88 Window::Window(const Window& copy) = default;
90 Window& Window::operator=(const Window& rhs) = default;
92 Window::Window(Window&& rhs) noexcept = default;
94 Window& Window::operator=(Window&& rhs) noexcept = default;
96 Window Window::DownCast(BaseHandle handle)
98 return Window(dynamic_cast<Dali::Internal::Adaptor::Window*>(handle.GetObjectPtr()));
101 void Window::Add(Dali::Actor actor)
103 GetImplementation(*this).Add(actor);
106 void Window::Remove(Dali::Actor actor)
108 GetImplementation(*this).Remove(actor);
111 void Window::SetBackgroundColor(const Vector4& color)
113 GetImplementation(*this).SetBackgroundColor(color);
116 Vector4 Window::GetBackgroundColor() const
118 return GetImplementation(*this).GetBackgroundColor();
121 Layer Window::GetRootLayer() const
123 return GetImplementation(*this).GetRootLayer();
126 Layer Window::GetOverlayLayer()
128 return GetImplementation(*this).GetOverlayLayer();
131 uint32_t Window::GetLayerCount() const
133 return GetImplementation(*this).GetLayerCount();
136 Layer Window::GetLayer(uint32_t depth) const
138 return GetImplementation(*this).GetLayer(depth);
141 Uint16Pair Window::GetDpi() const
143 return GetImplementation(*this).GetDpi();
146 void Window::SetClass(std::string name, std::string klass)
148 GetImplementation(*this).SetClass(name, klass);
153 GetImplementation(*this).Raise();
158 GetImplementation(*this).Lower();
161 void Window::Activate()
163 GetImplementation(*this).Activate();
166 void Window::AddAvailableOrientation(WindowOrientation orientation)
168 GetImplementation(*this).AddAvailableOrientation(orientation);
171 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
173 GetImplementation(*this).RemoveAvailableOrientation(orientation);
176 void Window::SetPreferredOrientation(WindowOrientation orientation)
178 GetImplementation(*this).SetPreferredOrientation(orientation);
181 WindowOrientation Window::GetPreferredOrientation()
183 return GetImplementation(*this).GetPreferredOrientation();
186 Any Window::GetNativeHandle() const
188 return GetImplementation(*this).GetNativeHandle();
191 Window::FocusChangeSignalType& Window::FocusChangeSignal()
193 return GetImplementation(*this).FocusChangeSignal();
196 void Window::SetAcceptFocus(bool accept)
198 GetImplementation(*this).SetAcceptFocus(accept);
201 bool Window::IsFocusAcceptable() const
203 return GetImplementation(*this).IsFocusAcceptable();
208 GetImplementation(*this).Show();
213 GetImplementation(*this).Hide();
216 bool Window::IsVisible() const
218 return GetImplementation(*this).IsVisible();
221 unsigned int Window::GetSupportedAuxiliaryHintCount() const
223 return GetImplementation(*this).GetSupportedAuxiliaryHintCount();
226 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
228 return GetImplementation(*this).GetSupportedAuxiliaryHint(index);
231 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
233 return GetImplementation(*this).AddAuxiliaryHint(hint, value);
236 bool Window::RemoveAuxiliaryHint(unsigned int id)
238 return GetImplementation(*this).RemoveAuxiliaryHint(id);
241 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
243 return GetImplementation(*this).SetAuxiliaryHintValue(id, value);
246 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
248 return GetImplementation(*this).GetAuxiliaryHintValue(id);
251 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
253 return GetImplementation(*this).GetAuxiliaryHintId(hint);
256 void Window::SetInputRegion(const Rect<int>& inputRegion)
258 return GetImplementation(*this).SetInputRegion(inputRegion);
261 void Window::SetType(WindowType type)
263 GetImplementation(*this).SetType(type);
266 WindowType Window::GetType() const
268 return GetImplementation(*this).GetType();
271 WindowOperationResult Window::SetNotificationLevel(WindowNotificationLevel level)
273 return GetImplementation(*this).SetNotificationLevel(level);
276 WindowNotificationLevel Window::GetNotificationLevel() const
278 return GetImplementation(*this).GetNotificationLevel();
281 void Window::SetOpaqueState(bool opaque)
283 GetImplementation(*this).SetOpaqueState(opaque);
286 bool Window::IsOpaqueState() const
288 return GetImplementation(*this).IsOpaqueState();
291 WindowOperationResult Window::SetScreenOffMode(WindowScreenOffMode screenMode)
293 return GetImplementation(*this).SetScreenOffMode(screenMode);
296 WindowScreenOffMode Window::GetScreenOffMode() const
298 return GetImplementation(*this).GetScreenOffMode();
301 WindowOperationResult Window::SetBrightness(int brightness)
303 return GetImplementation(*this).SetBrightness(brightness);
306 int Window::GetBrightness() const
308 return GetImplementation(*this).GetBrightness();
311 Window::ResizeSignalType& Window::ResizeSignal()
313 return GetImplementation(*this).ResizeSignal();
316 void Window::SetSize(Window::WindowSize size)
318 GetImplementation(*this).SetSize(size);
321 Window::WindowSize Window::GetSize() const
323 return GetImplementation(*this).GetSize();
326 void Window::SetPosition(Dali::Window::WindowPosition position)
328 GetImplementation(*this).SetPosition(position);
331 Dali::Window::WindowPosition Window::GetPosition() const
333 return GetImplementation(*this).GetPosition();
336 void Window::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
338 return GetImplementation(*this).SetLayout(numCols, numRows, column, row, colSpan, rowSpan);
341 void Window::SetTransparency(bool transparent)
343 GetImplementation(*this).SetTransparency(transparent);
346 Dali::RenderTaskList Window::GetRenderTaskList()
348 return GetImplementation(*this).GetRenderTaskList();
351 void Window::KeepRendering(float durationSeconds)
353 GetImplementation(*this).KeepRendering(durationSeconds);
356 void Window::SetPartialUpdateEnabled(bool enabled)
358 GetImplementation(*this).SetPartialUpdateEnabled(enabled);
361 bool Window::IsPartialUpdateEnabled() const
363 return GetImplementation(*this).IsPartialUpdateEnabled();
366 Window::KeyEventSignalType& Window::KeyEventSignal()
368 return GetImplementation(*this).KeyEventSignal();
371 Window::TouchEventSignalType& Window::TouchedSignal()
373 return GetImplementation(*this).TouchedSignal();
376 Window::Window(Internal::Adaptor::Window* window)