2 * Copyright (c) 2024 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.
18 #include <dali/integration-api/adaptor-framework/scene-holder.h>
19 #include <dali/integration-api/events/touch-event-integ.h>
21 #include <toolkit-scene-holder-impl.h>
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>
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 #include "test-render-surface.h"
32 using AdaptorImpl = Dali::Internal::Adaptor::Adaptor;
36 ///////////////////////////////////////////////////////////////////////////////
38 // Dali::Internal::Adaptor::SceneHolder Stub
40 ///////////////////////////////////////////////////////////////////////////////
46 class SceneHolder::SceneHolderLifeCycleObserver
49 SceneHolderLifeCycleObserver(Adaptor*& adaptor, bool& adaptorStarted)
51 mAdaptorStarted(adaptorStarted)
55 private: // Adaptor::LifeCycleObserver interface
56 virtual void OnStart()
58 mAdaptorStarted = true;
60 virtual void OnPause(){};
61 virtual void OnResume(){};
64 // Mark adaptor as stopped;
65 mAdaptorStarted = false;
67 virtual void OnDestroy()
74 bool& mAdaptorStarted;
77 SceneHolder::SceneHolder(const Dali::Rect<int>& positionSize)
79 mScene(Dali::Integration::Scene::New(Dali::Size(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height)))),
80 mRenderSurface(new TestRenderSurface(positionSize))
84 SceneHolder::~SceneHolder()
86 if(Dali::Adaptor::IsAvailable())
88 AdaptorImpl::GetImpl(AdaptorImpl::Get()).RemoveWindow(this);
92 void SceneHolder::Add(Dali::Actor actor)
97 void SceneHolder::Remove(Dali::Actor actor)
102 Dali::Layer SceneHolder::GetRootLayer() const
104 return mScene.GetRootLayer();
107 void SceneHolder::SetBackgroundColor(Vector4 color)
109 return mScene.SetBackgroundColor(color);
112 Vector4 SceneHolder::GetBackgroundColor() const
114 return mScene.GetBackgroundColor();
117 void SceneHolder::FeedTouchPoint(Dali::TouchPoint& point, int timeStamp)
121 void SceneHolder::FeedWheelEvent(Dali::WheelEvent& wheelEvent)
125 void SceneHolder::FeedKeyEvent(Dali::KeyEvent& keyEvent)
129 Dali::Integration::SceneHolder::KeyEventSignalType& SceneHolder::KeyEventSignal()
131 return mScene.KeyEventSignal();
134 Dali::Integration::SceneHolder::KeyEventGeneratedSignalType& SceneHolder::KeyEventGeneratedSignal()
136 return mScene.KeyEventGeneratedSignal();
139 Dali::Integration::SceneHolder::TouchEventSignalType& SceneHolder::TouchedSignal()
141 return mScene.TouchedSignal();
144 Dali::Integration::SceneHolder::WheelEventSignalType& SceneHolder::WheelEventSignal()
146 return mScene.WheelEventSignal();
149 Dali::Integration::SceneHolder::WheelEventGeneratedSignalType& SceneHolder::WheelEventGeneratedSignal()
151 return mScene.WheelEventGeneratedSignal();
154 Integration::Scene SceneHolder::GetScene()
159 Dali::Integration::RenderSurfaceInterface& SceneHolder::GetRenderSurface()
161 return *mRenderSurface;
164 Dali::RenderTaskList SceneHolder::GetRenderTaskList()
166 return mScene.GetRenderTaskList();
169 } // namespace Adaptor
171 } // namespace Internal
173 ///////////////////////////////////////////////////////////////////////////////
175 // Dali::Integration::SceneHolder Stub
177 ///////////////////////////////////////////////////////////////////////////////
179 namespace Integration
181 SceneHolder::SceneHolder()
183 // Dali::Internal::Adaptor::Adaptor::Get().WindowCreatedSignal().Emit( *this );
186 SceneHolder::~SceneHolder()
190 SceneHolder::SceneHolder(const SceneHolder& handle)
195 SceneHolder::SceneHolder(Internal::Adaptor::SceneHolder* internal)
196 : BaseHandle(internal)
200 SceneHolder& SceneHolder::operator=(const SceneHolder& rhs)
202 BaseHandle::operator=(rhs);
206 Dali::Integration::SceneHolder SceneHolder::Get(Dali::Actor actor)
208 Internal::Adaptor::SceneHolder* sceneHolderImpl = nullptr;
210 if(Dali::Adaptor::IsAvailable())
212 sceneHolderImpl = AdaptorImpl::GetImpl(AdaptorImpl::Get()).GetWindow(actor);
215 return Dali::Integration::SceneHolder(sceneHolderImpl);
218 void SceneHolder::Add(Actor actor)
220 GetImplementation(*this).Add(actor);
223 void SceneHolder::Remove(Actor actor)
225 GetImplementation(*this).Remove(actor);
228 Dali::Layer SceneHolder::GetRootLayer() const
230 return GetImplementation(*this).GetRootLayer();
233 void SceneHolder::SetBackgroundColor(Vector4 color)
235 GetImplementation(*this).SetBackgroundColor(color);
238 Vector4 SceneHolder::GetBackgroundColor() const
240 return GetImplementation(*this).GetBackgroundColor();
243 void SceneHolder::FeedTouchPoint(Dali::TouchPoint& point, int timeStamp)
245 GetImplementation(*this).FeedTouchPoint(point, timeStamp);
248 void SceneHolder::FeedWheelEvent(Dali::WheelEvent& wheelEvent)
250 GetImplementation(*this).FeedWheelEvent(wheelEvent);
253 void SceneHolder::FeedKeyEvent(Dali::KeyEvent& keyEvent)
255 GetImplementation(*this).FeedKeyEvent(keyEvent);
258 RenderTaskList SceneHolder::GetRenderTaskList()
260 return GetImplementation(*this).GetRenderTaskList();
263 SceneHolder::KeyEventSignalType& SceneHolder::KeyEventSignal()
265 return GetImplementation(*this).KeyEventSignal();
268 SceneHolder::KeyEventGeneratedSignalType& SceneHolder::KeyEventGeneratedSignal()
270 return GetImplementation(*this).KeyEventGeneratedSignal();
273 SceneHolder::TouchEventSignalType& SceneHolder::TouchedSignal()
275 return GetImplementation(*this).TouchedSignal();
278 SceneHolder::WheelEventSignalType& SceneHolder::WheelEventSignal()
280 return GetImplementation(*this).WheelEventSignal();
283 SceneHolder::WheelEventGeneratedSignalType& SceneHolder::WheelEventGeneratedSignal()
285 return GetImplementation(*this).WheelEventGeneratedSignal();
288 } // namespace Integration