1 #ifndef DALI_INTEGRATION_SCENEHOLDER_H
2 #define DALI_INTEGRATION_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.
22 #include <dali/public-api/dali-adaptor-common.h>
23 #include <dali/public-api/object/base-handle.h>
24 #include <dali/public-api/math/vector4.h>
25 #include <dali/public-api/signals/dali-signal.h>
38 namespace Internal DALI_INTERNAL
54 * @brief SceneHolder is responsible for creating a Scene for rendering.
56 class DALI_ADAPTOR_API SceneHolder : public BaseHandle
60 typedef Signal< void (const Dali::KeyEvent&) > KeyEventSignalType; ///< Key event signal type
62 typedef Signal< bool (const Dali::KeyEvent&) > KeyEventGeneratedSignalType; ///< Key event generated signal type
64 typedef Signal< void (const Dali::TouchData&) > TouchSignalType; ///< Touch signal type
66 typedef Signal< void (const Dali::WheelEvent&) > WheelEventSignalType; ///< Touched signal type
69 * @brief Create an uninitialized SceneHolder handle.
76 * This is non-virtual since derived Handle types must not contain data or virtual methods.
81 * @brief This copy constructor is required for (smart) pointer semantics.
83 * @param [in] handle A reference to the copied handle
85 SceneHolder( const SceneHolder& handle );
88 * @brief This assignment operator is required for (smart) pointer semantics.
90 * @param [in] rhs A reference to the copied handle
91 * @return A reference to this
93 SceneHolder& operator=( const SceneHolder& rhs );
96 * @brief Adds a child Actor to the SceneHolder.
98 * The child will be referenced.
99 * @param[in] actor The child
100 * @pre The actor has been initialized.
101 * @pre The actor does not have a parent.
103 void Add( Actor actor );
106 * @brief Removes a child Actor from the SceneHolder.
108 * The child will be unreferenced.
109 * @param[in] actor The child
110 * @pre The actor has been added to the SceneHolder.
112 void Remove( Actor actor );
115 * @brief Returns the Scene's Root Layer.
117 * @return The root layer
119 Layer GetRootLayer() const;
122 * @brief Sets the background color.
124 * @param[in] color The new background color
126 void SetBackgroundColor( Vector4 color );
129 * @brief Gets the background color.
131 * @return The background color
133 Vector4 GetBackgroundColor() const;
136 * @brief Gets the native handle.
138 * When users call this function, it wraps the actual type used by the underlying system.
140 * @return The native handle or an empty handle
142 Any GetNativeHandle() const;
145 * @brief Feed (Send) touch event to core
146 * @param[in] point The touch point
147 * @param[in] timeStamp The time stamp
149 void FeedTouchPoint( Dali::TouchPoint& point, int timeStamp );
152 * @brief Feed (Send) wheel event to core
153 * @param[in] wheelEvent The wheel event
155 void FeedWheelEvent( Dali::WheelEvent& wheelEvent );
158 * @brief Feed (Send) key event to core
159 * @param[in] keyEvent The key event holding the key information.
161 void FeedKeyEvent( Dali::KeyEvent& keyEvent );
164 * @brief Retrieve the SceneHolder that the given actor is added to.
166 * @param[in] actor The actor
167 * @return The SceneHolder the actor is added to or an empty handle if the actor is not added to any SceneHolder.
169 static SceneHolder Get( Actor actor );
172 * @brief This signal is emitted when key event is received.
174 * A callback of the following type may be connected:
176 * void YourCallbackName(const KeyEvent& event);
178 * @return The signal to connect to
180 KeyEventSignalType& KeyEventSignal();
183 * @brief This signal is emitted when key event is received.
185 * A callback of the following type may be connected:
187 * bool YourCallbackName(const KeyEvent& event);
189 * @return The signal to connect to
191 KeyEventGeneratedSignalType& KeyEventGeneratedSignal();
194 * @brief This signal is emitted when the screen is touched and when the touch ends
195 * (i.e. the down & up touch events only).
197 * If there are multiple touch points, then this will be emitted when the first touch occurs and
198 * then when the last finger is lifted.
199 * An interrupted event will also be emitted (if it occurs).
200 * A callback of the following type may be connected:
202 * void YourCallbackName( TouchData event );
204 * @return The touch signal to connect to
205 * @note Motion events are not emitted.
207 TouchSignalType& TouchSignal();
210 * @brief This signal is emitted when wheel event is received.
212 * A callback of the following type may be connected:
214 * void YourCallbackName(const WheelEvent& event);
216 * @return The signal to connect to
218 WheelEventSignalType& WheelEventSignal();
220 public: // Not intended for application developers
223 * @brief This constructor is used internally to create additional SceneHolder handles.
225 * @param[in] sceneHolder A pointer to a newly allocated Dali resource
227 explicit SceneHolder( Internal::Adaptor::SceneHolder* sceneHolder );
231 } // namespace Integration
235 #endif // DALI_INTEGRATION_SCENEHOLDER_H