1 #ifndef DALI_INTEGRATION_SCENEHOLDER_H
2 #define DALI_INTEGRATION_SCENEHOLDER_H
5 * Copyright (c) 2023 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.
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>
38 namespace Internal DALI_INTERNAL
46 } // namespace DALI_INTERNAL
51 * @brief SceneHolder is responsible for creating a Scene for rendering.
53 class DALI_ADAPTOR_API SceneHolder : public BaseHandle
56 typedef Signal<void(const Dali::KeyEvent&)> KeyEventSignalType; ///< Key event signal type
58 typedef Signal<bool(const Dali::KeyEvent&)> KeyEventGeneratedSignalType; ///< Key event generated signal type
60 typedef Signal<void(const Dali::TouchEvent&)> TouchEventSignalType; ///< Touch signal type
62 typedef Signal<void(const Dali::WheelEvent&)> WheelEventSignalType; ///< Touched signal type
64 typedef Signal<bool(const Dali::WheelEvent&)> WheelEventGeneratedSignalType; ///< Wheel event generated signal type
67 * @brief Create an uninitialized SceneHolder handle.
74 * This is non-virtual since derived Handle types must not contain data or virtual methods.
79 * @brief This copy constructor is required for (smart) pointer semantics.
81 * @param [in] handle A reference to the copied handle
83 SceneHolder(const SceneHolder& handle);
86 * @brief This assignment operator is required for (smart) pointer semantics.
88 * @param [in] rhs A reference to the copied handle
89 * @return A reference to this
91 SceneHolder& operator=(const SceneHolder& rhs);
94 * @brief Adds a child Actor to the SceneHolder.
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.
101 void Add(Actor actor);
104 * @brief Removes a child Actor from the SceneHolder.
106 * The child will be unreferenced.
107 * @param[in] actor The child
108 * @pre The actor has been added to the SceneHolder.
110 void Remove(Actor actor);
113 * @brief Returns the Scene's Root Layer.
115 * @return The root layer
117 Layer GetRootLayer() const;
120 * @brief Sets the background color.
122 * @param[in] color The new background color
124 void SetBackgroundColor(Vector4 color);
127 * @brief Gets the background color.
129 * @return The background color
131 Vector4 GetBackgroundColor() const;
134 * @brief Gets the native handle.
136 * When users call this function, it wraps the actual type used by the underlying system.
138 * @return The native handle or an empty handle
140 Any GetNativeHandle() const;
143 * @brief Feed (Send) touch event to core
144 * @param[in] point The touch point
145 * @param[in] timeStamp The time stamp
147 void FeedTouchPoint(Dali::TouchPoint& point, int timeStamp);
150 * @brief Feed (Send) wheel event to core
151 * @param[in] wheelEvent The wheel event
153 void FeedWheelEvent(Dali::WheelEvent& wheelEvent);
156 * @brief Feed (Send) key event to core
157 * @param[in] keyEvent The key event holding the key information.
159 void FeedKeyEvent(Dali::KeyEvent& keyEvent);
162 * @brief Retrieves the list of render-tasks.
163 * @return A valid handle to a RenderTaskList
165 RenderTaskList GetRenderTaskList();
168 * @brief Retrieve the SceneHolder that the given actor is added to.
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.
173 static SceneHolder Get(Actor actor);
176 * @brief This signal is emitted when key event is received.
178 * A callback of the following type may be connected:
180 * void YourCallbackName(const KeyEvent& event);
182 * @return The signal to connect to
184 KeyEventSignalType& KeyEventSignal();
187 * @brief This signal is emitted when key event is received.
189 * A callback of the following type may be connected:
191 * bool YourCallbackName(const KeyEvent& event);
193 * @return The signal to connect to
195 KeyEventGeneratedSignalType& KeyEventGeneratedSignal();
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.
202 * A callback of the following type may be connected:
204 * bool YourCallbackName(const KeyEvent& event);
206 * @return The signal to connect to
208 KeyEventGeneratedSignalType& InterceptKeyEventSignal();
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).
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:
219 * void YourCallbackName( TouchEvent event );
221 * @return The touch signal to connect to
222 * @note Motion events are not emitted.
224 TouchEventSignalType& TouchedSignal();
227 * @brief This signal is emitted when wheel event is received.
229 * A callback of the following type may be connected:
231 * void YourCallbackName(const WheelEvent& event);
233 * @return The signal to connect to
235 WheelEventSignalType& WheelEventSignal();
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.
241 * Therefore, KeyboardFocusManager first checks whether WheelEvent is generated as WheelEventGeneratedSignal.
242 * This is only valid for custom wheel events.
244 * A callback of the following type may be connected:
246 * bool YourCallbackName(const WheelEvent& event);
248 * @return The signal to connect to
250 WheelEventGeneratedSignalType& WheelEventGeneratedSignal();
252 public: // Not intended for application developers
254 * @brief This constructor is used internally to create additional SceneHolder handles.
256 * @param[in] sceneHolder A pointer to a newly allocated Dali resource
258 explicit SceneHolder(Internal::Adaptor::SceneHolder* sceneHolder);
261 } // namespace Integration
265 #endif // DALI_INTEGRATION_SCENEHOLDER_H