Renamed TouchSignal to TouchedSignal
[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) 2020 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/object/base-handle.h>
24 #include <dali/public-api/math/vector4.h>
25 #include <dali/public-api/signals/dali-signal.h>
26
27 namespace Dali
28 {
29
30 class Actor;
31 class Layer;
32 class Any;
33 class TouchEvent;
34 class WheelEvent;
35 struct TouchPoint;
36 class KeyEvent;
37
38 namespace Internal DALI_INTERNAL
39 {
40
41 namespace Adaptor
42 {
43
44 class SceneHolder;
45
46 }
47
48 }
49
50 namespace Integration
51 {
52
53 /**
54  * @brief SceneHolder is responsible for creating a Scene for rendering.
55  */
56 class DALI_ADAPTOR_API SceneHolder : public BaseHandle
57 {
58 public:
59
60   typedef Signal< void (const Dali::KeyEvent&) > KeyEventSignalType;          ///< Key event signal type
61
62   typedef Signal< bool (const Dali::KeyEvent&) > KeyEventGeneratedSignalType; ///< Key event generated signal type
63
64   typedef Signal< void (const Dali::TouchEvent&) > TouchEventSignalType;      ///< Touch signal type
65
66   typedef Signal< void (const Dali::WheelEvent&) > WheelEventSignalType;      ///< Touched signal type
67
68   /**
69    * @brief Create an uninitialized SceneHolder handle.
70    */
71   SceneHolder();
72
73   /**
74    * @brief Destructor
75    *
76    * This is non-virtual since derived Handle types must not contain data or virtual methods.
77    */
78   ~SceneHolder();
79
80   /**
81    * @brief This copy constructor is required for (smart) pointer semantics.
82    *
83    * @param [in] handle A reference to the copied handle
84    */
85   SceneHolder( const SceneHolder& handle );
86
87   /**
88    * @brief This assignment operator is required for (smart) pointer semantics.
89    *
90    * @param [in] rhs  A reference to the copied handle
91    * @return A reference to this
92    */
93   SceneHolder& operator=( const SceneHolder& rhs );
94
95   /**
96    * @brief Adds a child Actor to the SceneHolder.
97    *
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.
102    */
103   void Add( Actor actor );
104
105   /**
106    * @brief Removes a child Actor from the SceneHolder.
107    *
108    * The child will be unreferenced.
109    * @param[in] actor The child
110    * @pre The actor has been added to the SceneHolder.
111    */
112   void Remove( Actor actor );
113
114   /**
115    * @brief Returns the Scene's Root Layer.
116    *
117    * @return The root layer
118    */
119   Layer GetRootLayer() const;
120
121   /**
122    * @brief Sets the background color.
123    *
124    * @param[in] color The new background color
125    */
126   void SetBackgroundColor( Vector4 color );
127
128   /**
129    * @brief Gets the background color.
130    *
131    * @return The background color
132    */
133   Vector4 GetBackgroundColor() const;
134
135   /**
136    * @brief Gets the native handle.
137    *
138    * When users call this function, it wraps the actual type used by the underlying system.
139    *
140    * @return The native handle or an empty handle
141    */
142   Any GetNativeHandle() const;
143
144   /**
145    * @brief Feed (Send) touch event to core
146    * @param[in] point The touch point
147    * @param[in] timeStamp The time stamp
148    */
149   void FeedTouchPoint( Dali::TouchPoint& point, int timeStamp );
150
151   /**
152    * @brief Feed (Send) wheel event to core
153    * @param[in] wheelEvent The wheel event
154    */
155   void FeedWheelEvent( Dali::WheelEvent& wheelEvent );
156
157   /**
158    * @brief Feed (Send) key event to core
159    * @param[in] keyEvent The key event holding the key information.
160    */
161   void FeedKeyEvent( Dali::KeyEvent& keyEvent );
162
163   /**
164    * @brief Retrieve the SceneHolder that the given actor is added to.
165    *
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.
168    */
169   static SceneHolder Get( Actor actor );
170
171   /**
172    * @brief This signal is emitted when key event is received.
173    *
174    * A callback of the following type may be connected:
175    * @code
176    *   void YourCallbackName(const KeyEvent& event);
177    * @endcode
178    * @return The signal to connect to
179    */
180   KeyEventSignalType& KeyEventSignal();
181
182   /**
183    * @brief This signal is emitted when key event is received.
184    *
185    * A callback of the following type may be connected:
186    * @code
187    *   bool YourCallbackName(const KeyEvent& event);
188    * @endcode
189    * @return The signal to connect to
190    */
191   KeyEventGeneratedSignalType& KeyEventGeneratedSignal();
192
193   /**
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).
196    *
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:
201    * @code
202    *   void YourCallbackName( TouchEvent event );
203    * @endcode
204    * @return The touch signal to connect to
205    * @note Motion events are not emitted.
206    */
207   TouchEventSignalType& TouchedSignal();
208
209   /**
210    * @brief This signal is emitted when wheel event is received.
211    *
212    * A callback of the following type may be connected:
213    * @code
214    *   void YourCallbackName(const WheelEvent& event);
215    * @endcode
216    * @return The signal to connect to
217    */
218   WheelEventSignalType& WheelEventSignal();
219
220 public: // Not intended for application developers
221
222   /**
223    * @brief This constructor is used internally to create additional SceneHolder handles.
224    *
225    * @param[in] sceneHolder A pointer to a newly allocated Dali resource
226    */
227   explicit SceneHolder( Internal::Adaptor::SceneHolder* sceneHolder );
228
229 };
230
231 } // namespace Integration
232
233 } // namespace Dali
234
235 #endif // DALI_INTEGRATION_SCENEHOLDER_H