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& handle)
84 : BaseHandle( handle )
88 Window& Window::operator=(const Window& rhs)
90 BaseHandle::operator=(rhs);
94 Dali::Window Window::New( PositionSize windowPosition, const std::string& name, bool isTransparent )
96 return New( windowPosition, name, "", isTransparent );
99 Dali::Window Window::New(PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent )
101 Internal::Adaptor::Window* window = Internal::Adaptor::Window::New( windowPosition, name, className, isTransparent );
103 Dali::Window result( window );
105 // This will also emit the window created signals
106 AdaptorImpl::GetImpl( AdaptorImpl::Get() ).AddWindow( window );
111 Window::Window( Internal::Adaptor::Window* window )
112 : BaseHandle( window )
116 Integration::Scene Window::GetScene()
118 return GetImplementation( *this ).GetScene();
121 Dali::RenderSurfaceInterface& Window::GetRenderSurface()
123 return GetImplementation( *this ).GetRenderSurface();
126 void Window::Add( Actor actor )
128 GetImplementation( *this ).Add( actor );
131 void Window::Remove( Actor actor )
133 GetImplementation( *this ).Remove( actor );
136 Dali::Layer Window::GetRootLayer() const
138 return GetImplementation( *this ).GetRootLayer();
141 void Window::SetBackgroundColor( const Vector4& color )
143 GetImplementation( *this ).SetBackgroundColor( color );
146 Vector4 Window::GetBackgroundColor() const
148 return GetImplementation( *this ).GetBackgroundColor();
153 GetImplementation( *this ).mFocusChangeSignal.Emit(*this, true);
158 GetImplementation( *this ).mVisibilityChangedSignal.Emit( *this, false );
161 FocusChangeSignalType& Window::FocusChangeSignal()
163 return GetImplementation( *this ).mFocusChangeSignal;
166 Window::KeyEventSignalType& Window::KeyEventSignal()
168 return GetImplementation( *this ).KeyEventSignal();
171 Window::TouchSignalType& Window::TouchSignal()
173 return GetImplementation( *this ).TouchSignal();
176 namespace DevelWindow
179 Window Get( Actor actor )
181 Internal::Adaptor::Window* windowImpl = nullptr;
183 if ( Dali::Adaptor::IsAvailable() )
185 windowImpl = static_cast<Internal::Adaptor::Window*>( AdaptorImpl::GetImpl( AdaptorImpl::Get() ).GetWindow( actor ) );
188 return Dali::Window( windowImpl );
191 Window DownCast( BaseHandle handle )
193 Internal::Adaptor::Window* windowImpl = nullptr;
194 if ( Dali::Adaptor::IsAvailable() )
196 windowImpl = dynamic_cast<Dali::Internal::Adaptor::Window*>( handle.GetObjectPtr());
198 return Dali::Window( windowImpl );
201 void AddFrameRenderedCallback( Window window, std::unique_ptr< CallbackBase > callback, int32_t frameId )
203 CallbackBase::Execute( *callback, frameId );
206 void AddFramePresentedCallback( Window window, std::unique_ptr< CallbackBase > callback, int32_t frameId )
208 CallbackBase::Execute( *callback, frameId );
211 EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window )
213 return GetImplementation( window ).GetScene().EventProcessingFinishedSignal();
216 KeyEventGeneratedSignalType& KeyEventGeneratedSignal( Window window )
218 return GetImplementation( window ).KeyEventGeneratedSignal();
221 WheelEventSignalType& WheelEventSignal( Window window )
223 return GetImplementation( window ).WheelEventSignal();
226 VisibilityChangedSignalType& VisibilityChangedSignal( Window window )
228 return GetImplementation( window ).mVisibilityChangedSignal;
231 } // namespace DevelWindow