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/object/base-object.h>
27 #include <dali/integration-api/adaptor-framework/adaptor.h>
28 #include <toolkit-adaptor-impl.h>
30 using AdaptorImpl = Dali::Internal::Adaptor::Adaptor;
37 /********************************************************************************
38 * Stub for Dali::Internal::Adaptor::Window
39 ********************************************************************************/
46 Window::Window( const PositionSize& positionSize )
47 : SceneHolder( positionSize ),
49 mVisibilityChangedSignal()
53 Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
55 return new Window( positionSize );
61 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
63 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
64 BaseObject& object = window.GetBaseObject();
65 return static_cast<Internal::Adaptor::Window&>(object);
68 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
70 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
71 const BaseObject& object = window.GetBaseObject();
72 return static_cast<const Internal::Adaptor::Window&>(object);
83 Window::Window( const Window& copy ) = default;
85 Window& Window::operator=( const Window& rhs ) = default;
87 Window::Window( Window&& rhs ) = default;
89 Window& Window::operator=( Window&& rhs ) = default;
91 Dali::Window Window::New( PositionSize windowPosition, const std::string& name, bool isTransparent )
93 return New( windowPosition, name, "", isTransparent );
96 Dali::Window Window::New(PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent )
98 Internal::Adaptor::Window* window = Internal::Adaptor::Window::New( windowPosition, name, className, isTransparent );
100 Dali::Window result( window );
102 // This will also emit the window created signals
103 AdaptorImpl::GetImpl( AdaptorImpl::Get() ).AddWindow( window );
108 Window::Window( Internal::Adaptor::Window* window )
109 : BaseHandle( window )
113 Integration::Scene Window::GetScene()
115 return GetImplementation( *this ).GetScene();
118 Dali::RenderSurfaceInterface& Window::GetRenderSurface()
120 return GetImplementation( *this ).GetRenderSurface();
123 void Window::Add( Actor actor )
125 GetImplementation( *this ).Add( actor );
128 void Window::Remove( Actor actor )
130 GetImplementation( *this ).Remove( actor );
133 Dali::Layer Window::GetRootLayer() const
135 return GetImplementation( *this ).GetRootLayer();
138 void Window::SetBackgroundColor( const Vector4& color )
140 GetImplementation( *this ).SetBackgroundColor( color );
143 Vector4 Window::GetBackgroundColor() const
145 return GetImplementation( *this ).GetBackgroundColor();
150 GetImplementation( *this ).mFocusChangeSignal.Emit(*this, true);
155 GetImplementation( *this ).mVisibilityChangedSignal.Emit( *this, false );
158 FocusChangeSignalType& Window::FocusChangeSignal()
160 return GetImplementation( *this ).mFocusChangeSignal;
163 Window::KeyEventSignalType& Window::KeyEventSignal()
165 return GetImplementation( *this ).KeyEventSignal();
168 Window::TouchEventSignalType& Window::TouchedSignal()
170 return GetImplementation( *this ).TouchedSignal();
173 namespace DevelWindow
176 Window Get( Actor actor )
178 Internal::Adaptor::Window* windowImpl = nullptr;
180 if ( Dali::Adaptor::IsAvailable() )
182 windowImpl = static_cast<Internal::Adaptor::Window*>( AdaptorImpl::GetImpl( AdaptorImpl::Get() ).GetWindow( actor ) );
185 return Dali::Window( windowImpl );
188 Window DownCast( BaseHandle handle )
190 Internal::Adaptor::Window* windowImpl = nullptr;
191 if ( Dali::Adaptor::IsAvailable() )
193 windowImpl = dynamic_cast<Dali::Internal::Adaptor::Window*>( handle.GetObjectPtr());
195 return Dali::Window( windowImpl );
198 void AddFrameRenderedCallback( Window window, std::unique_ptr< CallbackBase > callback, int32_t frameId )
200 CallbackBase::Execute( *callback, frameId );
203 void AddFramePresentedCallback( Window window, std::unique_ptr< CallbackBase > callback, int32_t frameId )
205 CallbackBase::Execute( *callback, frameId );
208 EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window )
210 return GetImplementation( window ).GetScene().EventProcessingFinishedSignal();
213 KeyEventGeneratedSignalType& KeyEventGeneratedSignal( Window window )
215 return GetImplementation( window ).KeyEventGeneratedSignal();
218 WheelEventSignalType& WheelEventSignal( Window window )
220 return GetImplementation( window ).WheelEventSignal();
223 VisibilityChangedSignalType& VisibilityChangedSignal( Window window )
225 return GetImplementation( window ).mVisibilityChangedSignal;
228 } // namespace DevelWindow