Changes after TouchedSignal changes
[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
30 using AdaptorImpl = Dali::Internal::Adaptor::Adaptor;
31
32 namespace Dali
33 {
34
35 ///////////////////////////////////////////////////////////////////////////////
36 //
37 // Dali::Internal::Adaptor::SceneHolder Stub
38 //
39 ///////////////////////////////////////////////////////////////////////////////
40
41 namespace Internal
42 {
43
44 namespace Adaptor
45 {
46
47 SceneHolder::SceneHolder( const Dali::Rect<int>& positionSize )
48 : mRenderSurface( positionSize ),
49   mScene( Dali::Integration::Scene::New( Dali::Size( static_cast<float>( positionSize.width ), static_cast<float>( positionSize.height ) ) ) )
50 {
51 }
52
53 SceneHolder::~SceneHolder()
54 {
55   if ( Dali::Adaptor::IsAvailable() )
56   {
57     AdaptorImpl::GetImpl( AdaptorImpl::Get() ).RemoveWindow( this );
58   }
59 }
60
61 void SceneHolder::Add( Dali::Actor actor )
62 {
63   mScene.Add( actor );
64 }
65
66 void SceneHolder::Remove( Dali::Actor actor )
67 {
68   mScene.Remove( actor );
69 }
70
71 Dali::Layer SceneHolder::GetRootLayer() const
72 {
73   return mScene.GetRootLayer();
74 }
75
76 void SceneHolder::SetBackgroundColor( Vector4 color )
77 {
78   return mScene.SetBackgroundColor( color );
79 }
80
81 Vector4 SceneHolder::GetBackgroundColor() const
82 {
83   return mScene.GetBackgroundColor();
84 }
85
86 void SceneHolder::FeedTouchPoint( Dali::TouchPoint& point, int timeStamp )
87 {
88 }
89
90 void SceneHolder::FeedWheelEvent( Dali::WheelEvent& wheelEvent )
91 {
92 }
93
94 void SceneHolder::FeedKeyEvent( Dali::KeyEvent& keyEvent )
95 {
96 }
97
98 Dali::Integration::SceneHolder::KeyEventSignalType& SceneHolder::KeyEventSignal()
99 {
100   return mScene.KeyEventSignal();
101 }
102
103 Dali::Integration::SceneHolder::KeyEventGeneratedSignalType& SceneHolder::KeyEventGeneratedSignal()
104 {
105   return mScene.KeyEventGeneratedSignal();
106 }
107
108 Dali::Integration::SceneHolder::TouchEventSignalType& SceneHolder::TouchedSignal()
109 {
110   return mScene.TouchedSignal();
111 }
112
113 Dali::Integration::SceneHolder::WheelEventSignalType& SceneHolder::WheelEventSignal()
114 {
115   return mScene.WheelEventSignal();
116 }
117
118 Integration::Scene SceneHolder::GetScene()
119 {
120   return mScene;
121 }
122
123 Dali::RenderSurfaceInterface& SceneHolder::GetRenderSurface()
124 {
125   return mRenderSurface;
126 }
127
128 } // namespace Adaptor
129
130 } // namespace Internal
131
132 ///////////////////////////////////////////////////////////////////////////////
133 //
134 // Dali::Integration::SceneHolder Stub
135 //
136 ///////////////////////////////////////////////////////////////////////////////
137
138 namespace Integration
139 {
140
141 SceneHolder::SceneHolder()
142 {
143   // Dali::Internal::Adaptor::Adaptor::Get().WindowCreatedSignal().Emit( *this );
144 }
145
146 SceneHolder::~SceneHolder()
147 {
148 }
149
150 SceneHolder::SceneHolder( const SceneHolder& handle )
151 : BaseHandle(handle)
152 {
153 }
154
155 SceneHolder::SceneHolder( Internal::Adaptor::SceneHolder* internal )
156 : BaseHandle(internal)
157 {
158 }
159
160 SceneHolder& SceneHolder::operator=( const SceneHolder& rhs )
161 {
162   BaseHandle::operator=(rhs);
163   return *this;
164 }
165
166 Dali::Integration::SceneHolder SceneHolder::Get( Dali::Actor actor )
167 {
168   Internal::Adaptor::SceneHolder* sceneHolderImpl = nullptr;
169
170   if ( Dali::Adaptor::IsAvailable() )
171   {
172     sceneHolderImpl = AdaptorImpl::GetImpl( AdaptorImpl::Get() ).GetWindow( actor );
173   }
174
175   return Dali::Integration::SceneHolder( sceneHolderImpl );
176 }
177
178 void SceneHolder::Add( Actor actor )
179 {
180   GetImplementation( *this ).Add( actor );
181 }
182
183 void SceneHolder::Remove( Actor actor )
184 {
185   GetImplementation( *this ).Remove( actor );
186 }
187
188 Dali::Layer SceneHolder::GetRootLayer() const
189 {
190   return GetImplementation( *this ).GetRootLayer();
191 }
192
193 void SceneHolder::SetBackgroundColor( Vector4 color )
194 {
195   GetImplementation( *this ).SetBackgroundColor( color );
196 }
197
198 Vector4 SceneHolder::GetBackgroundColor() const
199 {
200   return GetImplementation( *this ).GetBackgroundColor();
201 }
202
203 void SceneHolder::FeedTouchPoint( Dali::TouchPoint& point, int timeStamp )
204 {
205   GetImplementation( *this ).FeedTouchPoint( point, timeStamp );
206 }
207
208 void SceneHolder::FeedWheelEvent( Dali::WheelEvent& wheelEvent )
209 {
210   GetImplementation( *this ).FeedWheelEvent( wheelEvent );
211 }
212
213 void SceneHolder::FeedKeyEvent( Dali::KeyEvent& keyEvent )
214 {
215   GetImplementation( *this ).FeedKeyEvent( keyEvent );
216 }
217
218 SceneHolder::KeyEventSignalType& SceneHolder::KeyEventSignal()
219 {
220   return GetImplementation( *this ).KeyEventSignal();
221 }
222
223 SceneHolder::KeyEventGeneratedSignalType& SceneHolder::KeyEventGeneratedSignal()
224 {
225   return GetImplementation( *this ).KeyEventGeneratedSignal();
226 }
227
228 SceneHolder::TouchEventSignalType& SceneHolder::TouchedSignal()
229 {
230   return GetImplementation( *this ).TouchedSignal();
231 }
232
233 SceneHolder::WheelEventSignalType& SceneHolder::WheelEventSignal()
234 {
235   return GetImplementation( *this ).WheelEventSignal();
236 }
237
238 } // Integration
239
240 } // Dali