506bee8407074fd159d454de2b3dc9290313318d
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-window.cpp
1 /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19 #include "toolkit-window.h"
20
21 // EXTERNAL INCLUDES
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>
26
27 #include <dali/integration-api/adaptors/scene-holder.h>
28 #include <toolkit-scene-holder-impl.h>
29
30 #define DALI_WINDOW_H
31 #include <dali/integration-api/adaptors/adaptor.h>
32 #include <toolkit-adaptor-impl.h>
33
34 // INTERNAL INCLUDES
35 #include "test-render-surface.h"
36
37 using AdaptorImpl = Dali::Internal::Adaptor::Adaptor;
38
39 namespace Dali
40 {
41
42 class Window;
43
44 /********************************************************************************
45  * Stub for Dali::Internal::Adaptor::Window
46  ********************************************************************************/
47
48 namespace Internal
49 {
50 namespace Adaptor
51 {
52 class Window : public SceneHolder
53 {
54 public:
55
56   Window( const PositionSize& positionSize )
57   : SceneHolder( positionSize )
58   {
59   }
60
61   virtual ~Window() = default;
62
63   static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
64   {
65     return new Window( positionSize );
66   }
67 };
68
69 } // Adaptor
70 } // Internal
71
72 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
73 {
74   DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
75   BaseObject& object = window.GetBaseObject();
76   return static_cast<Internal::Adaptor::Window&>(object);
77 }
78
79 Window::Window()
80 {
81 }
82
83 Window::~Window()
84 {
85 }
86
87 Window::Window(const Window& handle)
88 : BaseHandle( handle )
89 {
90 }
91
92 Window& Window::operator=(const Window& rhs)
93 {
94   BaseHandle::operator=(rhs);
95   return *this;
96 }
97
98 Dali::Window Window::New( PositionSize windowPosition, const std::string& name, bool isTransparent )
99 {
100   return New( windowPosition, name, "", isTransparent );
101 }
102
103 Dali::Window Window::New(PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent )
104 {
105   Internal::Adaptor::Window* window = Internal::Adaptor::Window::New( windowPosition, name, className, isTransparent );
106
107   Dali::Window result( window );
108
109   Dali::Integration::SceneHolder sceneHolder( static_cast<Dali::Internal::Adaptor::SceneHolder*>( window ) );
110   Dali::Internal::Adaptor::Adaptor::Get().WindowCreatedSignal().Emit( sceneHolder );
111
112   return result;
113 }
114
115 Dali::Layer Window::GetRootLayer() const
116 {
117   return Dali::Stage::GetCurrent().GetRootLayer();
118 }
119
120 Window::Window( Internal::Adaptor::Window* window )
121 : BaseHandle( window )
122 {
123 }
124
125 Integration::Scene Window::GetScene()
126 {
127   return GetImplementation( *this ).GetScene();
128 }
129
130 Integration::RenderSurface& Window::GetRenderSurface()
131 {
132   return GetImplementation( *this ).GetRenderSurface();
133 }
134
135 namespace DevelWindow
136 {
137
138 Window Get( Actor actor )
139 {
140   return Window();
141 }
142
143 EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window )
144 {
145   return GetImplementation( window ).GetScene().EventProcessingFinishedSignal();
146 }
147
148 KeyEventSignalType& KeyEventSignal( Window window )
149 {
150   return GetImplementation( window ).KeyEventSignal();
151 }
152
153 KeyEventGeneratedSignalType& KeyEventGeneratedSignal( Window window )
154 {
155   return GetImplementation( window ).KeyEventGeneratedSignal();
156 }
157
158 TouchSignalType& TouchSignal( Window window )
159 {
160   return GetImplementation( window ).TouchSignal();
161 }
162
163 WheelEventSignalType& WheelEventSignal( Window window )
164 {
165   return GetImplementation( window ).WheelEventSignal();
166 }
167 } // namespace DevelWindow
168
169 } // Dali