DALi Version 2.2.11
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-scene-holder.cpp
1 /*
2  * Copyright (c) 2020 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 #include <dali/integration-api/events/touch-event-integ.h>
19 #include <dali/integration-api/adaptor-framework/scene-holder.h>
20
21 #include <toolkit-scene-holder-impl.h>
22
23 #include <dali/public-api/actors/actor.h>
24 #include <dali/public-api/actors/layer.h>
25 #include <dali/public-api/object/base-object.h>
26
27 #include <dali/integration-api/adaptor-framework/adaptor.h>
28 #include <toolkit-adaptor-impl.h>
29 #include <dali/public-api/render-tasks/render-task-list.h>
30
31 using AdaptorImpl = Dali::Internal::Adaptor::Adaptor;
32
33 namespace Dali
34 {
35
36 ///////////////////////////////////////////////////////////////////////////////
37 //
38 // Dali::Internal::Adaptor::SceneHolder Stub
39 //
40 ///////////////////////////////////////////////////////////////////////////////
41
42 namespace Internal
43 {
44
45 namespace Adaptor
46 {
47
48 SceneHolder::SceneHolder( const Dali::Rect<int>& positionSize )
49 : mRenderSurface( positionSize ),
50   mScene( Dali::Integration::Scene::New( Dali::Size( static_cast<float>( positionSize.width ), static_cast<float>( positionSize.height ) ) ) )
51 {
52 }
53
54 SceneHolder::~SceneHolder()
55 {
56   if ( Dali::Adaptor::IsAvailable() )
57   {
58     AdaptorImpl::GetImpl( AdaptorImpl::Get() ).RemoveWindow( this );
59   }
60 }
61
62 void SceneHolder::Add( Dali::Actor actor )
63 {
64   mScene.Add( actor );
65 }
66
67 void SceneHolder::Remove( Dali::Actor actor )
68 {
69   mScene.Remove( actor );
70 }
71
72 Dali::Layer SceneHolder::GetRootLayer() const
73 {
74   return mScene.GetRootLayer();
75 }
76
77 void SceneHolder::SetBackgroundColor( Vector4 color )
78 {
79   return mScene.SetBackgroundColor( color );
80 }
81
82 Vector4 SceneHolder::GetBackgroundColor() const
83 {
84   return mScene.GetBackgroundColor();
85 }
86
87 void SceneHolder::FeedTouchPoint( Dali::TouchPoint& point, int timeStamp )
88 {
89 }
90
91 void SceneHolder::FeedWheelEvent( Dali::WheelEvent& wheelEvent )
92 {
93 }
94
95 void SceneHolder::FeedKeyEvent( Dali::KeyEvent& keyEvent )
96 {
97 }
98
99 Dali::Integration::SceneHolder::KeyEventSignalType& SceneHolder::KeyEventSignal()
100 {
101   return mScene.KeyEventSignal();
102 }
103
104 Dali::Integration::SceneHolder::KeyEventGeneratedSignalType& SceneHolder::KeyEventGeneratedSignal()
105 {
106   return mScene.KeyEventGeneratedSignal();
107 }
108
109 Dali::Integration::SceneHolder::TouchEventSignalType& SceneHolder::TouchedSignal()
110 {
111   return mScene.TouchedSignal();
112 }
113
114 Dali::Integration::SceneHolder::WheelEventSignalType& SceneHolder::WheelEventSignal()
115 {
116   return mScene.WheelEventSignal();
117 }
118
119 Dali::Integration::SceneHolder::WheelEventGeneratedSignalType& SceneHolder::WheelEventGeneratedSignal()
120 {
121   return mScene.WheelEventGeneratedSignal();
122 }
123
124 Integration::Scene SceneHolder::GetScene()
125 {
126   return mScene;
127 }
128
129 Dali::RenderSurfaceInterface& SceneHolder::GetRenderSurface()
130 {
131   return mRenderSurface;
132 }
133
134 Dali::RenderTaskList SceneHolder::GetRenderTaskList()
135 {
136   return mScene.GetRenderTaskList();
137 }
138
139 } // namespace Adaptor
140
141 } // namespace Internal
142
143 ///////////////////////////////////////////////////////////////////////////////
144 //
145 // Dali::Integration::SceneHolder Stub
146 //
147 ///////////////////////////////////////////////////////////////////////////////
148
149 namespace Integration
150 {
151
152 SceneHolder::SceneHolder()
153 {
154   // Dali::Internal::Adaptor::Adaptor::Get().WindowCreatedSignal().Emit( *this );
155 }
156
157 SceneHolder::~SceneHolder()
158 {
159 }
160
161 SceneHolder::SceneHolder( const SceneHolder& handle )
162 : BaseHandle(handle)
163 {
164 }
165
166 SceneHolder::SceneHolder( Internal::Adaptor::SceneHolder* internal )
167 : BaseHandle(internal)
168 {
169 }
170
171 SceneHolder& SceneHolder::operator=( const SceneHolder& rhs )
172 {
173   BaseHandle::operator=(rhs);
174   return *this;
175 }
176
177 Dali::Integration::SceneHolder SceneHolder::Get( Dali::Actor actor )
178 {
179   Internal::Adaptor::SceneHolder* sceneHolderImpl = nullptr;
180
181   if ( Dali::Adaptor::IsAvailable() )
182   {
183     sceneHolderImpl = AdaptorImpl::GetImpl( AdaptorImpl::Get() ).GetWindow( actor );
184   }
185
186   return Dali::Integration::SceneHolder( sceneHolderImpl );
187 }
188
189 void SceneHolder::Add( Actor actor )
190 {
191   GetImplementation( *this ).Add( actor );
192 }
193
194 void SceneHolder::Remove( Actor actor )
195 {
196   GetImplementation( *this ).Remove( actor );
197 }
198
199 Dali::Layer SceneHolder::GetRootLayer() const
200 {
201   return GetImplementation( *this ).GetRootLayer();
202 }
203
204 void SceneHolder::SetBackgroundColor( Vector4 color )
205 {
206   GetImplementation( *this ).SetBackgroundColor( color );
207 }
208
209 Vector4 SceneHolder::GetBackgroundColor() const
210 {
211   return GetImplementation( *this ).GetBackgroundColor();
212 }
213
214 void SceneHolder::FeedTouchPoint( Dali::TouchPoint& point, int timeStamp )
215 {
216   GetImplementation( *this ).FeedTouchPoint( point, timeStamp );
217 }
218
219 void SceneHolder::FeedWheelEvent( Dali::WheelEvent& wheelEvent )
220 {
221   GetImplementation( *this ).FeedWheelEvent( wheelEvent );
222 }
223
224 void SceneHolder::FeedKeyEvent( Dali::KeyEvent& keyEvent )
225 {
226   GetImplementation( *this ).FeedKeyEvent( keyEvent );
227 }
228
229 SceneHolder::KeyEventSignalType& SceneHolder::KeyEventSignal()
230 {
231   return GetImplementation( *this ).KeyEventSignal();
232 }
233
234 SceneHolder::KeyEventGeneratedSignalType& SceneHolder::KeyEventGeneratedSignal()
235 {
236   return GetImplementation( *this ).KeyEventGeneratedSignal();
237 }
238
239 SceneHolder::TouchEventSignalType& SceneHolder::TouchedSignal()
240 {
241   return GetImplementation( *this ).TouchedSignal();
242 }
243
244 SceneHolder::WheelEventSignalType& SceneHolder::WheelEventSignal()
245 {
246   return GetImplementation( *this ).WheelEventSignal();
247 }
248
249 SceneHolder::WheelEventGeneratedSignalType& SceneHolder::WheelEventGeneratedSignal()
250 {
251   return GetImplementation( *this ).WheelEventGeneratedSignal();
252 }
253
254 } // Integration
255
256 } // Dali