Adding chipmunk implementation for physics adaptor
[platform/core/uifw/dali-toolkit.git] / dali-scene3d / internal / light / light-impl.h
1 #ifndef DALI_SCENE3D_LIGHT_IMPL_H
2 #define DALI_SCENE3D_LIGHT_IMPL_H
3
4 /*
5  * Copyright (c) 2023 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/actors/custom-actor-impl.h>
23 #include <dali/public-api/common/dali-common.h>
24 #include <dali/public-api/object/weak-handle.h>
25 #include <string_view>
26
27 // INTERNAL INCLUDES
28 #include <dali-scene3d/public-api/controls/scene-view/scene-view.h>
29 #include <dali-scene3d/public-api/light/light.h>
30
31 namespace Dali
32 {
33 namespace Scene3D
34 {
35 /**
36  * @addtogroup dali_scene3d_light
37  * @{
38  */
39
40 namespace Internal
41 {
42 /**
43  * @brief This is the internal base class for custom node of Light.
44  *
45  * @SINCE_2_2.32
46  */
47 class DALI_SCENE3D_API Light : public CustomActorImpl
48 {
49 public:
50   // Creation & Destruction
51   /**
52    * @brief Creates a new LightImpl instance that does not require touch by default.
53    *
54    * If touch is required, then the user can connect to this class' touch signal.
55    * @SINCE_2_2.32
56    * @return A handle to the Light instance
57    */
58   static Scene3D::Light New();
59
60   /**
61    * @copydoc Scene3D::Light::Enable()
62    */
63   void Enable(bool enable);
64
65   /**
66    * @copydoc Scene3D::Light::IsEnabled()
67    */
68   bool IsEnabled() const;
69
70 protected:
71   /**
72    * @brief Virtual destructor.
73    * @SINCE_2_2.32
74    */
75   virtual ~Light();
76
77 protected: // From CustomActorImpl
78   /**
79    * @copydoc CustomActorImpl::OnSceneConnection()
80    * @note If overridden, then an up-call to Light::OnSceneConnection MUST be made at the end.
81    */
82   void OnSceneConnection(int depth) override;
83
84   /**
85    * @copydoc CustomActorImpl::OnSceneDisconnection()
86    * @note If overridden, then an up-call to Light::OnSceneDisconnection MUST be made at the end.
87    */
88   void OnSceneDisconnection() override;
89
90   /**
91    * @copydoc CustomActorImpl::OnChildAdd()
92    * @note If overridden, then an up-call to Light::OnChildAdd MUST be made at the end.
93    */
94   void OnChildAdd(Actor& child) override;
95
96   /**
97    * @copydoc CustomActorImpl::OnChildRemove()
98    * @note If overridden, then an up-call to Light::OnChildRemove MUST be made at the end.
99    */
100   void OnChildRemove(Actor& child) override;
101
102   /**
103    * @copydoc CustomActorImpl::OnSizeSet()
104    * @note If overridden, then an up-call to Light::OnSizeSet MUST be made at the end.
105    */
106   void OnSizeSet(const Vector3& targetSize) override;
107
108   /**
109    * @copydoc CustomActorImpl::OnSizeAnimation()
110    * @note If overridden, then an up-call to Light::OnSizeAnimation MUST be made at the end.
111    */
112   void OnSizeAnimation(Animation& animation, const Vector3& targetSize) override;
113
114   /**
115    * @copydoc CustomActorImpl::OnRelayout()
116    */
117   void OnRelayout(const Vector2& size, RelayoutContainer& container) override;
118
119   /**
120    * @copydoc CustomActorImpl::OnSetResizePolicy()
121    */
122   void OnSetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension) override;
123
124   /**
125    * @copydoc CustomActorImpl::GetNaturalSize()
126    */
127   Vector3 GetNaturalSize() override;
128
129   /**
130    * @copydoc CustomActorImpl::CalculateChildSize()
131    */
132   float CalculateChildSize(const Dali::Actor& child, Dimension::Type dimension) override;
133
134   /**
135    * @copydoc CustomActorImpl::GetHeightForWidth()
136    */
137   float GetHeightForWidth(float width) override;
138
139   /**
140    * @copydoc CustomActorImpl::GetWidthForHeight()
141    */
142   float GetWidthForHeight(float height) override;
143
144   /**
145    * @copydoc CustomActorImpl::RelayoutDependentOnChildren()
146    */
147   bool RelayoutDependentOnChildren(Dimension::Type dimension = Dimension::ALL_DIMENSIONS) override;
148
149   /**
150    * @copydoc CustomActorImpl::OnCalculateRelayoutSize()
151    */
152   void OnCalculateRelayoutSize(Dimension::Type dimension) override;
153
154   /**
155    * @copydoc CustomActorImpl::OnLayoutNegotiated()
156    */
157   void OnLayoutNegotiated(float size, Dimension::Type dimension) override;
158
159 protected:
160   // Construction
161
162   /**
163    * @brief Light constructor.
164    */
165   Light();
166
167   /**
168    * @brief Second phase initialization.
169    */
170   void Initialize();
171
172 public: // Public Method
173
174   /**
175    * @copydoc Scene3D::Light::GetMaximumEnabledLightCount()
176    */
177   static uint32_t GetMaximumEnabledLightCount();
178
179   /**
180    * @brief Retrieves Light Enabled Uniform Name for shader()
181    * @return string_view for LightEnabledUniformName
182    */
183   static std::string_view GetLightCountUniformName();
184
185   /**
186    * @brief Retrieves Light Direction Uniform Name for shader()
187    * @return string_view for LightDirectionUniformName
188    */
189   static std::string_view GetLightDirectionUniformName();
190
191   /**
192    * @brief Retrieves Light Color Uniform Name for shader()
193    * @return string_view for LightColorUniformName
194    */
195   static std::string_view GetLightColorUniformName();
196
197 private:
198   /// @cond internal
199
200   // Not copyable or movable
201   DALI_INTERNAL        Light(const Light&)     = delete; ///< Deleted copy constructor.
202   DALI_INTERNAL        Light(Light&&)          = delete; ///< Deleted move constructor.
203   DALI_INTERNAL Light& operator=(const Light&) = delete; ///< Deleted copy assignment operator.
204   DALI_INTERNAL Light& operator=(Light&&)      = delete; ///< Deleted move assignment operator.
205
206 private:
207   WeakHandle<Scene3D::SceneView> mParentSceneView;
208   bool mIsEnabled{true};
209   /// @endcond
210 };
211
212 /**
213  * @brief Gets implementation from the handle.
214  *
215  * @param handle
216  * @return Implementation
217  * @pre handle is initialized and points to a node
218  */
219 DALI_SCENE3D_API Internal::Light& GetImplementation(Dali::Scene3D::Light& handle);
220
221 /**
222  * @brief Gets implementation from the handle.
223  *
224  * @param handle
225  * @return Implementation
226  * @pre Handle is initialized and points to a node.
227  */
228 DALI_SCENE3D_API const Internal::Light& GetImplementation(const Dali::Scene3D::Light& handle);
229
230 } // namespace Internal
231
232 /**
233  * @}
234  */
235 } // namespace Scene3D
236
237 } // namespace Dali
238
239 #endif // DALI_SCENE3D_LIGHT_IMPL_H