Merge "Klockwork: remove unreachable code, check iterators" into tizen
[platform/core/uifw/dali-core.git] / dali / public-api / common / light.h
1 #ifndef __DALI_LIGHT_H__
2 #define __DALI_LIGHT_H__
3
4 /*
5  * Copyright (c) 2014 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 <string>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/object/base-handle.h>
26
27
28 /**
29  * The top level DALi namespace
30  */
31 namespace Dali
32 {
33
34 namespace Internal DALI_INTERNAL
35 {
36 class Light;
37 }
38
39 class Light;
40
41 /**
42  * @brief Light source types.
43  */
44 enum LightType
45 {
46   AMBIENT,        ///< Lights everything evenly
47   DIRECTIONAL,    ///< Casts light evenly in a specific direction.
48   SPOT,           ///< Casts light from a single point in the shape of a cone. Objects outside the cone are unlit. (EG: a search light)
49   POINT           ///< Casts light outward from a single point in all directions. (EG: a light bulb)
50 };
51
52 /**
53  * @brief Encapsulates the data describing a light source.
54  */
55 class DALI_IMPORT_API Light : public BaseHandle
56 {
57 public:
58   /**
59    * @brief Create an initialized Light.
60    *
61    * @param[in] name The light's name
62    * @return A handle to a newly allocated Dali resource.
63    */
64   static Light New(const std::string& name);
65
66   /**
67    * @brief Downcast an Object handle to Light handle.
68    *
69    * If handle points to a Light object the downcast produces valid
70    * handle. If not the returned handle is left uninitialized.
71    * @param[in] handle to An object
72    * @return handle to a Light object or an uninitialized handle
73    */
74   static Light DownCast( BaseHandle handle );
75
76   /**
77    * @brief Create an uninitialized light; this can be initialized with Light::New().
78    *
79    * Calling member functions with an uninitialized Dali::Object is not allowed.
80    */
81   Light()
82   {
83   }
84
85   /**
86    * @brief Destructor
87    *
88    * This is non-virtual since derived Handle types must not contain data or virtual methods.
89    */
90   ~Light();
91
92   /**
93    * @brief This copy constructor is required for (smart) pointer semantics.
94    *
95    * @param [in] handle A reference to the copied handle
96    */
97   Light(const Light& handle);
98
99   /**
100    * @brief This assignment operator is required for (smart) pointer semantics.
101    *
102    * @param [in] rhs  A reference to the copied handle
103    * @return A reference to this
104    */
105   Light& operator=(const Light& rhs);
106
107   /**
108    * @brief Set the light's name.
109    *
110    * @param[in] name The light's name
111    */
112   void SetName(const std::string& name);
113
114   /**
115    * @brief Get the light's name.
116    *
117    * @return The light's name
118    */
119   const std::string& GetName() const;
120
121   /**
122    * @brief Set the light's type.
123    *
124    * @param[in] type The type of light
125    */
126   void SetType(LightType type);
127
128   /**
129    * @brief Get the lights type.
130    *
131    * @return The light's type
132    */
133   LightType GetType() const;
134
135   /**
136    * @brief Set the distances at which the light's intensity starts to fall off and reaches zero.
137    *
138    * @param[in] fallOff The fall off start and end. The start is in the x component and end is in the y component.
139    */
140   void SetFallOff(const Vector2& fallOff);
141
142   /**
143    * @brief Get the distances at which the light's intensity starts to fall off and reaches zero.
144    *
145    * @return The distances at which the light's intensity starts to fall off, and reaches zero.
146    * See @ref SetFallOff
147    */
148   const Vector2& GetFallOff() const;
149
150   /**
151    * @brief Set the spotlight's inner and outer cone angles.
152    *
153    * @param[in] angle The spotlight's inner and outer cone angles.
154    *                  The inner is in the x component and outer is in the y component.
155    */
156   void SetSpotAngle(const Vector2& angle);
157
158   /**
159    * @brief Get the spotlight's inner and outer cone angles.
160    *
161    * @return The spotlight's inner and outer cone angles
162    */
163   const Vector2& GetSpotAngle() const;
164
165   /**
166    * @brief Set the ambient color for the light.
167    *
168    * The color is composed of rgb
169    * @param[in] color The color to set.
170    */
171   void SetAmbientColor(const Vector3& color);
172
173   /**
174    * @brief Get the light's ambient color.
175    *
176    * @return the light's color as rgb
177    */
178   const Vector3& GetAmbientColor() const;
179
180   /**
181    * @brief Set the diffuse color for the light.
182    *
183    * The color is composed of rgb
184    * @param[in] color The color to set.
185    */
186   void SetDiffuseColor(const Vector3& color);
187
188   /**
189    * @brief Get the light's ambient color.
190    *
191    * @return the light's color as rgb
192    */
193   const Vector3& GetDiffuseColor() const;
194
195   /**
196    * @brief Set the specular color for the light.
197    *
198    * The color is composed of rgb
199    * @param[in] color The color to set.
200    */
201   void SetSpecularColor(const Vector3& color);
202
203   /**
204    * @brief Get the light's specular color.
205    *
206    * @return the light's specular color as rgb
207    */
208   const Vector3& GetSpecularColor() const;
209
210   /**
211    * @brief Set the direction in which the light's rays are cast.
212    *
213    * Valid when the light's type is DIRECTIONAL (see @ref Dali::LightType).
214    * @param [in] direction The direction in which the light's rays are cast.
215    */
216   void SetDirection(const Vector3& direction);
217
218   /**
219    * @brief Get the direction in which the light's rays are cast.
220    *
221    * Valid when the light's type is DIRECTIONAL (see @ref LightType).
222    * @return The direction in which the light's rays are cast.
223    */
224   const Vector3& GetDirection() const;
225
226 public: // Not intended for application developers
227
228   /**
229    * @brief This constructor is used by Dali New() methods.
230    *
231    * @param [in] light A pointer to a newly allocated Dali resource
232    */
233   explicit DALI_INTERNAL Light(Internal::Light* light);
234 };
235
236 } // namespace Dali
237
238 #endif // __DALI_LIGHT_H__