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 "toolkit-window-impl.h"
22 #include <dali/public-api/actors/actor.h>
23 #include <dali/public-api/actors/layer.h>
24 #include <dali/public-api/common/stage.h>
25 #include <dali/public-api/object/base-object.h>
28 #include <dali/integration-api/adaptor-framework/adaptor.h>
29 #include <toolkit-adaptor-impl.h>
31 using AdaptorImpl = Dali::Internal::Adaptor::Adaptor;
38 /********************************************************************************
39 * Stub for Dali::Internal::Adaptor::Window
40 ********************************************************************************/
47 Window::Window( const PositionSize& positionSize )
48 : SceneHolder( positionSize ),
50 mVisibilityChangedSignal()
54 Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
56 return new Window( positionSize );
62 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
64 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
65 BaseObject& object = window.GetBaseObject();
66 return static_cast<Internal::Adaptor::Window&>(object);
69 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
71 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
72 const BaseObject& object = window.GetBaseObject();
73 return static_cast<const Internal::Adaptor::Window&>(object);
84 Window::Window(const Window& handle)
85 : BaseHandle( handle )
89 Window& Window::operator=(const Window& rhs)
91 BaseHandle::operator=(rhs);
95 Dali::Window Window::New( PositionSize windowPosition, const std::string& name, bool isTransparent )
97 return New( windowPosition, name, "", isTransparent );
100 Dali::Window Window::New(PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent )
102 Internal::Adaptor::Window* window = Internal::Adaptor::Window::New( windowPosition, name, className, isTransparent );
104 Dali::Window result( window );
106 // This will also emit the window created signals
107 AdaptorImpl::GetImpl( AdaptorImpl::Get() ).AddWindow( window );
112 Window::Window( Internal::Adaptor::Window* window )
113 : BaseHandle( window )
117 Integration::Scene Window::GetScene()
119 return GetImplementation( *this ).GetScene();
122 Dali::RenderSurfaceInterface& Window::GetRenderSurface()
124 return GetImplementation( *this ).GetRenderSurface();
127 void Window::Add( Actor actor )
129 GetImplementation( *this ).Add( actor );
132 void Window::Remove( Actor actor )
134 GetImplementation( *this ).Remove( actor );
137 Dali::Layer Window::GetRootLayer() const
139 return GetImplementation( *this ).GetRootLayer();
142 void Window::SetBackgroundColor( const Vector4& color )
144 GetImplementation( *this ).SetBackgroundColor( color );
147 Vector4 Window::GetBackgroundColor() const
149 return GetImplementation( *this ).GetBackgroundColor();
154 GetImplementation( *this ).mFocusChangeSignal.Emit(*this, true);
159 GetImplementation( *this ).mVisibilityChangedSignal.Emit( *this, false );
162 FocusChangeSignalType& Window::FocusChangeSignal()
164 return GetImplementation( *this ).mFocusChangeSignal;
167 namespace DevelWindow
170 Window Get( Actor actor )
172 Internal::Adaptor::Window* windowImpl = nullptr;
174 if ( Dali::Adaptor::IsAvailable() )
176 windowImpl = static_cast<Internal::Adaptor::Window*>( AdaptorImpl::GetImpl( AdaptorImpl::Get() ).GetWindow( actor ) );
179 return Dali::Window( windowImpl );
182 Window DownCast( BaseHandle handle )
184 Internal::Adaptor::Window* windowImpl = nullptr;
185 if ( Dali::Adaptor::IsAvailable() )
187 windowImpl = dynamic_cast<Dali::Internal::Adaptor::Window*>( handle.GetObjectPtr());
189 return Dali::Window( windowImpl );
192 EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window )
194 return GetImplementation( window ).GetScene().EventProcessingFinishedSignal();
197 KeyEventSignalType& KeyEventSignal( Window window )
199 return GetImplementation( window ).KeyEventSignal();
202 KeyEventGeneratedSignalType& KeyEventGeneratedSignal( Window window )
204 return GetImplementation( window ).KeyEventGeneratedSignal();
207 TouchSignalType& TouchSignal( Window window )
209 return GetImplementation( window ).TouchSignal();
212 WheelEventSignalType& WheelEventSignal( Window window )
214 return GetImplementation( window ).WheelEventSignal();
217 VisibilityChangedSignalType& VisibilityChangedSignal( Window window )
219 return GetImplementation( window ).mVisibilityChangedSignal;
222 } // namespace DevelWindow