Make ModelNode / Light don't work A11y + Clean code lines 70/304870/3
authorEunki, Hong <eunkiki.hong@samsung.com>
Thu, 25 Jan 2024 04:24:24 +0000 (13:24 +0900)
committerEunki Hong <eunkiki.hong@samsung.com>
Mon, 18 Mar 2024 11:22:56 +0000 (11:22 +0000)
Let we make ModelNode and Light disable to create ControlAccessible as default.

And also, let we seperate the header file API override comes from.
It will make easy to find where it is comes from.

Change-Id: I477a2c34e247681df45120d83edd84b67fc22a9e
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali-scene3d/internal/light/light-impl.cpp
dali-scene3d/internal/light/light-impl.h
dali-scene3d/internal/model-components/model-node-impl.cpp
dali-scene3d/internal/model-components/model-node-impl.h

index cc7c639..e43986c 100644 (file)
@@ -19,6 +19,7 @@
 #include <dali-scene3d/internal/light/light-impl.h>
 
 // EXTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/control-devel.h>
 #include <dali/integration-api/debug.h>
 #include <dali/public-api/object/type-registry-helper.h>
 #include <dali/public-api/object/type-registry.h>
@@ -78,113 +79,26 @@ Light::~Light()
 {
 }
 
-void Light::Initialize()
+// From Internal::Control.
+
+void Light::OnInitialize()
 {
-  Self().SetProperty(Dali::Actor::Property::COLOR, Color::WHITE);
+  Actor self = Self();
+
+  // TODO : We need to check this is enough.
+  Toolkit::DevelControl::EnableCreateAccessible(Toolkit::Control::DownCast(self), false);
+
+  self.SetProperty(Dali::Actor::Property::COLOR, Color::WHITE);
 
   // Directional Light setting
   mLightSourceActor = Dali::CameraActor::New();
   mLightSourceActor.SetProjectionMode(Dali::Camera::ORTHOGRAPHIC_PROJECTION);
   mLightSourceActor.SetProperty(Dali::Actor::Property::POSITION, Vector3::ZERO);
   mLightSourceActor.SetProperty(Dali::Actor::Property::ORIENTATION, Quaternion());
-  Self().Add(mLightSourceActor);
-}
-
-void Light::Enable(bool enable)
-{
-  if(enable == mIsEnabled)
-  {
-    return;
-  }
-  mIsEnabled = enable;
-
-  Scene3D::SceneView sceneView = mParentSceneView.GetHandle();
-  if(!sceneView)
-  {
-    return;
-  }
-
-  if(mIsEnabled)
-  {
-    GetImpl(sceneView).AddLight(Scene3D::Light::DownCast(Self()));
-  }
-  else
-  {
-    GetImpl(sceneView).RemoveLight(Scene3D::Light::DownCast(Self()));
-  }
-}
-
-bool Light::IsEnabled() const
-{
-  return mIsEnabled;
-}
-
-void Light::EnableShadow(bool enable)
-{
-  if(enable == mIsShadowEnabled)
-  {
-    return;
-  }
-  mIsShadowEnabled = enable;
-
-  Scene3D::SceneView sceneView = mParentSceneView.GetHandle();
-  if(!sceneView)
-  {
-    return;
-  }
-
-  if(mIsShadowEnabled)
-  {
-    GetImpl(sceneView).SetShadow(Scene3D::Light::DownCast(Self()));
-  }
-  else
-  {
-    GetImpl(sceneView).RemoveShadow(Scene3D::Light::DownCast(Self()));
-  }
+  self.Add(mLightSourceActor);
 }
 
