1 #ifndef DALI_INTEGRATION_INTERNAL_SCENEHOLDER_H
2 #define DALI_INTEGRATION_INTERNAL_SCENEHOLDER_H
5 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
24 #include <dali/public-api/object/base-object.h>
25 #include <dali/public-api/common/intrusive-ptr.h>
26 #include <dali/integration-api/scene.h>
27 #include <dali/integration-api/events/key-event-integ.h>
28 #include <dali/integration-api/events/point.h>
29 #include <dali/integration-api/events/touch-event-combiner.h>
32 #ifdef DALI_ADAPTOR_COMPILATION
33 #include <dali/integration-api/render-surface-interface.h>
34 #include <dali/integration-api/scene-holder.h>
36 #include <dali/integration-api/adaptors/render-surface-interface.h>
37 #include <dali/integration-api/adaptors/scene-holder.h>
69 using SceneHolderPtr = IntrusivePtr< SceneHolder >;
72 * @brief SceneHolder creates a Scene for rendering.
74 class DALI_ADAPTOR_API SceneHolder : public BaseObject
80 * @copydoc Dali::Integration::SceneHolder::Add
82 void Add( Dali::Actor actor );
85 * @copydoc Dali::Integration::SceneHolder::Remove
87 void Remove( Dali::Actor actor );
90 * @copydoc Dali::Integration::SceneHolder::GetRootLayer
92 Dali::Layer GetRootLayer() const;
95 * @brief Gets the window name.
96 * @return The name of the window
98 std::string GetName() const;
101 * @brief Retrieve the unique ID of the window.
104 uint32_t GetId() const;
107 * @brief Retrieve the Scene.
110 Dali::Integration::Scene GetScene();
113 * @brief Set the render surface
114 * @param[in] surface The render surface
116 void SetSurface( Dali::RenderSurfaceInterface* surface );
119 * @brief Called when the surface set is resized.
121 void SurfaceResized( bool forceUpdate );
124 * @brief Get the render surface
125 * @return The render surface
127 Dali::RenderSurfaceInterface* GetSurface() const;
130 * @brief Set the adaptor to the scene holder
131 * @param[in] adaptor An initialized adaptor
133 void SetAdaptor( Dali::Adaptor& adaptor );
136 * @copydoc Dali::Integration::SceneHolder::SetBackgroundColor
138 void SetBackgroundColor( const Dali::Vector4& color );
141 * @copydoc Dali::Integration::SceneHolder::GetBackgroundColor
143 Vector4 GetBackgroundColor() const;
146 * @brief Pause the rendering of the scene holder.
151 * @brief Resume the rendering of the scene holder (from pause).
156 * @copydoc Dali::Integration::SceneHolder::FeedTouchPoint
158 void FeedTouchPoint( Dali::Integration::Point& point, int timeStamp );
161 * @copydoc Dali::Integration::SceneHolder::FeedWheelEvent
163 void FeedWheelEvent( Dali::Integration::WheelEvent& wheelEvent );
166 * @copydoc Dali::Integration::SceneHolder::FeedKeyEvent
168 void FeedKeyEvent( Dali::Integration::KeyEvent& keyEvent );
170 public: // The following methods can be overridden if required
173 * @brief Returns whether the Scene is visible or not.
174 * @return True if the Scene is visible, false otherwise.
176 virtual bool IsVisible() const;
178 public: // The following methods must be overridden
181 * @copydoc Dali::Integration::SceneHolder::GetNativeHandle
183 virtual Dali::Any GetNativeHandle() const = 0;
191 SceneHolder(const SceneHolder&) = delete;
194 SceneHolder& operator=(const SceneHolder& rhs) = delete;
199 virtual ~SceneHolder();
201 private: // The following methods can be overridden if required
204 * @brief Called by the base class to inform deriving classes that the adaptor has been set.
205 * @param[in] adaptor The adaptor
207 virtual void OnAdaptorSet( Dali::Adaptor& adaptor ) {};
210 * @brief Called by the base class to inform deriving classes that a new surface has been set.
211 * @param[in] surface The new render surface
213 virtual void OnSurfaceSet( Dali::RenderSurfaceInterface* surface ) {};
216 * @brief Called by the base class to inform deriving classes that we are being paused.
218 virtual void OnPause() {};
221 * @brief Called by the base class to inform deriving classes that we are resuming from a paused state.
223 virtual void OnResume() {};
226 * Recalculate the touch position if required
227 * @param[in,out] point The touch point
229 virtual void RecalculateTouchPosition( Integration::Point& point ) {};
234 * Resets the event handling.
240 static uint32_t mSceneHolderCounter; ///< A counter to track the SceneHolder creation
242 class SceneHolderLifeCycleObserver;
243 std::unique_ptr< SceneHolderLifeCycleObserver > mLifeCycleObserver; ///< The adaptor life cycle observer
247 uint32_t mId; ///< A unique ID to identify the SceneHolder starting from 0
248 Dali::Integration::Scene mScene; ///< The Scene
249 std::string mName; ///< The name of the SceneHolder
251 std::unique_ptr< Dali::RenderSurfaceInterface > mSurface; ///< The window rendering surface
252 Adaptor* mAdaptor; ///< The adaptor
254 Dali::Integration::TouchEventCombiner mCombiner; ///< Combines multi-touch events.
256 bool mAdaptorStarted:1; ///< Whether the adaptor has started or not
257 bool mVisible:1; ///< Whether the scene is visible or not
264 // Get impl of handle
265 inline Internal::Adaptor::SceneHolder& GetImplementation( Dali::Integration::SceneHolder& sceneHolder )
267 DALI_ASSERT_ALWAYS( sceneHolder && "SceneHolder handle is empty" );
268 Dali::RefObject& object = sceneHolder.GetBaseObject();
269 return static_cast<Internal::Adaptor::SceneHolder&>( object );
272 inline const Internal::Adaptor::SceneHolder& GetImplementation( const Dali::Integration::SceneHolder& sceneHolder )
274 DALI_ASSERT_ALWAYS( sceneHolder && "SceneHolder handle is empty" );
275 const Dali::RefObject& object = sceneHolder.GetBaseObject();
276 return static_cast<const Internal::Adaptor::SceneHolder&>( object );
281 #endif // DALI_INTEGRATION_INTERNAL_SCENEHOLDER_H