[Tizen] Add screen and client rotation itself function
[platform/core/uifw/dali-core.git] / dali / integration-api / scene.h
1 #ifndef DALI_SCENE_H
2 #define DALI_SCENE_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 // INTERNAL INCLUDES
22 #include <dali/public-api/object/handle.h>
23 #include <dali/public-api/math/vector2.h>
24 #include <dali/public-api/math/vector4.h>
25
26 namespace Dali
27 {
28
29 class Actor;
30 struct KeyEvent;
31 class Layer;
32 class RenderTaskList;
33 class TouchData;
34 struct WheelEvent;
35
36 namespace Internal DALI_INTERNAL
37 {
38   class Scene;
39 }
40
41 namespace Integration
42 {
43
44 struct Event;
45
46 /**
47  * @brief
48  *
49  * Scene creates a "world" that can be bound to a surface for rendering.
50  *
51  */
52 class DALI_CORE_API Scene : public BaseHandle
53 {
54 public:
55   typedef Signal< void () > EventProcessingFinishedSignalType; ///< Event Processing finished signal type
56   typedef Signal< void (const Dali::KeyEvent&) > KeyEventSignalType; ///< Key event signal type
57   typedef Signal< bool (const Dali::KeyEvent&) > KeyEventGeneratedSignalType; ///< key event generated signal type
58   typedef Signal< void (const Dali::TouchData&) > TouchSignalType; ///< Touch signal type
59   typedef Signal< void (const Dali::WheelEvent&) > WheelEventSignalType; ///< Touched signal type
60
61   /**
62    * @brief Create an initialized Scene handle.
63    *
64    * @param[in] size The size of the set surface for this scene
65    *
66    * @return a handle to a newly allocated Dali resource.
67    */
68   static Scene New( Size size );
69
70   /**
71    * @brief Downcast an Object handle to Scene handle.
72    *
73    * If handle points to a Scene object the downcast produces
74    * valid handle. If not the returned handle is left uninitialized.
75    * @param[in] handle to An object
76    * @return handle to a Scene object or an uninitialized handle
77    */
78   static Scene DownCast( BaseHandle handle );
79
80   /**
81    * @brief Create an uninitialized Scene handle.
82    *
83    * This can be initialized with Scene::New(). Calling member
84    * functions with an uninitialized Dali::Object is not allowed.
85    */
86   Scene();
87
88   /**
89    * @brief Destructor
90    *
91    * This is non-virtual since derived Handle types must not contain data or virtual methods.
92    */
93   ~Scene();
94
95   /**
96    * @brief This copy constructor is required for (smart) pointer semantics.
97    *
98    * @param [in] handle A reference to the copied handle
99    */
100   Scene(const Scene& handle);
101
102   /**
103    * @brief This assignment operator is required for (smart) pointer semantics.
104    *
105    * @param [in] rhs  A reference to the copied handle
106    * @return A reference to this
107    */
108   Scene& operator=(const Scene& rhs);
109
110   /**
111    * @brief Adds a child Actor to the Scene.
112    *
113    * The child will be referenced.
114    * @param[in] actor The child
115    * @pre The actor has been initialized.
116    * @pre The actor does not have a parent.
117    */
118   void Add(Actor actor);
119
120   /**
121    * @brief Removes a child Actor from the Scene.
122    *
123    * The child will be unreferenced.
124    * @param[in] actor The child
125    * @pre The actor has been added to the stage.
126    */
127   void Remove(Actor actor);
128
129   /**
130    * @brief Returns the size of the Scene in pixels as a Vector.
131    *
132    * The x component will be the width of the Scene in pixels.
133    * The y component will be the height of the Scene in pixels.
134    *
135    * @return The size of the Scene as a Vector
136    */
137   Size GetSize() const;
138
139   /**
140    * Sets horizontal and vertical pixels per inch value that is used by the display
141    * @param[in] dpi Horizontal and vertical dpi value
142    */
143   void SetDpi( Vector2 dpi );
144
145   /**
146    * @brief Retrieves the DPI of the display device to which the scene is connected.
147    *
148    * @return The horizontal and vertical DPI
149    */
150   Vector2 GetDpi() const;
151
152   /**
153    * @brief Sets the background color.
154    *
155    * @param[in] color The new background color
156    */
157   void SetBackgroundColor( const Vector4& color );
158
159   /**
160    * @brief Gets the background color of the render surface.
161    *
162    * @return The background color
163    */
164   Vector4 GetBackgroundColor() const;
165
166   /**
167    * @brief Retrieves the list of render-tasks.
168    *
169    * @return A valid handle to a RenderTaskList
170    */
171   Dali::RenderTaskList GetRenderTaskList() const;
172
173   /**
174    * @brief Returns the Scene's Root Layer.
175    *
176    * @return The root layer
177    */
178   Layer GetRootLayer() const;
179
180   /**
181    * @brief Queries the number of on-stage layers.
182    *
183    * Note that a default layer is always provided (count >= 1).
184    * @return The number of layers
185    */
186   uint32_t GetLayerCount() const;
187
188   /**
189    * @brief Retrieves the layer at a specified depth.
190    *
191    * @param[in] depth The depth
192    * @return The layer found at the given depth
193    * @pre Depth is less than layer count; see GetLayerCount().
194    */
195   Layer GetLayer( uint32_t depth ) const;
196
197   /**
198    * @brief Informs the scene that the set surface has been resized.
199    *
200    * @param[in] width The new width of the set surface
201    * @param[in] height The new height of the set surface
202    * @param[in] orientation The orientation of the surface
203    * @param[in] forceUpdate The flag to update force
204    */
205   void SurfaceResized( float width, float height, int orientation, bool forceUpdate );
206
207   /**
208    * @brief Informs the scene that the surface has been replaced.
209    */
210   void SurfaceReplaced();
211
212   /**
213    * @brief Discards this Scene from the Core.
214    */
215   void Discard();
216
217   /**
218    * @brief Retrieve the Scene that the given actor belongs to.
219    * @return The Scene.
220    */
221   static Integration::Scene Get( Actor actor );
222
223   /**
224    * This function is called when an event is queued.
225    * @param[in] event A event to queue.
226    */
227   void QueueEvent( const Integration::Event& event );
228
229   /**
230    * This function is called by Core when events are processed.
231    */
232   void ProcessEvents();
233
234   /**
235    * @brief This signal is emitted just after the event processing is finished.
236    *
237    * @return The signal to connect to
238    */
239   EventProcessingFinishedSignalType& EventProcessingFinishedSignal();
240
241   /**
242    * @brief This signal is emitted when key event is received.
243    *
244    * A callback of the following type may be connected:
245    * @code
246    *   void YourCallbackName(const KeyEvent& event);
247    * @endcode
248    * @return The signal to connect to
249    */
250   KeyEventSignalType& KeyEventSignal();
251
252   /**
253    * @brief The user would connect to this signal to get a KeyEvent when KeyEvent is generated.
254    *
255    * If the control already consumed key event, KeyEventProcessor do not need to Emit keyEvent.
256    * Therefore, KeyinputManager first checks whether KeyEvent is generated as KeyEventGeneratedSignal.
257    * After that keyEventProcessor must invoke KeyEvent only if KeyEventGeneratedSignal () is not consumed.
258    *
259    * A callback of the following type may be connected:
260    * @code
261    *   bool YourCallbackName(const KeyEvent& event);
262    * @endcode
263    *
264    * @return The return is true if KeyEvent is consumed, otherwise false.
265    */
266   KeyEventGeneratedSignalType& KeyEventGeneratedSignal();
267
268   /**
269    * @brief This signal is emitted when the screen is touched and when the touch ends
270    * (i.e. the down & up touch events only).
271    *
272    * If there are multiple touch points, then this will be emitted when the first touch occurs and
273    * then when the last finger is lifted.
274    * An interrupted event will also be emitted (if it occurs).
275    * A callback of the following type may be connected:
276    * @code
277    *   void YourCallbackName( TouchData event );
278    * @endcode
279    *
280    * @return The touch signal to connect to
281    * @note Motion events are not emitted.
282    */
283   TouchSignalType& TouchSignal();
284
285   /**
286    * @brief This signal is emitted when wheel event is received.
287    *
288    * A callback of the following type may be connected:
289    * @code
290    *   void YourCallbackName(const WheelEvent& event);
291    * @endcode
292    * @return The signal to connect to
293    */
294   WheelEventSignalType& WheelEventSignal();
295
296 public: // Not intended for application developers
297
298   /**
299    * @brief This constructor is used by Dali::New() methods.
300    *
301    * @param[in] scene A pointer to an internal Scene resource
302    */
303   explicit DALI_INTERNAL Scene(Internal::Scene* scene);
304 };
305
306 } // namespace Integration
307
308 } // namespace Dali
309
310 #endif // DALI_SCENE_H