-bool Light::IsShadowEnabled() const
-{
-  return mIsShadowEnabled;
-}
-
-CameraActor Light::GetCamera() const
-{
-  return mLightSourceActor;
-}
-
-void Light::EnableShadowSoftFiltering(bool useSoftFiltering)
-{
-  mUseSoftFiltering = useSoftFiltering;
-  UpdateShadowUniforms();
-}
-
-bool Light::IsShadowSoftFilteringEnabled() const
-{
-  return mUseSoftFiltering;
-}
-
-void Light::SetShadowIntensity(float shadowIntensity)
-{
-  mShadowIntensity = shadowIntensity;
-  UpdateShadowUniforms();
-}
-
-float Light::GetShadowIntensity() const
-{
-  return mShadowIntensity;
-}
-
-void Light::SetShadowBias(float shadowBias)
-{
-  mShadowBias = shadowBias;
-  UpdateShadowUniforms();
-}
-
-float Light::GetShadowBias() const
-{
-  return mShadowBias;
-}
+// From CustomActorImpl.
 
 void Light::OnSceneConnection(int depth)
 {
@@ -294,6 +208,104 @@ const Light& GetImplementation(const Dali::Scene3D::Light& handle)
 
 // Public Method
 
+void Light::Enable(bool enable)
+{
+  if(enable == mIsEnabled)
+  {
+    return;
+  }
+  mIsEnabled = enable;
+
+  Scene3D::SceneView sceneView = mParentSceneView.GetHandle();
+  if(!sceneView)
+  {
+    return;
+  }
+
+  if(mIsEnabled)
+  {
+    GetImpl(sceneView).AddLight(Scene3D::Light::DownCast(Self()));
+  }
+  else
+  {
+    GetImpl(sceneView).RemoveLight(Scene3D::Light::DownCast(Self()));
+  }
+}
+
+bool Light::IsEnabled() const
+{
+  return mIsEnabled;
+}
+
+void Light::EnableShadow(bool enable)
+{
+  if(enable == mIsShadowEnabled)
+  {
+    return;
+  }
+  mIsShadowEnabled = enable;
+
+  Scene3D::SceneView sceneView = mParentSceneView.GetHandle();
+  if(!sceneView)
+  {
+    return;
+  }
+
+  if(mIsShadowEnabled)
+  {
+    GetImpl(sceneView).SetShadow(Scene3D::Light::DownCast(Self()));
+  }
+  else
+  {
+    GetImpl(sceneView).RemoveShadow(Scene3D::Light::DownCast(Self()));
+  }
+}
+
+bool Light::IsShadowEnabled() const
+{
+  return mIsShadowEnabled;
+}
+
+CameraActor Light::GetCamera() const
+{
+  return mLightSourceActor;
+}
+
+void Light::EnableShadowSoftFiltering(bool useSoftFiltering)
+{
+  mUseSoftFiltering = useSoftFiltering;
+  UpdateShadowUniforms();
+}
+
+bool Light::IsShadowSoftFilteringEnabled() const
+{
+  return mUseSoftFiltering;
+}
+
+void Light::SetShadowIntensity(float shadowIntensity)
+{
+  mShadowIntensity = shadowIntensity;
+  UpdateShadowUniforms();
+}
+
+float Light::GetShadowIntensity() const
+{
+  return mShadowIntensity;
+}
+
+void Light::SetShadowBias(float shadowBias)
+{
+  mShadowBias = shadowBias;
+  UpdateShadowUniforms();
+}
+
+float Light::GetShadowBias() const
+{
+  return mShadowBias;
+}
+
+// Public Static Method
+
 uint32_t Light::GetMaximumEnabledLightCount()
 {
   return MAX_NUMBER_OF_LIGHT;
@@ -324,6 +336,8 @@ std::string_view Light::GetShadowViewProjectionMatrixUniformName()
   return SHADOW_VIEW_PROJECTION_MATRIX_STRING;
 }
 
+// Private Method
+
 void Light::UpdateShadowUniforms()
 {
   Scene3D::SceneView sceneView = mParentSceneView.GetHandle();
index bb46c5f..6f0ff24 100644 (file)
@@ -57,61 +57,6 @@ public:
    */
   static Scene3D::Light New();
 
-  /**
-   * @copydoc Scene3D::Light::Enable()
-   */
-  void Enable(bool enable);
-
-  /**
-   * @copydoc Scene3D::Light::IsEnabled()
-   */
-  bool IsEnabled() const;
-
-  /**
-   * @copydoc Scene3D::Light::EnableShadow()
-   */
-  void EnableShadow(bool enable);
-
-  /**
-   * @copydoc Scene3D::Light::IsShadowEnabled()
-   */
-  bool IsShadowEnabled() const;
-
-  /**
-   * @copydoc Scene3D::Light::GetCamera()
-   */
-  CameraActor GetCamera() const;
-
-  /**
-   * @copydoc Scene3D::Light::EnableShadowSoftFiltering()
-   */
-  void EnableShadowSoftFiltering(bool useSoftFiltering);
-
-  /**
-   * @copydoc Scene3D::Light::IsShadowSoftFilteringEnabled()
-   */
-  bool IsShadowSoftFilteringEnabled() const;
-
-  /**
-   * @copydoc Scene3D::Light::SetShadowIntensity()
-   */
-  void SetShadowIntensity(float shadowIntensity);
-
-  /**
-   * @copydoc Scene3D::Light::GetShadowIntensity()
-   */
-  float GetShadowIntensity() const;
-
-  /**
-   * @copydoc Scene3D::Light::SetShadowBias()
-   */
-  void SetShadowBias(float shadowBias);
-
-  /**
-   * @copydoc Scene3D::Light::GetShadowBias()
-   */
-  float GetShadowBias() const;
-
 protected:
   /**
    * @brief Virtual destructor.
@@ -119,7 +64,13 @@ protected:
    */
   virtual ~Light();
 
-protected: // From CustomActorImpl
+public: // From Internal::Control.
+  /**
+   * @copydoc Dali::Toolkit::Internal::Control::OnInitialize()
+   */
+  void OnInitialize() override;
+
+protected: // From CustomActorImpl. Note that it will make we can ignore many codes what Internal::Control using now.
   /**
    * @copydoc CustomActorImpl::OnSceneConnection()
    * @note If overridden, then an up-call to Light::OnSceneConnection MUST be made at the end.
@@ -209,12 +160,63 @@ protected:
    */
   Light();
 
+public: // Public Method
   /**
-   * @brief Second phase initialization.
+   * @copydoc Scene3D::Light::Enable()
    */
-  void Initialize();
+  void Enable(bool enable);
 
-public: // Public Method
+  /**
+   * @copydoc Scene3D::Light::IsEnabled()
+   */
+  bool IsEnabled() const;
+
+  /**
+   * @copydoc Scene3D::Light::EnableShadow()
+   */
+  void EnableShadow(bool enable);
+
+  /**
+   * @copydoc Scene3D::Light::IsShadowEnabled()
+   */
+  bool IsShadowEnabled() const;
+
+  /**
+   * @copydoc Scene3D::Light::GetCamera()
+   */
+  CameraActor GetCamera() const;
+
+  /**
+   * @copydoc Scene3D::Light::EnableShadowSoftFiltering()
+   */
+  void EnableShadowSoftFiltering(bool useSoftFiltering);
+
+  /**
+   * @copydoc Scene3D::Light::IsShadowSoftFilteringEnabled()
+   */
+  bool IsShadowSoftFilteringEnabled() const;
+
+  /**
+   * @copydoc Scene3D::Light::SetShadowIntensity()
+   */
+  void SetShadowIntensity(float shadowIntensity);
+
+  /**
+   * @copydoc Scene3D::Light::GetShadowIntensity()
+   */
+  float GetShadowIntensity() const;
+
+  /**
+   * @copydoc Scene3D::Light::SetShadowBias()
+   */
+  void SetShadowBias(float shadowBias);
+
+  /**
+   * @copydoc Scene3D::Light::GetShadowBias()
+   */
+  float GetShadowBias() const;
+
+public: // Public Static Method
   /**
    * @copydoc Scene3D::Light::GetMaximumEnabledLightCount()
    */
index 3338069..2505c35 100644 (file)
@@ -19,6 +19,7 @@
 #include <dali-scene3d/internal/model-components/model-node-impl.h>
 
 // EXTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/control-devel.h>
 #include <dali/integration-api/debug.h>
 #include <dali/public-api/object/type-registry-helper.h>
 #include <dali/public-api/object/type-registry.h>
@@ -73,18 +74,21 @@ ModelNode::~ModelNode()
 {
 }
 
-void ModelNode::Initialize()
-{
-  OnInitialize();
-}
+// From Internal::Control.
 
 void ModelNode::OnInitialize()
 {
   Actor self = Self();
+
+  // TODO : We need to check this is enough.
+  Toolkit::DevelControl::EnableCreateAccessible(Toolkit::Control::DownCast(self), false);
+
   self.RegisterProperty("uIsShadowCasting", static_cast<int>(mIsShadowCasting));
   self.RegisterProperty("uIsShadowReceiving", static_cast<int>(mIsShadowReceiving));
 }
 
+// From CustomActorImpl.
+
 void ModelNode::OnSceneConnection(int depth)
 {
 }
index 2d8e31d..a357180 100644 (file)
@@ -78,7 +78,13 @@ protected:
    */
   virtual ~ModelNode();
 
-protected: // From CustomActorImpl
+public: // From Internal::Control.
+  /**
+   * @copydoc Dali::Toolkit::Internal::Control::OnInitialize()
+   */
+  void OnInitialize() override;
+
+protected: // From CustomActorImpl. Note that it will make we can ignore many codes what Internal::Control using now.
   /**
    * @copydoc CustomActorImpl::OnSceneConnection()
    * @note If overridden, then an up-call to ModelNode::OnSceneConnection MUST be made at the end.
@@ -176,23 +182,6 @@ protected:
    */
   ModelNode();
 
-  /**
-   * @brief Second phase initialization.
-   * @SINCE_2_2.99
-   */
-  void Initialize();
-
-public: // API for derived classes to override
-  // Lifecycle
-
-  /**
-   * @brief This method is called after the Node has been initialized.
-   *
-   * Derived classes should do any second phase initialization by overriding this method.
-   * @SINCE_2_2.99
-   */
-  virtual void OnInitialize();
-
 public: // Public Method
   /**
    * @copydoc Dali::Scene3D::ModelNode::GetModelPrimitiveCount()