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