1 #ifndef DALI_INTEGRATION_SCENEHOLDER_H
2 #define DALI_INTEGRATION_SCENEHOLDER_H
5 * Copyright (c) 2022 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>
37 namespace Internal DALI_INTERNAL
45 } // namespace DALI_INTERNAL
50 * @brief SceneHolder is responsible for creating a Scene for rendering.
52 class DALI_ADAPTOR_API SceneHolder : public BaseHandle
55 typedef Signal<void(const Dali::KeyEvent&)> KeyEventSignalType; ///< Key event signal type
57 typedef Signal<bool(const Dali::KeyEvent&)> KeyEventGeneratedSignalType; ///< Key event generated signal type
59 typedef Signal<void(const Dali::TouchEvent&)> TouchEventSignalType; ///< Touch signal type
61 typedef Signal<void(const Dali::WheelEvent&)> WheelEventSignalType; ///< Touched signal type
63 typedef Signal<bool(const Dali::WheelEvent&)> WheelEventGeneratedSignalType; ///< Wheel event generated signal type
66 * @brief Create an uninitialized SceneHolder handle.
73 * This is non-virtual since derived Handle types must not contain data or virtual methods.
78 * @brief This copy constructor is required for (smart) pointer semantics.
80 * @param [in] handle A reference to the copied handle
82 SceneHolder(const SceneHolder& handle);
85 * @brief This assignment operator is required for (smart) pointer semantics.
87 * @param [in] rhs A reference to the copied handle
88 * @return A reference to this
90 SceneHolder& operator=(const SceneHolder& rhs);
93 * @brief Adds a child Actor to the SceneHolder.
95 * The child will be referenced.
96 * @param[in] actor The child
97 * @pre The actor has been initialized.
98 * @pre The actor does not have a parent.
100 void Add(Actor actor);
103 * @brief Removes a child Actor from the SceneHolder.
105 * The child will be unreferenced.
106 * @param[in] actor The child
107 * @pre The actor has been added to the SceneHolder.
109 void Remove(Actor actor);
112 * @brief Returns the Scene's Root Layer.
114 * @return The root layer
116 Layer GetRootLayer() const;
119 * @brief Sets the background color.
121 * @param[in] color The new background color
123 void SetBackgroundColor(Vector4 color);
126 * @brief Gets the background color.
128 * @return The background color
130 Vector4 GetBackgroundColor() const;
133 * @brief Gets the native handle.
135 * When users call this function, it wraps the actual type used by the underlying system.
137 * @return The native handle or an empty handle
139 Any GetNativeHandle() const;
142 * @brief Feed (Send) touch event to core
143 * @param[in] point The touch point
144 * @param[in] timeStamp The time stamp
146 void FeedTouchPoint(Dali::TouchPoint& point, int timeStamp);
149 * @brief Feed (Send) wheel event to core
150 * @param[in] wheelEvent The wheel event
152 void FeedWheelEvent(Dali::WheelEvent& wheelEvent);
155 * @brief Feed (Send) key event to core
156 * @param[in] keyEvent The key event holding the key information.
158 void FeedKeyEvent(Dali::KeyEvent& keyEvent);
161 * @brief Retrieve the SceneHolder that the given actor is added to.
163 * @param[in] actor The actor
164 * @return The SceneHolder the actor is added to or an empty handle if the actor is not added to any SceneHolder.
166 static SceneHolder Get(Actor actor);
169 * @brief This signal is emitted when key event is received.
171 * A callback of the following type may be connected:
173 * void YourCallbackName(const KeyEvent& event);
175 * @return The signal to connect to
177 KeyEventSignalType& KeyEventSignal();
180 * @brief This signal is emitted when key event is received.
182 * A callback of the following type may be connected:
184 * bool YourCallbackName(const KeyEvent& event);
186 * @return The signal to connect to
188 KeyEventGeneratedSignalType& KeyEventGeneratedSignal();
191 * @brief This signal is emitted when the screen is touched and when the touch ends
192 * (i.e. the down & up touch events only).
194 * If there are multiple touch points, then this will be emitted when the first touch occurs and
195 * then when the last finger is lifted.
196 * An interrupted event will also be emitted (if it occurs).
197 * A callback of the following type may be connected:
199 * void YourCallbackName( TouchEvent event );
201 * @return The touch signal to connect to
202 * @note Motion events are not emitted.
204 TouchEventSignalType& TouchedSignal();
207 * @brief This signal is emitted when wheel event is received.
209 * A callback of the following type may be connected:
211 * void YourCallbackName(const WheelEvent& event);
213 * @return The signal to connect to
215 WheelEventSignalType& WheelEventSignal();
218 * @brief This signal is emitted to KeyboardFocusManager when a custom wheel type event is received.
219 * When a custom wheel event occurs, it need to process the focused actor first.
221 * Therefore, KeyboardFocusManager first checks whether WheelEvent is generated as WheelEventGeneratedSignal.
222 * This is only valid for custom wheel events.
224 * A callback of the following type may be connected:
226 * bool YourCallbackName(const WheelEvent& event);
228 * @return The signal to connect to
230 WheelEventGeneratedSignalType& WheelEventGeneratedSignal();
232 public: // Not intended for application developers
234 * @brief This constructor is used internally to create additional SceneHolder handles.
236 * @param[in] sceneHolder A pointer to a newly allocated Dali resource
238 explicit SceneHolder(Internal::Adaptor::SceneHolder* sceneHolder);
241 } // namespace Integration
245 #endif // DALI_INTEGRATION_SCENEHOLDER_H