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/public-api/actors/actor.h>
26 #include <dali/internal/window-system/common/window-impl.h>
27 #include <dali/internal/window-system/common/orientation-impl.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, 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 ) = default;
85 Window& Window::operator=( Window&& rhs ) = default;
87 void Window::Add( Dali::Actor actor )
89 GetImplementation( *this ).Add( actor );
92 void Window::Remove( Dali::Actor actor )
94 GetImplementation( *this ).Remove( actor );
97 void Window::SetBackgroundColor( const Vector4& color )
99 GetImplementation( *this ).SetBackgroundColor( color );
102 Vector4 Window::GetBackgroundColor() const
104 return GetImplementation( *this ).GetBackgroundColor();
107 Layer Window::GetRootLayer() const
109 return GetImplementation( *this ).GetRootLayer();
112 uint32_t Window::GetLayerCount() const
114 return GetImplementation( *this ).GetLayerCount();
117 Layer Window::GetLayer( uint32_t depth ) const
119 return GetImplementation( *this ).GetLayer( depth );
122 Uint16Pair Window::GetDpi() const
124 return GetImplementation(*this).GetDpi();
127 void Window::SetClass( std::string name, std::string klass )
129 GetImplementation(*this).SetClass( name, klass );
134 GetImplementation(*this).Raise();
139 GetImplementation(*this).Lower();
142 void Window::Activate()
144 GetImplementation(*this).Activate();
147 void Window::AddAvailableOrientation( WindowOrientation orientation )
149 GetImplementation(*this).AddAvailableOrientation( orientation );
152 void Window::RemoveAvailableOrientation( WindowOrientation orientation )
154 GetImplementation(*this).RemoveAvailableOrientation( orientation );
157 void Window::SetPreferredOrientation( WindowOrientation orientation )
159 GetImplementation(*this).SetPreferredOrientation( orientation );
162 Dali::Window::WindowOrientation Window::GetPreferredOrientation()
164 return GetImplementation(*this).GetPreferredOrientation();
167 Any Window::GetNativeHandle() const
169 return GetImplementation(*this).GetNativeHandle();
172 Window::FocusChangeSignalType& Window::FocusChangeSignal()
174 return GetImplementation(*this).FocusChangeSignal();
177 void Window::SetAcceptFocus( bool accept )
179 GetImplementation(*this).SetAcceptFocus( accept );
182 bool Window::IsFocusAcceptable() const
184 return GetImplementation(*this).IsFocusAcceptable();
189 GetImplementation(*this).Show();
194 GetImplementation(*this).Hide();
197 bool Window::IsVisible() const
199 return GetImplementation(*this).IsVisible();
202 unsigned int Window::GetSupportedAuxiliaryHintCount() const
204 return GetImplementation(*this).GetSupportedAuxiliaryHintCount();
207 std::string Window::GetSupportedAuxiliaryHint( unsigned int index ) const
209 return GetImplementation(*this).GetSupportedAuxiliaryHint( index );
212 unsigned int Window::AddAuxiliaryHint( const std::string& hint, const std::string& value )
214 return GetImplementation(*this).AddAuxiliaryHint( hint, value );
217 bool Window::RemoveAuxiliaryHint( unsigned int id )
219 return GetImplementation(*this).RemoveAuxiliaryHint( id );
222 bool Window::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
224 return GetImplementation(*this).SetAuxiliaryHintValue( id, value );
227 std::string Window::GetAuxiliaryHintValue( unsigned int id ) const
229 return GetImplementation(*this).GetAuxiliaryHintValue( id );
232 unsigned int Window::GetAuxiliaryHintId( const std::string& hint ) const
234 return GetImplementation(*this).GetAuxiliaryHintId( hint );
237 void Window::SetInputRegion( const Rect< int >& inputRegion )
239 return GetImplementation(*this).SetInputRegion( inputRegion );
242 void Window::SetType( Window::Type type )
244 GetImplementation(*this).SetType( type );
247 Window::Type Window::GetType() const
249 return GetImplementation(*this).GetType();
252 bool Window::SetNotificationLevel( Window::NotificationLevel::Type level )
254 return GetImplementation(*this).SetNotificationLevel( level );
257 Window::NotificationLevel::Type Window::GetNotificationLevel() const
259 return GetImplementation(*this).GetNotificationLevel();
262 void Window::SetOpaqueState( bool opaque )
264 GetImplementation(*this).SetOpaqueState( opaque );
267 bool Window::IsOpaqueState() const
269 return GetImplementation(*this).IsOpaqueState();
272 bool Window::SetScreenOffMode(Window::ScreenOffMode::Type screenMode)
274 return GetImplementation(*this).SetScreenOffMode(screenMode);
277 Window::ScreenOffMode::Type Window::GetScreenOffMode() const
279 return GetImplementation(*this).GetScreenOffMode();
282 bool Window::SetBrightness( int brightness )
284 return GetImplementation(*this).SetBrightness( brightness );
287 int Window::GetBrightness() const
289 return GetImplementation(*this).GetBrightness();
292 Window::ResizeSignalType& Window::ResizeSignal()
294 return GetImplementation(*this).ResizeSignal();
297 void Window::SetSize( Window::WindowSize size )
299 GetImplementation(*this).SetSize( size );
302 Window::WindowSize Window::GetSize() const
304 return GetImplementation(*this).GetSize();
307 void Window::SetPosition( Window::WindowPosition position )
309 GetImplementation(*this).SetPosition( position );
312 Window::WindowPosition Window::GetPosition() const
314 return GetImplementation(*this).GetPosition();
317 void Window::SetTransparency( bool transparent )
319 GetImplementation(*this).SetTransparency( transparent );
322 Dali::RenderTaskList Window::GetRenderTaskList()
324 return GetImplementation(*this).GetRenderTaskList();
327 Window::KeyEventSignalType& Window::KeyEventSignal()
329 return GetImplementation(*this).KeyEventSignal();
332 Window::TouchEventSignalType& Window::TouchedSignal()
334 return GetImplementation(*this).TouchedSignal();
337 Window::Window( Internal::Adaptor::Window* window )
338 : BaseHandle( window )