2 * Copyright (c) 2020 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, 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) = default;
84 Window& Window::operator=(Window&& rhs) = default;
86 void Window::Add(Dali::Actor actor)
88 GetImplementation(*this).Add(actor);
91 void Window::Remove(Dali::Actor actor)
93 GetImplementation(*this).Remove(actor);
96 void Window::SetBackgroundColor(const Vector4& color)
98 GetImplementation(*this).SetBackgroundColor(color);
101 Vector4 Window::GetBackgroundColor() const
103 return GetImplementation(*this).GetBackgroundColor();
106 Layer Window::GetRootLayer() const
108 return GetImplementation(*this).GetRootLayer();
111 uint32_t Window::GetLayerCount() const
113 return GetImplementation(*this).GetLayerCount();
116 Layer Window::GetLayer(uint32_t depth) const
118 return GetImplementation(*this).GetLayer(depth);
121 Uint16Pair Window::GetDpi() const
123 return GetImplementation(*this).GetDpi();
126 void Window::SetClass(std::string name, std::string klass)
128 GetImplementation(*this).SetClass(name, klass);
133 GetImplementation(*this).Raise();
138 GetImplementation(*this).Lower();
141 void Window::Activate()
143 GetImplementation(*this).Activate();
146 void Window::AddAvailableOrientation(WindowOrientation orientation)
148 GetImplementation(*this).AddAvailableOrientation(orientation);
151 void Window::RemoveAvailableOrientation(WindowOrientation orientation)
153 GetImplementation(*this).RemoveAvailableOrientation(orientation);
156 void Window::SetPreferredOrientation(WindowOrientation orientation)
158 GetImplementation(*this).SetPreferredOrientation(orientation);
161 WindowOrientation Window::GetPreferredOrientation()
163 return GetImplementation(*this).GetPreferredOrientation();
166 Any Window::GetNativeHandle() const
168 return GetImplementation(*this).GetNativeHandle();
171 Window::FocusChangeSignalType& Window::FocusChangeSignal()
173 return GetImplementation(*this).FocusChangeSignal();
176 void Window::SetAcceptFocus(bool accept)
178 GetImplementation(*this).SetAcceptFocus(accept);
181 bool Window::IsFocusAcceptable() const
183 return GetImplementation(*this).IsFocusAcceptable();
188 GetImplementation(*this).Show();
193 GetImplementation(*this).Hide();
196 bool Window::IsVisible() const
198 return GetImplementation(*this).IsVisible();
201 unsigned int Window::GetSupportedAuxiliaryHintCount() const
203 return GetImplementation(*this).GetSupportedAuxiliaryHintCount();
206 std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
208 return GetImplementation(*this).GetSupportedAuxiliaryHint(index);
211 unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
213 return GetImplementation(*this).AddAuxiliaryHint(hint, value);
216 bool Window::RemoveAuxiliaryHint(unsigned int id)
218 return GetImplementation(*this).RemoveAuxiliaryHint(id);
221 bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
223 return GetImplementation(*this).SetAuxiliaryHintValue(id, value);
226 std::string Window::GetAuxiliaryHintValue(unsigned int id) const
228 return GetImplementation(*this).GetAuxiliaryHintValue(id);
231 unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
233 return GetImplementation(*this).GetAuxiliaryHintId(hint);
236 void Window::SetInputRegion(const Rect<int>& inputRegion)
238 return GetImplementation(*this).SetInputRegion(inputRegion);
241 void Window::SetType(WindowType type)
243 GetImplementation(*this).SetType(type);
246 WindowType Window::GetType() const
248 return GetImplementation(*this).GetType();
251 bool Window::SetNotificationLevel(WindowNotificationLevel level)
253 return GetImplementation(*this).SetNotificationLevel(level);
256 WindowNotificationLevel Window::GetNotificationLevel() const
258 return GetImplementation(*this).GetNotificationLevel();
261 void Window::SetOpaqueState(bool opaque)
263 GetImplementation(*this).SetOpaqueState(opaque);
266 bool Window::IsOpaqueState() const
268 return GetImplementation(*this).IsOpaqueState();
271 bool Window::SetScreenOffMode(WindowScreenOffMode screenMode)
273 return GetImplementation(*this).SetScreenOffMode(screenMode);
276 WindowScreenOffMode Window::GetScreenOffMode() const
278 return GetImplementation(*this).GetScreenOffMode();
281 bool Window::SetBrightness(int brightness)
283 return GetImplementation(*this).SetBrightness(brightness);
286 int Window::GetBrightness() const
288 return GetImplementation(*this).GetBrightness();
291 Window::ResizeSignalType& Window::ResizeSignal()
293 return GetImplementation(*this).ResizeSignal();
296 void Window::SetSize(Window::WindowSize size)
298 GetImplementation(*this).SetSize(size);
301 Window::WindowSize Window::GetSize() const
303 return GetImplementation(*this).GetSize();
306 void Window::SetPosition(Window::WindowPosition position)
308 GetImplementation(*this).SetPosition(position);
311 Window::WindowPosition Window::GetPosition() const
313 return GetImplementation(*this).GetPosition();
316 void Window::SetTransparency(bool transparent)
318 GetImplementation(*this).SetTransparency(transparent);
321 Dali::RenderTaskList Window::GetRenderTaskList()
323 return GetImplementation(*this).GetRenderTaskList();
326 Window::KeyEventSignalType& Window::KeyEventSignal()
328 return GetImplementation(*this).KeyEventSignal();
331 Window::TouchEventSignalType& Window::TouchedSignal()
333 return GetImplementation(*this).TouchedSignal();
336 Window::Window(Internal::Adaptor::Window* window)