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 Get the render surface
120 * @return The render surface
122 Dali::RenderSurfaceInterface* GetSurface() const;
125 * @brief Set the adaptor to the scene holder
126 * @param[in] adaptor An initialized adaptor
128 void SetAdaptor( Dali::Adaptor& adaptor );
131 * @copydoc Dali::Integration::SceneHolder::SetBackgroundColor
133 void SetBackgroundColor( const Dali::Vector4& color );
136 * @copydoc Dali::Integration::SceneHolder::GetBackgroundColor
138 Vector4 GetBackgroundColor() const;
141 * @brief Pause the rendering of the scene holder.
146 * @brief Resume the rendering of the scene holder (from pause).
151 * @copydoc Dali::Integration::SceneHolder::FeedTouchPoint
153 void FeedTouchPoint( Dali::Integration::Point& point, int timeStamp );
156 * @copydoc Dali::Integration::SceneHolder::FeedWheelEvent
158 void FeedWheelEvent( Dali::Integration::WheelEvent& wheelEvent );
161 * @copydoc Dali::Integration::SceneHolder::FeedKeyEvent
163 void FeedKeyEvent( Dali::Integration::KeyEvent& keyEvent );
165 public: // The following methods can be overridden if required
168 * @brief Returns whether the Scene is visible or not.
169 * @return True if the Scene is visible, false otherwise.
171 virtual bool IsVisible() const;
173 public: // The following methods must be overridden
176 * @copydoc Dali::Integration::SceneHolder::GetNativeHandle
178 virtual Dali::Any GetNativeHandle() const = 0;
186 SceneHolder(const SceneHolder&) = delete;
189 SceneHolder& operator=(const SceneHolder& rhs) = delete;
194 virtual ~SceneHolder();
196 private: // The following methods can be overridden if required
199 * @brief Called by the base class to inform deriving classes that the adaptor has been set.
200 * @param[in] adaptor The adaptor
202 virtual void OnAdaptorSet( Dali::Adaptor& adaptor ) {};
205 * @brief Called by the base class to inform deriving classes that a new surface has been set.
206 * @param[in] surface The new render surface
208 virtual void OnSurfaceSet( Dali::RenderSurfaceInterface* surface ) {};
211 * @brief Called by the base class to inform deriving classes that we are being paused.
213 virtual void OnPause() {};
216 * @brief Called by the base class to inform deriving classes that we are resuming from a paused state.
218 virtual void OnResume() {};
221 * Recalculate the touch position if required
222 * @param[in,out] point The touch point
224 virtual void RecalculateTouchPosition( Integration::Point& point ) {};
229 * Resets the event handling.
235 static uint32_t mSceneHolderCounter; ///< A counter to track the SceneHolder creation
237 class SceneHolderLifeCycleObserver;
238 std::unique_ptr< SceneHolderLifeCycleObserver > mLifeCycleObserver; ///< The adaptor life cycle observer
242 uint32_t mId; ///< A unique ID to identify the SceneHolder starting from 0
243 Dali::Integration::Scene mScene; ///< The Scene
244 std::string mName; ///< The name of the SceneHolder
246 std::unique_ptr< Dali::RenderSurfaceInterface > mSurface; ///< The window rendering surface
247 Adaptor* mAdaptor; ///< The adaptor
249 Dali::Integration::TouchEventCombiner mCombiner; ///< Combines multi-touch events.
251 bool mAdaptorStarted:1; ///< Whether the adaptor has started or not
252 bool mVisible:1; ///< Whether the scene is visible or not
259 // Get impl of handle
260 inline Internal::Adaptor::SceneHolder& GetImplementation( Dali::Integration::SceneHolder& sceneHolder )
262 DALI_ASSERT_ALWAYS( sceneHolder && "SceneHolder handle is empty" );
263 Dali::RefObject& object = sceneHolder.GetBaseObject();
264 return static_cast<Internal::Adaptor::SceneHolder&>( object );
267 inline const Internal::Adaptor::SceneHolder& GetImplementation( const Dali::Integration::SceneHolder& sceneHolder )
269 DALI_ASSERT_ALWAYS( sceneHolder && "SceneHolder handle is empty" );
270 const Dali::RefObject& object = sceneHolder.GetBaseObject();
271 return static_cast<const Internal::Adaptor::SceneHolder&>( object );
276 #endif // DALI_INTEGRATION_INTERNAL_SCENEHOLDER_H