[Tizen] Remove graphics-api relative codes in public-api/application.h
[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/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   /**
64    * @brief Create an uninitialized SceneHolder handle.
65    */
66   SceneHolder();
67
68   /**
69    * @brief Destructor
70    *
71    * This is non-virtual since derived Handle types must not contain data or virtual methods.
72    */
73   ~SceneHolder();
74
75   /**
76    * @brief This copy constructor is required for (smart) pointer semantics.
77    *
78    * @param [in] handle A reference to the copied handle
79    */
80   SceneHolder(const SceneHolder& handle);
81
82   /**
83    * @brief This assignment operator is required for (smart) pointer semantics.
84    *
85    * @param [in] rhs  A reference to the copied handle
86    * @return A reference to this
87    */
88   SceneHolder& operator=(const SceneHolder& rhs);
89
90   /**
91    * @brief Adds a child Actor to the SceneHolder.
92    *
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.
97    */
98   void Add(Actor actor);
99
100   /**
101    * @brief Removes a child Actor from the SceneHolder.
102    *
103    * The child will be unreferenced.
104    * @param[in] actor The child
105    * @pre The actor has been added to the SceneHolder.
106    */
107   void Remove(Actor actor);
108
109   /**
110    * @brief Returns the Scene's Root Layer.
111    *
112    * @return The root layer
113    */
114   Layer GetRootLayer() const;
115
116   /**
117    * @brief Sets the background color.
118    *
119    * @param[in] color The new background color
120    */
121   void SetBackgroundColor(Vector4 color);
122
123   /**
124    * @brief Gets the background color.
125    *
126    * @return The background color
127    */
128   Vector4 GetBackgroundColor() const;
129
130   /**
131    * @brief Gets the native handle.
132    *
133    * When users call this function, it wraps the actual type used by the underlying system.
134    *
135    * @return The native handle or an empty handle
136    */
137   Any GetNativeHandle() const;
138
139   /**
140    * @brief Feed (Send) touch event to core
141    * @param[in] point The touch point
142    * @param[in] timeStamp The time stamp
143    */
144   void FeedTouchPoint(Dali::TouchPoint& point, int timeStamp);
145
146   /**
147    * @brief Feed (Send) wheel event to core
148    * @param[in] wheelEvent The wheel event
149    */
150   void FeedWheelEvent(Dali::WheelEvent& wheelEvent);
151
152   /**
153    * @brief Feed (Send) key event to core
154    * @param[in] keyEvent The key event holding the key information.
155    */
156   void FeedKeyEvent(Dali::KeyEvent& keyEvent);
157
158   /**
159    * @brief Retrieve the SceneHolder that the given actor is added to.
160    *
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.
163    */
164   static SceneHolder Get(Actor actor);
165
166   /**
167    * @brief This signal is emitted when key event is received.
168    *
169    * A callback of the following type may be connected:
170    * @code
171    *   void YourCallbackName(const KeyEvent& event);
172    * @endcode
173    * @return The signal to connect to
174    */
175   KeyEventSignalType& KeyEventSignal();
176
177   /**
178    * @brief This signal is emitted when key event is received.
179    *
180    * A callback of the following type may be connected:
181    * @code
182    *   bool YourCallbackName(const KeyEvent& event);
183    * @endcode
184    * @return The signal to connect to
185    */
186   KeyEventGeneratedSignalType& KeyEventGeneratedSignal();
187
188   /**
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).
191    *
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:
196    * @code
197    *   void YourCallbackName( TouchEvent event );
198    * @endcode
199    * @return The touch signal to connect to
200    * @note Motion events are not emitted.
201    */
202   TouchEventSignalType& TouchedSignal();
203
204   /**
205    * @brief This signal is emitted when wheel event is received.
206    *
207    * A callback of the following type may be connected:
208    * @code
209    *   void YourCallbackName(const WheelEvent& event);
210    * @endcode
211    * @return The signal to connect to
212    */
213   WheelEventSignalType& WheelEventSignal();
214
215 public: // Not intended for application developers
216   /**
217    * @brief This constructor is used internally to create additional SceneHolder handles.
218    *
219    * @param[in] sceneHolder A pointer to a newly allocated Dali resource
220    */
221   explicit SceneHolder(Internal::Adaptor::SceneHolder* sceneHolder);
222 };
223
224 } // namespace Integration
225
226 } // namespace Dali
227
228 #endif // DALI_INTEGRATION_SCENEHOLDER_H