Add GetRenderTaskList to SceneHolder
[platform/core/uifw/dali-adaptor.git] / dali / integration-api / adaptor-framework / scene-holder.h
1 #ifndef DALI_INTEGRATION_SCENEHOLDER_H
2 #define DALI_INTEGRATION_SCENEHOLDER_H
3
4 /*
5  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/dali-adaptor-common.h>
23 #include <dali/public-api/math/vector4.h>
24 #include <dali/public-api/object/base-handle.h>
25 #include <dali/public-api/signals/dali-signal.h>
26
27 namespace Dali
28 {
29 class Actor;
30 class Layer;
31 class Any;
32 class TouchEvent;
33 class WheelEvent;
34 struct TouchPoint;
35 class KeyEvent;
36 class RenderTaskList;
37
38 namespace Internal DALI_INTERNAL
39 {
40 namespace Adaptor
41 {
42 class SceneHolder;
43
44 }
45
46 } // namespace DALI_INTERNAL
47
48 namespace Integration
49 {
50 /**
51  * @brief SceneHolder is responsible for creating a Scene for rendering.
52  */
53 class DALI_ADAPTOR_API SceneHolder : public BaseHandle
54 {
55 public:
56   typedef Signal<void(const Dali::KeyEvent&)> KeyEventSignalType; ///< Key event signal type
57
58   typedef Signal<bool(const Dali::KeyEvent&)> KeyEventGeneratedSignalType; ///< Key event generated signal type
59
60   typedef Signal<void(const Dali::TouchEvent&)> TouchEventSignalType; ///< Touch signal type
61
62   typedef Signal<void(const Dali::WheelEvent&)> WheelEventSignalType; ///< Touched signal type
63
64   typedef Signal<bool(const Dali::WheelEvent&)> WheelEventGeneratedSignalType; ///< Wheel event generated signal type
65
66   /**
67    * @brief Create an uninitialized SceneHolder handle.
68    */
69   SceneHolder();
70
71   /**
72    * @brief Destructor
73    *
74    * This is non-virtual since derived Handle types must not contain data or virtual methods.
75    */
76   ~SceneHolder();
77
78   /**
79    * @brief This copy constructor is required for (smart) pointer semantics.
80    *
81    * @param [in] handle A reference to the copied handle
82    */
83   SceneHolder(const SceneHolder& handle);
84
85   /**
86    * @brief This assignment operator is required for (smart) pointer semantics.
87    *
88    * @param [in] rhs  A reference to the copied handle
89    * @return A reference to this
90    */
91   SceneHolder& operator=(const SceneHolder& rhs);
92
93   /**
94    * @brief Adds a child Actor to the SceneHolder.
95    *
96    * The child will be referenced.
97    * @param[in] actor The child
98    * @pre The actor has been initialized.
99    * @pre The actor does not have a parent.
100    */
101   void Add(Actor actor);
102
103   /**
104    * @brief Removes a child Actor from the SceneHolder.
105    *
106    * The child will be unreferenced.
107    * @param[in] actor The child
108    * @pre The actor has been added to the SceneHolder.
109    */
110   void Remove(Actor actor);
111
112   /**
113    * @brief Returns the Scene's Root Layer.
114    *
115    * @return The root layer
116    */
117   Layer GetRootLayer() const;
118
119   /**
120    * @brief Sets the background color.
121    *
122    * @param[in] color The new background color
123    */
124   void SetBackgroundColor(Vector4 color);
125
126   /**
127    * @brief Gets the background color.
128    *
129    * @return The background color
130    */
131   Vector4 GetBackgroundColor() const;
132
133   /**
134    * @brief Gets the native handle.
135    *
136    * When users call this function, it wraps the actual type used by the underlying system.
137    *
138    * @return The native handle or an empty handle
139    */
140   Any GetNativeHandle() const;
141
142   /**
143    * @brief Feed (Send) touch event to core
144    * @param[in] point The touch point
145    * @param[in] timeStamp The time stamp
146    */
147   void FeedTouchPoint(Dali::TouchPoint& point, int timeStamp);
148
149   /**
150    * @brief Feed (Send) wheel event to core
151    * @param[in] wheelEvent The wheel event
152    */
153   void FeedWheelEvent(Dali::WheelEvent& wheelEvent);
154
155   /**
156    * @brief Feed (Send) key event to core
157    * @param[in] keyEvent The key event holding the key information.
158    */
159   void FeedKeyEvent(Dali::KeyEvent& keyEvent);
160
161   /**
162    * @brief Retrieves the list of render-tasks.
163    * @return A valid handle to a RenderTaskList
164    */
165   RenderTaskList GetRenderTaskList();
166
167   /**
168    * @brief Retrieve the SceneHolder that the given actor is added to.
169    *
170    * @param[in] actor The actor
171    * @return The SceneHolder the actor is added to or an empty handle if the actor is not added to any SceneHolder.
172    */
173   static SceneHolder Get(Actor actor);
174
175   /**
176    * @brief This signal is emitted when key event is received.
177    *
178    * A callback of the following type may be connected:
179    * @code
180    *   void YourCallbackName(const KeyEvent& event);
181    * @endcode
182    * @return The signal to connect to
183    */
184   KeyEventSignalType& KeyEventSignal();
185
186   /**
187    * @brief This signal is emitted when key event is received.
188    *
189    * A callback of the following type may be connected:
190    * @code
191    *   bool YourCallbackName(const KeyEvent& event);
192    * @endcode
193    * @return The signal to connect to
194    */
195   KeyEventGeneratedSignalType& KeyEventGeneratedSignal();
196
197   /**
198    * @brief This signal is emitted when key event is received.
199    * Intercepts KeyEvents in the window before dispatching KeyEvents to the control.
200    * If a KeyEvent is consumed, no KeyEvent is delivered to the control.
201    *
202    * A callback of the following type may be connected:
203    * @code
204    *   bool YourCallbackName(const KeyEvent& event);
205    * @endcode
206    * @return The signal to connect to
207    */
208   KeyEventGeneratedSignalType& InterceptKeyEventSignal();
209
210   /**
211    * @brief This signal is emitted when the screen is touched and when the touch ends
212    * (i.e. the down & up touch events only).
213    *
214    * If there are multiple touch points, then this will be emitted when the first touch occurs and
215    * then when the last finger is lifted.
216    * An interrupted event will also be emitted (if it occurs).
217    * A callback of the following type may be connected:
218    * @code
219    *   void YourCallbackName( TouchEvent event );
220    * @endcode
221    * @return The touch signal to connect to
222    * @note Motion events are not emitted.
223    */
224   TouchEventSignalType& TouchedSignal();
225
226   /**
227    * @brief This signal is emitted when wheel event is received.
228    *
229    * A callback of the following type may be connected:
230    * @code
231    *   void YourCallbackName(const WheelEvent& event);
232    * @endcode
233    * @return The signal to connect to
234    */
235   WheelEventSignalType& WheelEventSignal();
236
237   /**
238    * @brief This signal is emitted to KeyboardFocusManager when a custom wheel type event is received.
239    * When a custom wheel event occurs, it need to process the focused actor first.
240    *
241    * Therefore, KeyboardFocusManager first checks whether WheelEvent is generated as WheelEventGeneratedSignal.
242    * This is only valid for custom wheel events.
243    *
244    * A callback of the following type may be connected:
245    * @code
246    *   bool YourCallbackName(const WheelEvent& event);
247    * @endcode
248    * @return The signal to connect to
249    */
250   WheelEventGeneratedSignalType& WheelEventGeneratedSignal();
251
252 public: // Not intended for application developers
253   /**
254    * @brief This constructor is used internally to create additional SceneHolder handles.
255    *
256    * @param[in] sceneHolder A pointer to a newly allocated Dali resource
257    */
258   explicit SceneHolder(Internal::Adaptor::SceneHolder* sceneHolder);
259 };
260
261 } // namespace Integration
262
263 } // namespace Dali
264
265 #endif // DALI_INTEGRATION_SCENEHOLDER_H