1 #ifndef DALI_INTEGRATION_SCENEHOLDER_H
2 #define DALI_INTEGRATION_SCENEHOLDER_H
5 * Copyright (c) 2020 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
64 * @brief Create an uninitialized SceneHolder handle.
71 * This is non-virtual since derived Handle types must not contain data or virtual methods.
76 * @brief This copy constructor is required for (smart) pointer semantics.
78 * @param [in] handle A reference to the copied handle
80 SceneHolder(const SceneHolder& handle);
83 * @brief This assignment operator is required for (smart) pointer semantics.
85 * @param [in] rhs A reference to the copied handle
86 * @return A reference to this
88 SceneHolder& operator=(const SceneHolder& rhs);
91 * @brief Adds a child Actor to the SceneHolder.
93 * The child will be referenced.
94 * @param[in] actor The child
95 * @pre The actor has been initialized.
96 * @pre The actor does not have a parent.
98 void Add(Actor actor);
101 * @brief Removes a child Actor from the SceneHolder.
103 * The child will be unreferenced.
104 * @param[in] actor The child
105 * @pre The actor has been added to the SceneHolder.
107 void Remove(Actor actor);
110 * @brief Returns the Scene's Root Layer.
112 * @return The root layer
114 Layer GetRootLayer() const;
117 * @brief Sets the background color.
119 * @param[in] color The new background color
121 void SetBackgroundColor(Vector4 color);
124 * @brief Gets the background color.
126 * @return The background color
128 Vector4 GetBackgroundColor() const;
131 * @brief Gets the native handle.
133 * When users call this function, it wraps the actual type used by the underlying system.
135 * @return The native handle or an empty handle
137 Any GetNativeHandle() const;
140 * @brief Feed (Send) touch event to core
141 * @param[in] point The touch point
142 * @param[in] timeStamp The time stamp
144 void FeedTouchPoint(Dali::TouchPoint& point, int timeStamp);
147 * @brief Feed (Send) wheel event to core
148 * @param[in] wheelEvent The wheel event
150 void FeedWheelEvent(Dali::WheelEvent& wheelEvent);
153 * @brief Feed (Send) key event to core
154 * @param[in] keyEvent The key event holding the key information.
156 void FeedKeyEvent(Dali::KeyEvent& keyEvent);
159 * @brief Retrieve the SceneHolder that the given actor is added to.
161 * @param[in] actor The actor
162 * @return The SceneHolder the actor is added to or an empty handle if the actor is not added to any SceneHolder.
164 static SceneHolder Get(Actor actor);
167 * @brief This signal is emitted when key event is received.
169 * A callback of the following type may be connected:
171 * void YourCallbackName(const KeyEvent& event);
173 * @return The signal to connect to
175 KeyEventSignalType& KeyEventSignal();
178 * @brief This signal is emitted when key event is received.
180 * A callback of the following type may be connected:
182 * bool YourCallbackName(const KeyEvent& event);
184 * @return The signal to connect to
186 KeyEventGeneratedSignalType& KeyEventGeneratedSignal();
189 * @brief This signal is emitted when the screen is touched and when the touch ends
190 * (i.e. the down & up touch events only).
192 * If there are multiple touch points, then this will be emitted when the first touch occurs and
193 * then when the last finger is lifted.
194 * An interrupted event will also be emitted (if it occurs).
195 * A callback of the following type may be connected:
197 * void YourCallbackName( TouchEvent event );
199 * @return The touch signal to connect to
200 * @note Motion events are not emitted.
202 TouchEventSignalType& TouchedSignal();
205 * @brief This signal is emitted when wheel event is received.
207 * A callback of the following type may be connected:
209 * void YourCallbackName(const WheelEvent& event);
211 * @return The signal to connect to
213 WheelEventSignalType& WheelEventSignal();
215 public: // Not intended for application developers
217 * @brief This constructor is used internally to create additional SceneHolder handles.
219 * @param[in] sceneHolder A pointer to a newly allocated Dali resource
221 explicit SceneHolder(Internal::Adaptor::SceneHolder* sceneHolder);
224 } // namespace Integration
228 #endif // DALI_INTEGRATION_SCENEHOLDER_H