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