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 "test-render-surface.h"
35 /********************************************************************************
36 * Stub for Dali::Internal::Adaptor::Window
37 ********************************************************************************/
43 class Window : public Dali::BaseObject
47 Window( const PositionSize& positionSize )
48 : mScene( Dali::Integration::Scene::New( Size( positionSize.width, positionSize.height ) ) ),
49 mRenderSurface( new TestRenderSurface( positionSize ) )
51 mScene.SetSurface( *mRenderSurface );
56 delete mRenderSurface;
57 mRenderSurface = nullptr;
60 static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
62 return new Window( positionSize );
65 Integration::Scene mScene;
66 TestRenderSurface* mRenderSurface;
72 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
74 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
75 BaseObject& object = window.GetBaseObject();
76 return static_cast<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 Internal::Adaptor::Window* window = Internal::Adaptor::Window::New( windowPosition, name, "", isTransparent );
101 return Window( window );
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 return Window( window );
110 Dali::Layer Window::GetRootLayer() const
112 return Dali::Stage::GetCurrent().GetRootLayer();
115 Window::Window( Internal::Adaptor::Window* window )
116 : BaseHandle( window )
120 Integration::Scene Window::GetScene()
122 return GetImplementation( *this ).mScene;
125 Integration::RenderSurface& Window::GetRenderSurface()
127 return *GetImplementation( *this ).mRenderSurface;
130 namespace DevelWindow
133 Window Get( Actor actor )
138 EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window )
140 return GetImplementation( window ).mScene.EventProcessingFinishedSignal();
143 KeyEventSignalType& KeyEventSignal( Window window )
145 return GetImplementation( window ).mScene.KeyEventSignal();
148 TouchSignalType& TouchSignal( Window window )
150 return GetImplementation( window ).mScene.TouchSignal();
153 WheelEventSignalType& WheelEventSignal( Window window )
155 return GetImplementation( window ).mScene.WheelEventSignal();
158 } // namespace DevelWindow