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