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 DALI_LOG_ERROR("This device can't support multiple windows.\n");
56 Internal::Adaptor::Window* window = Internal::Adaptor::Window::New(posSize, name, className, isTransparent);
58 Integration::SceneHolder sceneHolder = Integration::SceneHolder(window);
60 if (isAdaptorAvailable)
62 Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get();
63 Internal::Adaptor::Adaptor::GetImplementation(adaptor).AddWindow(sceneHolder, name, className, isTransparent);
65 newWindow = Window(window);
78 Window::Window(const Window& handle)
83 Window& Window::operator=(const Window& rhs)
85 BaseHandle::operator=(rhs);
89 void Window::Add( Dali::Actor actor )
91 GetImplementation( *this ).Add( actor );
94 void Window::Remove( Dali::Actor actor )
96 GetImplementation( *this ).Remove( actor );
99 void Window::SetBackgroundColor( const Vector4& color )
101 GetImplementation( *this ).SetBackgroundColor( color );
104 Vector4 Window::GetBackgroundColor() const
106 return GetImplementation( *this ).GetBackgroundColor();
109 Layer Window::GetRootLayer() const
111 return GetImplementation( *this ).GetRootLayer();
114 uint32_t Window::GetLayerCount() const
116 return GetImplementation( *this ).GetLayerCount();
119 Layer Window::GetLayer( uint32_t depth ) const
121 return GetImplementation( *this ).GetLayer( depth );
124 void Window::ShowIndicator( IndicatorVisibleMode visibleMode )
126 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: ShowIndicator is deprecated and will be removed from next release.\n" );
128 GetImplementation(*this).ShowIndicator( visibleMode );
131 Window::IndicatorSignalType& Window::IndicatorVisibilityChangedSignal()
133 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: IndicatorVisibilityChangedSignal is deprecated and will be removed from next release.\n" );
135 return GetImplementation(*this).IndicatorVisibilityChangedSignal();
138 void Window::SetIndicatorBgOpacity( IndicatorBgOpacity opacity )
140 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetIndicatorBgOpacity is deprecated and will be removed from next release.\n" );
142 GetImplementation(*this).SetIndicatorBgOpacity( opacity );
145 void Window::RotateIndicator( WindowOrientation orientation )
147 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: RotateIndicator is deprecated and will be removed from next release.\n" );
149 GetImplementation(*this).RotateIndicator( orientation );
152 void Window::SetClass( std::string name, std::string klass )
154 GetImplementation(*this).SetClass( name, klass );
159 GetImplementation(*this).Raise();
164 GetImplementation(*this).Lower();
167 void Window::Activate()
169 GetImplementation(*this).Activate();
172 void Window::AddAvailableOrientation( WindowOrientation orientation )
174 GetImplementation(*this).AddAvailableOrientation( orientation );
177 void Window::RemoveAvailableOrientation( WindowOrientation orientation )
179 GetImplementation(*this).RemoveAvailableOrientation( orientation );
182 void Window::SetPreferredOrientation( WindowOrientation orientation )
184 GetImplementation(*this).SetPreferredOrientation( orientation );
187 Dali::Window::WindowOrientation Window::GetPreferredOrientation()
189 return GetImplementation(*this).GetPreferredOrientation();
192 DragAndDropDetector Window::GetDragAndDropDetector() const
194 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetDragAndDropDetector is deprecated and will be removed from the next release.\n" );
195 DALI_ASSERT_ALWAYS( &GetImplementation( *this ) == GetObjectPtr() && "Empty Handle" );
196 return Dali::DragAndDropDetector();
199 Any Window::GetNativeHandle() const
201 return GetImplementation(*this).GetNativeHandle();
204 Window::FocusSignalType& Window::FocusChangedSignal()
206 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: FocusChangedSignal is deprecated and will be removed from next release.\n" );
207 return GetImplementation(*this).FocusChangedSignal();
210 Window::FocusChangeSignalType& Window::FocusChangeSignal()
212 return GetImplementation(*this).FocusChangeSignal();
215 void Window::SetAcceptFocus( bool accept )
217 GetImplementation(*this).SetAcceptFocus( accept );
220 bool Window::IsFocusAcceptable() const
222 return GetImplementation(*this).IsFocusAcceptable();
227 GetImplementation(*this).Show();
232 GetImplementation(*this).Hide();
235 bool Window::IsVisible() const
237 return GetImplementation(*this).IsVisible();
240 unsigned int Window::GetSupportedAuxiliaryHintCount() const
242 return GetImplementation(*this).GetSupportedAuxiliaryHintCount();
245 std::string Window::GetSupportedAuxiliaryHint( unsigned int index ) const
247 return GetImplementation(*this).GetSupportedAuxiliaryHint( index );
250 unsigned int Window::AddAuxiliaryHint( const std::string& hint, const std::string& value )
252 return GetImplementation(*this).AddAuxiliaryHint( hint, value );
255 bool Window::RemoveAuxiliaryHint( unsigned int id )
257 return GetImplementation(*this).RemoveAuxiliaryHint( id );
260 bool Window::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
262 return GetImplementation(*this).SetAuxiliaryHintValue( id, value );
265 std::string Window::GetAuxiliaryHintValue( unsigned int id ) const
267 return GetImplementation(*this).GetAuxiliaryHintValue( id );
270 unsigned int Window::GetAuxiliaryHintId( const std::string& hint ) const
272 return GetImplementation(*this).GetAuxiliaryHintId( hint );
275 void Window::SetInputRegion( const Rect< int >& inputRegion )
277 return GetImplementation(*this).SetInputRegion( inputRegion );
280 void Window::SetType( Window::Type type )
282 GetImplementation(*this).SetType( type );
285 Window::Type Window::GetType() const
287 return GetImplementation(*this).GetType();
290 bool Window::SetNotificationLevel( Window::NotificationLevel::Type level )
292 return GetImplementation(*this).SetNotificationLevel( level );
295 Window::NotificationLevel::Type Window::GetNotificationLevel() const
297 return GetImplementation(*this).GetNotificationLevel();
300 void Window::SetOpaqueState( bool opaque )
302 GetImplementation(*this).SetOpaqueState( opaque );
305 bool Window::IsOpaqueState() const
307 return GetImplementation(*this).IsOpaqueState();
310 bool Window::SetScreenOffMode(Window::ScreenOffMode::Type screenMode)
312 return GetImplementation(*this).SetScreenOffMode(screenMode);
315 Window::ScreenOffMode::Type Window::GetScreenOffMode() const
317 return GetImplementation(*this).GetScreenOffMode();
320 bool Window::SetBrightness( int brightness )
322 return GetImplementation(*this).SetBrightness( brightness );
325 int Window::GetBrightness() const
327 return GetImplementation(*this).GetBrightness();
330 Window::ResizedSignalType& Window::ResizedSignal()
332 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: ResizedSignal is deprecated and will be removed from next release.\n" );
333 return GetImplementation(*this).ResizedSignal();
336 Window::ResizeSignalType& Window::ResizeSignal()
338 return GetImplementation(*this).ResizeSignal();
341 void Window::SetSize( Window::WindowSize size )
343 GetImplementation(*this).SetSize( size );
346 Window::WindowSize Window::GetSize() const
348 return GetImplementation(*this).GetSize();
351 void Window::SetPosition( Window::WindowPosition position )
353 GetImplementation(*this).SetPosition( position );
356 Window::WindowPosition Window::GetPosition() const
358 return GetImplementation(*this).GetPosition();
361 void Window::SetTransparency( bool transparent )
363 GetImplementation(*this).SetTransparency( transparent );
366 Window::Window( Internal::Adaptor::Window* window )
367 : BaseHandle( window )