2 * Copyright (c) 2019 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 class DALI_INTERNAL DragAndDropDetector : public BaseHandle {}; // Empty class only required to compile Deprecated API GetDragAndDropDetector
34 Window Window::New(PositionSize posSize, const std::string& name, bool isTransparent)
36 return Dali::Window::New(posSize, name, "", isTransparent);
39 Window Window::New(PositionSize posSize, const std::string& name, const std::string& className, bool isTransparent)
43 const bool isAdaptorAvailable = Dali::Adaptor::IsAvailable();
44 bool isNewWindowAllowed = true;
46 if (isAdaptorAvailable)
48 Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get();
49 isNewWindowAllowed = Internal::Adaptor::Adaptor::GetImplementation(adaptor).IsMultipleWindowSupported();
52 if (isNewWindowAllowed)
54 Internal::Adaptor::Window* window = Internal::Adaptor::Window::New(posSize, name, className, isTransparent);
56 Integration::SceneHolder sceneHolder = Integration::SceneHolder(window);
58 if (isAdaptorAvailable)
60 Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get();
61 Internal::Adaptor::Adaptor::GetImplementation(adaptor).AddWindow(sceneHolder, name, className, isTransparent);
63 newWindow = Window(window);
67 DALI_LOG_ERROR("This device can't support multiple windows.\n");
81 Window::Window(const Window& handle)
86 Window& Window::operator=(const Window& rhs)
88 BaseHandle::operator=(rhs);
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 uint32_t Window::GetLayerCount() const
119 return GetImplementation( *this ).GetLayerCount();
122 Layer Window::GetLayer( uint32_t depth ) const
124 return GetImplementation( *this ).GetLayer( depth );
127 void Window::ShowIndicator( IndicatorVisibleMode visibleMode )
129 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: ShowIndicator is deprecated and will be removed from next release.\n" );
131 GetImplementation(*this).ShowIndicator( visibleMode );
134 Window::IndicatorSignalType& Window::IndicatorVisibilityChangedSignal()
136 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: IndicatorVisibilityChangedSignal is deprecated and will be removed from next release.\n" );
138 return GetImplementation(*this).IndicatorVisibilityChangedSignal();
141 void Window::SetIndicatorBgOpacity( IndicatorBgOpacity opacity )
143 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetIndicatorBgOpacity is deprecated and will be removed from next release.\n" );
145 GetImplementation(*this).SetIndicatorBgOpacity( opacity );
148 void Window::RotateIndicator( WindowOrientation orientation )
150 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: RotateIndicator is deprecated and will be removed from next release.\n" );
152 GetImplementation(*this).RotateIndicator( orientation );
155 void Window::SetClass( std::string name, std::string klass )
157 GetImplementation(*this).SetClass( name, klass );
162 GetImplementation(*this).Raise();
167 GetImplementation(*this).Lower();
170 void Window::Activate()
172 GetImplementation(*this).Activate();
175 void Window::AddAvailableOrientation( WindowOrientation orientation )
177 GetImplementation(*this).AddAvailableOrientation( orientation );
180 void Window::RemoveAvailableOrientation( WindowOrientation orientation )
182 GetImplementation(*this).RemoveAvailableOrientation( orientation );
185 void Window::SetPreferredOrientation( WindowOrientation orientation )
187 GetImplementation(*this).SetPreferredOrientation( orientation );
190 Dali::Window::WindowOrientation Window::GetPreferredOrientation()
192 return GetImplementation(*this).GetPreferredOrientation();
195 DragAndDropDetector Window::GetDragAndDropDetector() const
197 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetDragAndDropDetector is deprecated and will be removed from the next release.\n" );
198 DALI_ASSERT_ALWAYS( &GetImplementation( *this ) == GetObjectPtr() && "Empty Handle" );
199 return Dali::DragAndDropDetector();
202 Any Window::GetNativeHandle() const
204 return GetImplementation(*this).GetNativeHandle();
207 Window::FocusSignalType& Window::FocusChangedSignal()
209 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: FocusChangedSignal is deprecated and will be removed from next release.\n" );
210 return GetImplementation(*this).FocusChangedSignal();
213 Window::FocusChangeSignalType& Window::FocusChangeSignal()
215 return GetImplementation(*this).FocusChangeSignal();
218 void Window::SetAcceptFocus( bool accept )
220 GetImplementation(*this).SetAcceptFocus( accept );
223 bool Window::IsFocusAcceptable() const
225 return GetImplementation(*this).IsFocusAcceptable();
230 GetImplementation(*this).Show();
235 GetImplementation(*this).Hide();
238 bool Window::IsVisible() const
240 return GetImplementation(*this).IsVisible();
243 unsigned int Window::GetSupportedAuxiliaryHintCount() const
245 return GetImplementation(*this).GetSupportedAuxiliaryHintCount();
248 std::string Window::GetSupportedAuxiliaryHint( unsigned int index ) const
250 return GetImplementation(*this).GetSupportedAuxiliaryHint( index );
253 unsigned int Window::AddAuxiliaryHint( const std::string& hint, const std::string& value )
255 return GetImplementation(*this).AddAuxiliaryHint( hint, value );
258 bool Window::RemoveAuxiliaryHint( unsigned int id )
260 return GetImplementation(*this).RemoveAuxiliaryHint( id );
263 bool Window::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
265 return GetImplementation(*this).SetAuxiliaryHintValue( id, value );
268 std::string Window::GetAuxiliaryHintValue( unsigned int id ) const
270 return GetImplementation(*this).GetAuxiliaryHintValue( id );
273 unsigned int Window::GetAuxiliaryHintId( const std::string& hint ) const
275 return GetImplementation(*this).GetAuxiliaryHintId( hint );
278 void Window::SetInputRegion( const Rect< int >& inputRegion )
280 return GetImplementation(*this).SetInputRegion( inputRegion );
283 void Window::SetType( Window::Type type )
285 GetImplementation(*this).SetType( type );
288 Window::Type Window::GetType() const
290 return GetImplementation(*this).GetType();
293 bool Window::SetNotificationLevel( Window::NotificationLevel::Type level )
295 return GetImplementation(*this).SetNotificationLevel( level );
298 Window::NotificationLevel::Type Window::GetNotificationLevel() const
300 return GetImplementation(*this).GetNotificationLevel();
303 void Window::SetOpaqueState( bool opaque )
305 GetImplementation(*this).SetOpaqueState( opaque );
308 bool Window::IsOpaqueState() const
310 return GetImplementation(*this).IsOpaqueState();
313 bool Window::SetScreenOffMode(Window::ScreenOffMode::Type screenMode)
315 return GetImplementation(*this).SetScreenOffMode(screenMode);
318 Window::ScreenOffMode::Type Window::GetScreenOffMode() const
320 return GetImplementation(*this).GetScreenOffMode();
323 bool Window::SetBrightness( int brightness )
325 return GetImplementation(*this).SetBrightness( brightness );
328 int Window::GetBrightness() const
330 return GetImplementation(*this).GetBrightness();
333 Window::ResizedSignalType& Window::ResizedSignal()
335 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: ResizedSignal is deprecated and will be removed from next release.\n" );
336 return GetImplementation(*this).ResizedSignal();
339 Window::ResizeSignalType& Window::ResizeSignal()
341 return GetImplementation(*this).ResizeSignal();
344 void Window::SetSize( Window::WindowSize size )
346 GetImplementation(*this).SetSize( size );
349 Window::WindowSize Window::GetSize() const
351 return GetImplementation(*this).GetSize();
354 void Window::SetPosition( Window::WindowPosition position )
356 GetImplementation(*this).SetPosition( position );
359 Window::WindowPosition Window::GetPosition() const
361 return GetImplementation(*this).GetPosition();
364 void Window::SetTransparency( bool transparent )
366 GetImplementation(*this).SetTransparency( transparent );
369 Window::Window( Internal::Adaptor::Window* window )
370 : BaseHandle( window )