[dali_1.4.9] Merge branch 'devel/master'
[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
25 namespace Dali
26 {
27
28 class Actor;
29 class Layer;
30 class RenderTaskList;
31
32 namespace Internal DALI_INTERNAL
33 {
34   class Scene;
35 }
36
37 namespace Integration
38 {
39
40 class RenderSurface;
41
42 /**
43  * @brief
44  *
45  * Scene creates a "world" that can be bound to a surface for rendering.
46  *
47  */
48 class DALI_CORE_API Scene : public BaseHandle
49 {
50 public:
51
52   /**
53    * @brief Create an initialized Scene handle.
54    *
55    * @param[in] size The size of the scene in pixels as a Vector
56    *
57    * @return a handle to a newly allocated Dali resource.
58    */
59   static Scene New( Size size );
60
61   /**
62    * @brief Downcast an Object handle to Scene handle.
63    *
64    * If handle points to a Scene object the downcast produces
65    * valid handle. If not the returned handle is left uninitialized.
66    * @param[in] handle to An object
67    * @return handle to a Scene object or an uninitialized handle
68    */
69   static Scene DownCast( BaseHandle handle );
70
71   /**
72    * @brief Create an uninitialized Scene handle.
73    *
74    * This can be initialized with Scene::New(). Calling member
75    * functions with an uninitialized Dali::Object is not allowed.
76    */
77   Scene();
78
79   /**
80    * @brief Destructor
81    *
82    * This is non-virtual since derived Handle types must not contain data or virtual methods.
83    */
84   ~Scene();
85
86   /**
87    * @brief This copy constructor is required for (smart) pointer semantics.
88    *
89    * @param [in] handle A reference to the copied handle
90    */
91   Scene(const Scene& handle);
92
93   /**
94    * @brief This assignment operator is required for (smart) pointer semantics.
95    *
96    * @param [in] rhs  A reference to the copied handle
97    * @return A reference to this
98    */
99   Scene& operator=(const Scene& rhs);
100
101   /**
102    * @brief Adds a child Actor to the Scene.
103    *
104    * The child will be referenced.
105    * @param[in] actor The child
106    * @pre The actor has been initialized.
107    * @pre The actor does not have a parent.
108    */
109   void Add(Actor& actor);
110
111   /**
112    * @brief Removes a child Actor from the Scene.
113    *
114    * The child will be unreferenced.
115    * @param[in] actor The child
116    * @pre The actor has been added to the stage.
117    */
118   void Remove(Actor& actor);
119
120   /**
121    * @brief Returns the size of the Scene in pixels as a Vector.
122    *
123    * The x component will be the width of the Scene in pixels.
124    * The y component will be the height of the Scene in pixels.
125    *
126    * @return The size of the Scene as a Vector
127    */
128   Size GetSize() const;
129
130   /**
131    * Sets horizontal and vertical pixels per inch value that is used by the display
132    * @param[in] dpi Horizontal and vertical dpi value
133    */
134   void SetDpi( Vector2 dpi );
135
136   /**
137    * @brief Retrieves the DPI of the display device to which the scene is connected.
138    *
139    * @return The horizontal and vertical DPI
140    */
141   Vector2 GetDpi() const;
142
143   /**
144    * @brief Retrieves the list of render-tasks.
145    *
146    * @return A valid handle to a RenderTaskList
147    */
148   Dali::RenderTaskList GetRenderTaskList() const;
149
150   /**
151    * @brief Returns the Scene's Root Layer.
152    *
153    * @return The root layer
154    */
155   Layer GetRootLayer() const;
156
157   /**
158    * @brief Queries the number of on-stage layers.
159    *
160    * Note that a default layer is always provided (count >= 1).
161    * @return The number of layers
162    */
163   uint32_t GetLayerCount() const;
164
165   /**
166    * @brief Retrieves the layer at a specified depth.
167    *
168    * @param[in] depth The depth
169    * @return The layer found at the given depth
170    * @pre Depth is less than layer count; see GetLayerCount().
171    */
172   Layer GetLayer( uint32_t depth ) const;
173
174   /**
175    * @brief Binds the rendering surface to the scene
176    *
177    * @return The root layer
178    */
179   void SetSurface( Integration::RenderSurface& surface );
180
181 public: // Not intended for application developers
182
183   /**
184    * @brief This constructor is used by Dali::New() methods.
185    *
186    * @param[in] scene A pointer to an internal Scene resource
187    */
188   explicit DALI_INTERNAL Scene(Internal::Scene* scene);
189 };
190
191 } // namespace Integration
192
193 } // namespace Dali
194
195 #endif // DALI_SCENE_H