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.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/adaptors/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 ********************************************************************************/
49 class Window : public Dali::BaseObject
53 Window( const PositionSize& positionSize )
54 : mRenderSurface( positionSize ),
55 mScene( Dali::Integration::Scene::New( mRenderSurface ) )
59 virtual ~Window() = default;
61 static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
63 return new Window( positionSize );
66 TestRenderSurface mRenderSurface;
67 Integration::Scene mScene;
73 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
75 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
76 BaseObject& object = window.GetBaseObject();
77 return static_cast<Internal::Adaptor::Window&>(object);
88 Window::Window(const Window& handle)
89 : BaseHandle( handle )
93 Window& Window::operator=(const Window& rhs)
95 BaseHandle::operator=(rhs);
99 Dali::Window Window::New( PositionSize windowPosition, const std::string& name, bool isTransparent )
101 return New( windowPosition, name, "", isTransparent );
104 Dali::Window Window::New(PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent )
106 Internal::Adaptor::Window* window = Internal::Adaptor::Window::New( windowPosition, name, className, isTransparent );
107 Dali::Window newWindow = Window( window );
108 Dali::Adaptor::WindowCreatedSignalType& windowCreatedSignal = AdaptorImpl::Get().WindowCreatedSignal();
109 windowCreatedSignal.Emit( newWindow );
110 return Window( window );
113 Dali::Layer Window::GetRootLayer() const
115 return Dali::Stage::GetCurrent().GetRootLayer();
118 Window::Window( Internal::Adaptor::Window* window )
119 : BaseHandle( window )
123 Integration::Scene Window::GetScene()
125 return GetImplementation( *this ).mScene;
128 Integration::RenderSurface& Window::GetRenderSurface()
130 return GetImplementation( *this ).mRenderSurface;
133 namespace DevelWindow
136 Window Get( Actor actor )
141 EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window )
143 return GetImplementation( window ).mScene.EventProcessingFinishedSignal();
146 KeyEventSignalType& KeyEventSignal( Window window )
148 return GetImplementation( window ).mScene.KeyEventSignal();
151 KeyEventGeneratedSignalType& KeyEventGeneratedSignal( Window window )
153 return GetImplementation( window ).mScene.KeyEventGeneratedSignal();
156 TouchSignalType& TouchSignal( Window window )
158 return GetImplementation( window ).mScene.TouchSignal();
161 WheelEventSignalType& WheelEventSignal( Window window )
163 return GetImplementation( window ).mScene.WheelEventSignal();
165 } // namespace DevelWindow