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