1 #ifndef DALI_SCENE3D_LIGHT_IMPL_H
2 #define DALI_SCENE3D_LIGHT_IMPL_H
5 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
28 #include <dali-scene3d/public-api/controls/scene-view/scene-view.h>
29 #include <dali-scene3d/public-api/light/light.h>
36 * @addtogroup dali_scene3d_light
43 * @brief This is the internal base class for custom node of Light.
47 class DALI_SCENE3D_API Light : public CustomActorImpl
50 // Creation & Destruction
52 * @brief Creates a new LightImpl instance that does not require touch by default.
54 * If touch is required, then the user can connect to this class' touch signal.
56 * @return A handle to the Light instance
58 static Scene3D::Light New();
61 * @copydoc Scene3D::Light::Enable()
63 void Enable(bool enable);
66 * @copydoc Scene3D::Light::IsEnabled()
68 bool IsEnabled() const;
72 * @brief Virtual destructor.
77 protected: // From CustomActorImpl
79 * @copydoc CustomActorImpl::OnSceneConnection()
80 * @note If overridden, then an up-call to Light::OnSceneConnection MUST be made at the end.
82 void OnSceneConnection(int depth) override;
85 * @copydoc CustomActorImpl::OnSceneDisconnection()
86 * @note If overridden, then an up-call to Light::OnSceneDisconnection MUST be made at the end.
88 void OnSceneDisconnection() override;
91 * @copydoc CustomActorImpl::OnChildAdd()
92 * @note If overridden, then an up-call to Light::OnChildAdd MUST be made at the end.
94 void OnChildAdd(Actor& child) override;
97 * @copydoc CustomActorImpl::OnChildRemove()
98 * @note If overridden, then an up-call to Light::OnChildRemove MUST be made at the end.
100 void OnChildRemove(Actor& child) override;
103 * @copydoc CustomActorImpl::OnSizeSet()
104 * @note If overridden, then an up-call to Light::OnSizeSet MUST be made at the end.
106 void OnSizeSet(const Vector3& targetSize) override;
109 * @copydoc CustomActorImpl::OnSizeAnimation()
110 * @note If overridden, then an up-call to Light::OnSizeAnimation MUST be made at the end.
112 void OnSizeAnimation(Animation& animation, const Vector3& targetSize) override;
115 * @copydoc CustomActorImpl::OnRelayout()
117 void OnRelayout(const Vector2& size, RelayoutContainer& container) override;
120 * @copydoc CustomActorImpl::OnSetResizePolicy()
122 void OnSetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension) override;
125 * @copydoc CustomActorImpl::GetNaturalSize()
127 Vector3 GetNaturalSize() override;
130 * @copydoc CustomActorImpl::CalculateChildSize()
132 float CalculateChildSize(const Dali::Actor& child, Dimension::Type dimension) override;
135 * @copydoc CustomActorImpl::GetHeightForWidth()
137 float GetHeightForWidth(float width) override;
140 * @copydoc CustomActorImpl::GetWidthForHeight()
142 float GetWidthForHeight(float height) override;
145 * @copydoc CustomActorImpl::RelayoutDependentOnChildren()
147 bool RelayoutDependentOnChildren(Dimension::Type dimension = Dimension::ALL_DIMENSIONS) override;
150 * @copydoc CustomActorImpl::OnCalculateRelayoutSize()
152 void OnCalculateRelayoutSize(Dimension::Type dimension) override;
155 * @copydoc CustomActorImpl::OnLayoutNegotiated()
157 void OnLayoutNegotiated(float size, Dimension::Type dimension) override;
163 * @brief Light constructor.
168 * @brief Second phase initialization.
172 public: // Public Method
175 * @copydoc Scene3D::Light::GetMaximumEnabledLightCount()
177 static uint32_t GetMaximumEnabledLightCount();
180 * @brief Retrieves Light Enabled Uniform Name for shader()
181 * @return string_view for LightEnabledUniformName
183 static std::string_view GetLightCountUniformName();
186 * @brief Retrieves Light Direction Uniform Name for shader()
187 * @return string_view for LightDirectionUniformName
189 static std::string_view GetLightDirectionUniformName();
192 * @brief Retrieves Light Color Uniform Name for shader()
193 * @return string_view for LightColorUniformName
195 static std::string_view GetLightColorUniformName();
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.
207 WeakHandle<Scene3D::SceneView> mParentSceneView;
208 bool mIsEnabled{true};
213 * @brief Gets implementation from the handle.
216 * @return Implementation
217 * @pre handle is initialized and points to a node
219 DALI_SCENE3D_API Internal::Light& GetImplementation(Dali::Scene3D::Light& handle);
222 * @brief Gets implementation from the handle.
225 * @return Implementation
226 * @pre Handle is initialized and points to a node.
228 DALI_SCENE3D_API const Internal::Light& GetImplementation(const Dali::Scene3D::Light& handle);
230 } // namespace Internal
235 } // namespace Scene3D
239 #endif // DALI_SCENE3D_LIGHT_IMPL_H