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 "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>
32 #include "test-render-surface.h"
34 using AdaptorImpl = Dali::Internal::Adaptor::Adaptor;
41 /********************************************************************************
42 * Stub for Dali::Internal::Adaptor::Window
43 ********************************************************************************/
50 Window::Window( const PositionSize& positionSize )
51 : SceneHolder( positionSize ),
53 mVisibilityChangedSignal()
57 Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
59 return new Window( positionSize );
65 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
67 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
68 BaseObject& object = window.GetBaseObject();
69 return static_cast<Internal::Adaptor::Window&>(object);
72 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
74 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
75 const BaseObject& object = window.GetBaseObject();
76 return static_cast<const Internal::Adaptor::Window&>(object);
87 Window::Window(const Window& handle)
88 : BaseHandle( handle )
92 Window& Window::operator=(const Window& rhs)
94 BaseHandle::operator=(rhs);
98 Dali::Window Window::New( PositionSize windowPosition, const std::string& name, bool isTransparent )
100 return New( windowPosition, name, "", isTransparent );
103 Dali::Window Window::New(PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent )
105 Internal::Adaptor::Window* window = Internal::Adaptor::Window::New( windowPosition, name, className, isTransparent );
107 Dali::Window result( window );
109 // This will also emit the window created signals
110 AdaptorImpl::GetImpl( AdaptorImpl::Get() ).AddWindow( window );
115 Window::Window( Internal::Adaptor::Window* window )
116 : BaseHandle( window )
120 Integration::Scene Window::GetScene()
122 return GetImplementation( *this ).GetScene();
125 Integration::RenderSurface& Window::GetRenderSurface()
127 return GetImplementation( *this ).GetRenderSurface();
130 void Window::Add( Actor actor )
132 GetImplementation( *this ).Add( actor );
135 void Window::Remove( Actor actor )
137 GetImplementation( *this ).Remove( actor );
140 Dali::Layer Window::GetRootLayer() const
142 return GetImplementation( *this ).GetRootLayer();
145 void Window::SetBackgroundColor( const Vector4& color )
147 GetImplementation( *this ).SetBackgroundColor( color );
150 Vector4 Window::GetBackgroundColor() const
152 return GetImplementation( *this ).GetBackgroundColor();
157 GetImplementation( *this ).mFocusChangeSignal.Emit(*this, true);
162 GetImplementation( *this ).mVisibilityChangedSignal.Emit( *this, false );
165 FocusChangeSignalType& Window::FocusChangeSignal()
167 return GetImplementation( *this ).mFocusChangeSignal;
170 namespace DevelWindow
173 Window Get( Actor actor )
175 Internal::Adaptor::Window* windowImpl = nullptr;
177 if ( Dali::Adaptor::IsAvailable() )
179 windowImpl = static_cast<Internal::Adaptor::Window*>( AdaptorImpl::GetImpl( AdaptorImpl::Get() ).GetWindow( actor ) );
182 return Dali::Window( windowImpl );
185 Window DownCast( BaseHandle handle )
187 Internal::Adaptor::Window* windowImpl = nullptr;
188 if ( Dali::Adaptor::IsAvailable() )
190 windowImpl = dynamic_cast<Dali::Internal::Adaptor::Window*>( handle.GetObjectPtr());
192 return Dali::Window( windowImpl );
195 EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window )
197 return GetImplementation( window ).GetScene().EventProcessingFinishedSignal();
200 KeyEventSignalType& KeyEventSignal( Window window )
202 return GetImplementation( window ).KeyEventSignal();
205 KeyEventGeneratedSignalType& KeyEventGeneratedSignal( Window window )
207 return GetImplementation( window ).KeyEventGeneratedSignal();
210 TouchSignalType& TouchSignal( Window window )
212 return GetImplementation( window ).TouchSignal();
215 WheelEventSignalType& WheelEventSignal( Window window )
217 return GetImplementation( window ).WheelEventSignal();
220 VisibilityChangedSignalType& VisibilityChangedSignal( Window window )
222 return GetImplementation( window ).mVisibilityChangedSignal;
225 } // namespace DevelWindow