Make depth-index as 'AUTO' instead of CONTENT change as default, and clamp depth... 29/309729/7
authorEunki, Hong <eunkiki.hong@samsung.com>
Tue, 16 Apr 2024 04:14:49 +0000 (13:14 +0900)
committerEunki Hong <eunkiki.hong@samsung.com>
Fri, 3 May 2024 08:03:04 +0000 (08:03 +0000)
Let we set depth index as auto if user doesn't set visual's depth index.

Previously we use same behavior if user doesn't set, or user set depth index as CONTENT.
So if user set as 0, it might not works well.

To avoid this confuse logic, let we seperate whether user didn't set the property or not.

Furthermore, let we hard-clamp the range of DepthIndex for VisualBase.

The case of AUTO_INDEX is only for special cases, and otherwise, let we use normal values
what user set.

---

We allow to use RegisterVisual use depth-index as AUTO_INDEX. If this case, it will works
like what we don't set the depth index.

Change-Id: If19b0757b5e27e0a94a37fc8bc0f57c6824d0b16
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
15 files changed:
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.h
automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp
dali-toolkit/devel-api/controls/control-depth-index-ranges.h
dali-toolkit/devel-api/controls/control-devel.h
dali-toolkit/devel-api/visual-factory/visual-base.h
dali-toolkit/internal/controls/buttons/toggle-button-impl.cpp
dali-toolkit/internal/controls/control/control-data-impl.cpp
dali-toolkit/internal/controls/control/control-data-impl.h
dali-toolkit/internal/controls/image-view/image-view-impl.cpp
dali-toolkit/internal/controls/progress-bar/progress-bar-impl.cpp
dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
dali-toolkit/internal/controls/web-view/web-view-impl.cpp
dali-toolkit/internal/visuals/visual-base-data-impl.cpp
dali-toolkit/internal/visuals/visual-base-impl.cpp

index 56b3b5e..262afcf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include "dummy-control.h"
 
 #include <dali-toolkit/dali-toolkit.h>
-#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
 #include <dali-toolkit/devel-api/controls/control-devel.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
 
 namespace Dali
 {
-
 namespace Toolkit
 {
-
 DummyControl::DummyControl()
 {
 }
 
 DummyControl::DummyControl(const DummyControl& control)
-: Control( control )
+: Control(control)
 {
 }
 
@@ -40,60 +38,60 @@ DummyControl::~DummyControl()
 {
 }
 
-DummyControl DummyControl::DownCast( BaseHandle handle )
+DummyControl DummyControl::DownCast(BaseHandle handle)
 {
   return Control::DownCast<DummyControl, DummyControlImpl>(handle);
 }
 
 DummyControl& DummyControl::operator=(const DummyControl& control)
 {
-  Control::operator=( control );
+  Control::operator=(control);
   return *this;
 }
 
 // Used to test signal connections
-void DummyControlImpl::CustomSlot1( Actor actor )
+void DummyControlImpl::CustomSlot1(Actor actor)
 {
   mCustomSlot1Called = true;
 }
 
-namespace {
-
+namespace
+{
 BaseHandle Create()
 {
   return DummyControlImpl::New();
 }
 
-DALI_TYPE_REGISTRATION_BEGIN( Toolkit::DummyControl, Toolkit::Control, Create );
+DALI_TYPE_REGISTRATION_BEGIN(Toolkit::DummyControl, Toolkit::Control, Create);
 DALI_TYPE_REGISTRATION_END()
 
 Dali::PropertyRegistration dummyControlVisualProperty01(
-  typeRegistration, "testVisual", Dali::Toolkit::DummyControl::Property::TEST_VISUAL, Dali::Property::MAP, &Dali::Toolkit::DummyControlImpl::SetProperty, &Dali::Toolkit::DummyControlImpl::GetProperty );
+  typeRegistration, "testVisual", Dali::Toolkit::DummyControl::Property::TEST_VISUAL, Dali::Property::MAP, &Dali::Toolkit::DummyControlImpl::SetProperty, &Dali::Toolkit::DummyControlImpl::GetProperty);
 
 Dali::PropertyRegistration dummyControlVisualProperty02(
-  typeRegistration, "testVisual2", Dali::Toolkit::DummyControl::Property::TEST_VISUAL2, Dali::Property::MAP, &Dali::Toolkit::DummyControlImpl::SetProperty, &Dali::Toolkit::DummyControlImpl::GetProperty );
+  typeRegistration, "testVisual2", Dali::Toolkit::DummyControl::Property::TEST_VISUAL2, Dali::Property::MAP, &Dali::Toolkit::DummyControlImpl::SetProperty, &Dali::Toolkit::DummyControlImpl::GetProperty);
 
 Dali::PropertyRegistration dummyControlVisualProperty03(
-  typeRegistration, "foregroundVisual", Dali::Toolkit::DummyControl::Property::FOREGROUND_VISUAL, Dali::Property::MAP, &Dali::Toolkit::DummyControlImpl::SetProperty, &Dali::Toolkit::DummyControlImpl::GetProperty );
+  typeRegistration, "foregroundVisual", Dali::Toolkit::DummyControl::Property::FOREGROUND_VISUAL, Dali::Property::MAP, &Dali::Toolkit::DummyControlImpl::SetProperty, &Dali::Toolkit::DummyControlImpl::GetProperty);
 
 Dali::PropertyRegistration dummyControlVisualProperty04(
-  typeRegistration, "focusVisual", Dali::Toolkit::DummyControl::Property::FOCUS_VISUAL, Dali::Property::MAP, &Dali::Toolkit::DummyControlImpl::SetProperty, &Dali::Toolkit::DummyControlImpl::GetProperty );
+  typeRegistration, "focusVisual", Dali::Toolkit::DummyControl::Property::FOCUS_VISUAL, Dali::Property::MAP, &Dali::Toolkit::DummyControlImpl::SetProperty, &Dali::Toolkit::DummyControlImpl::GetProperty);
 
 Dali::PropertyRegistration dummyControlVisualProperty05(
-  typeRegistration, "labelVisual", Dali::Toolkit::DummyControl::Property::LABEL_VISUAL, Dali::Property::MAP, &Dali::Toolkit::DummyControlImpl::SetProperty, &Dali::Toolkit::DummyControlImpl::GetProperty );
+  typeRegistration, "labelVisual", Dali::Toolkit::DummyControl::Property::LABEL_VISUAL, Dali::Property::MAP, &Dali::Toolkit::DummyControlImpl::SetProperty, &Dali::Toolkit::DummyControlImpl::GetProperty);
 
-}
+} // namespace
 
 DummyControl DummyControlImpl::New()
 {
-  IntrusivePtr< DummyControlImpl > impl = new DummyControlImpl;
-  DummyControl control( *impl );
+  IntrusivePtr<DummyControlImpl> impl = new DummyControlImpl;
+  DummyControl                   control(*impl);
   impl->Initialize();
   return control;
 }
 
 DummyControlImpl::DummyControlImpl()
-: Control( ControlBehaviour() ),
+: Control(ControlBehaviour()),
   mCustomSlot1Called(false)
 {
 }
@@ -102,69 +100,80 @@ DummyControlImpl::~DummyControlImpl()
 {
 }
 
-void DummyControlImpl::RegisterVisual( Property::Index index, Toolkit::Visual::Base visual )
+void DummyControlImpl::RegisterVisual(Property::Index index, Toolkit::Visual::Base visual)
+{
+  DevelControl::RegisterVisual(*this, index, visual);
+
+  VisualIndices::iterator iter = std::find(mRegisteredVisualIndices.begin(), mRegisteredVisualIndices.end(), index);
+  if(iter == mRegisteredVisualIndices.end())
+  {
+    mRegisteredVisualIndices.push_back(index);
+  }
+}
+
+void DummyControlImpl::RegisterVisual(Property::Index index, Toolkit::Visual::Base visual, bool enabled)
 {
-  DevelControl::RegisterVisual( *this, index, visual );
+  DevelControl::RegisterVisual(*this, index, visual, enabled);
 
-  VisualIndices::iterator iter = std::find( mRegisteredVisualIndices.begin(), mRegisteredVisualIndices.end(), index );
-  if( iter == mRegisteredVisualIndices.end() )
+  VisualIndices::iterator iter = std::find(mRegisteredVisualIndices.begin(), mRegisteredVisualIndices.end(), index);
+  if(iter == mRegisteredVisualIndices.end())
   {
     mRegisteredVisualIndices.push_back(index);
   }
 }
 
-void DummyControlImpl::RegisterVisual( Property::Index index, Toolkit::Visual::Base visual, bool enabled )
+void DummyControlImpl::RegisterVisual(Property::Index index, Toolkit::Visual::Base visual, int depthIndex)
 {
-  DevelControl::RegisterVisual( *this, index, visual, enabled );
+  DevelControl::RegisterVisual(*this, index, visual, depthIndex);
 
-  VisualIndices::iterator iter = std::find( mRegisteredVisualIndices.begin(), mRegisteredVisualIndices.end(), index );
-  if( iter == mRegisteredVisualIndices.end() )
+  VisualIndices::iterator iter = std::find(mRegisteredVisualIndices.begin(), mRegisteredVisualIndices.end(), index);
+  if(iter == mRegisteredVisualIndices.end())
   {
     mRegisteredVisualIndices.push_back(index);
   }
 }
 
-void DummyControlImpl::UnregisterVisual( Property::Index index )
+void DummyControlImpl::UnregisterVisual(Property::Index index)
 {
-  DevelControl::UnregisterVisual( *this, index );
+  DevelControl::UnregisterVisual(*this, index);
 
-  VisualIndices::iterator iter = std::find( mRegisteredVisualIndices.begin(), mRegisteredVisualIndices.end(), index );
-  if( iter != mRegisteredVisualIndices.end() )
+  VisualIndices::iterator iter = std::find(mRegisteredVisualIndices.begin(), mRegisteredVisualIndices.end(), index);
+  if(iter != mRegisteredVisualIndices.end())
   {
     mRegisteredVisualIndices.erase(iter);
   }
 }
 
-Toolkit::Visual::Base DummyControlImpl::GetVisual( Property::Index index )
+Toolkit::Visual::Base DummyControlImpl::GetVisual(Property::Index index)
 {
-  return DevelControl::GetVisual( *this, index );
+  return DevelControl::GetVisual(*this, index);
 }
 
-void DummyControlImpl::EnableVisual( Property::Index index, bool enabled )
+void DummyControlImpl::EnableVisual(Property::Index index, bool enabled)
 {
-  DevelControl::EnableVisual( *this, index, enabled );
+  DevelControl::EnableVisual(*this, index, enabled);
 }
 
-bool DummyControlImpl::IsVisualEnabled( Property::Index index )
+bool DummyControlImpl::IsVisualEnabled(Property::Index index)
 {
-  return DevelControl::IsVisualEnabled( *this, index );
+  return DevelControl::IsVisualEnabled(*this, index);
 }
 
-Animation DummyControlImpl::CreateTransition( const Toolkit::TransitionData& transition )
+Animation DummyControlImpl::CreateTransition(const Toolkit::TransitionData& transition)
 {
-  return DevelControl::CreateTransition( *this, transition );
+  return DevelControl::CreateTransition(*this, transition);
 }
 
-void DummyControlImpl::DoAction( Dali::Property::Index index, Dali::Property::Index action, const Dali::Property::Value attributes )
+void DummyControlImpl::DoAction(Dali::Property::Index index, Dali::Property::Index action, const Dali::Property::Value attributes)
 {
-  DummyControl control( *this );
-  DevelControl::DoAction(  control, index, action, attributes);
+  DummyControl control(*this);
+  DevelControl::DoAction(control, index, action, attributes);
 }
 
-void DummyControlImpl::SetProperty( BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value )
+void DummyControlImpl::SetProperty(BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value)
 {
-  Toolkit::DummyControl control = Toolkit::DummyControl::DownCast( Dali::BaseHandle( object ) );
-  DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(control.GetImplementation());
+  Toolkit::DummyControl control   = Toolkit::DummyControl::DownCast(Dali::BaseHandle(object));
+  DummyControlImpl&     dummyImpl = static_cast<DummyControlImpl&>(control.GetImplementation());
 
   switch(index)
   {
@@ -175,10 +184,10 @@ void DummyControlImpl::SetProperty( BaseObject* object, Dali::Property::Index in
     case Toolkit::DummyControl::Property::LABEL_VISUAL:
     {
       const Property::Map* map = value.GetMap();
-      if( map != NULL )
+      if(map != NULL)
       {
         VisualFactory visualFactory = VisualFactory::Get();
-        Visual::Base visual = visualFactory.CreateVisual(*map);
+        Visual::Base  visual        = visualFactory.CreateVisual(*map);
         dummyImpl.RegisterVisual(index, visual);
       }
       break;
@@ -186,27 +195,26 @@ void DummyControlImpl::SetProperty( BaseObject* object, Dali::Property::Index in
   }
 }
 
-Property::Value DummyControlImpl::GetProperty( BaseObject* object, Dali::Property::Index propertyIndex )
+Property::Value DummyControlImpl::GetProperty(BaseObject* object, Dali::Property::Index propertyIndex)
 {
-  Toolkit::DummyControl control = Toolkit::DummyControl::DownCast( Dali::BaseHandle( object ) );
-  DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>( control.GetImplementation() );
+  Toolkit::DummyControl control   = Toolkit::DummyControl::DownCast(Dali::BaseHandle(object));
+  DummyControlImpl&     dummyImpl = static_cast<DummyControlImpl&>(control.GetImplementation());
 
-  Visual::Base visual = dummyImpl.GetVisual( propertyIndex );
+  Visual::Base  visual = dummyImpl.GetVisual(propertyIndex);
   Property::Map map;
-  if( visual )
+  if(visual)
   {
-    visual.CreatePropertyMap( map );
+    visual.CreatePropertyMap(map);
   }
   Dali::Property::Value value = map;
 
   return value;
 }
 
-
 Toolkit::DummyControl Impl::DummyControl::New()
 {
-  IntrusivePtr< Toolkit::Impl::DummyControl > impl = new Toolkit::Impl::DummyControl;
-  Toolkit::DummyControl control( *impl );
+  IntrusivePtr<Toolkit::Impl::DummyControl> impl = new Toolkit::Impl::DummyControl;
+  Toolkit::DummyControl                     control(*impl);
   impl->Initialize();
   return control;
 }
@@ -245,29 +253,75 @@ Impl::DummyControl::~DummyControl()
   ++destructorCount;
 }
 
-void Impl::DummyControl::OnInitialize() { initializeCalled = true; }
-bool Impl::DummyControl::OnAccessibilityActivated() { activatedCalled = true; return true; }
-bool Impl::DummyControl::OnAccessibilityValueChange( bool isIncrease )
+void Impl::DummyControl::OnInitialize()
+{
+  initializeCalled = true;
+}
+bool Impl::DummyControl::OnAccessibilityActivated()
 {
-  onAccValueChangeCalled = true; return true;
+  activatedCalled = true;
+  return true;
+}
+bool Impl::DummyControl::OnAccessibilityValueChange(bool isIncrease)
+{
+  onAccValueChangeCalled = true;
+  return true;
 }
 
-void Impl::DummyControl::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
+void Impl::DummyControl::OnStyleChange(Toolkit::StyleManager styleManager, StyleChange::Type change)
 {
   themeChangeCalled = change == StyleChange::THEME_CHANGE;
-  fontChangeCalled = change == StyleChange::DEFAULT_FONT_SIZE_CHANGE;
-}
-void Impl::DummyControl::OnPinch(const PinchGesture& pinch) { pinchCalled = true; }
-void Impl::DummyControl::OnPan(const PanGesture& pan) { panCalled = true; }
-void Impl::DummyControl::OnTap(const TapGesture& tap) { tapCalled = true; }
-void Impl::DummyControl::OnLongPress(const LongPressGesture& longPress) { longPressCalled = true; }
-void Impl::DummyControl::OnSceneConnection( int depth ) { Control::OnSceneConnection( depth ); stageConnectionCalled = true; }
-void Impl::DummyControl::OnSceneDisconnection() { stageDisconnectionCalled = true; Control::OnSceneDisconnection(); }
-void Impl::DummyControl::OnChildAdd(Actor& child) { childAddCalled = true; }
-void Impl::DummyControl::OnChildRemove(Actor& child) { childRemoveCalled = true; }
-void Impl::DummyControl::OnSizeSet(const Vector3& targetSize) { Control::OnSizeSet( targetSize ); sizeSetCalled = true; }
-void Impl::DummyControl::OnSizeAnimation(Animation& animation, const Vector3& targetSize) { Control::OnSizeAnimation( animation, targetSize ); sizeAnimationCalled = true; }
-bool Impl::DummyControl::OnKeyEvent(const KeyEvent& event) { keyEventCalled = true; return false;}
+  fontChangeCalled  = change == StyleChange::DEFAULT_FONT_SIZE_CHANGE;
+}
+void Impl::DummyControl::OnPinch(const PinchGesture& pinch)
+{
+  pinchCalled = true;
+}
+void Impl::DummyControl::OnPan(const PanGesture& pan)
+{
+  panCalled = true;
+}
+void Impl::DummyControl::OnTap(const TapGesture& tap)
+{
+  tapCalled = true;
+}
+void Impl::DummyControl::OnLongPress(const LongPressGesture& longPress)
+{
+  longPressCalled = true;
+}
+void Impl::DummyControl::OnSceneConnection(int depth)
+{
+  Control::OnSceneConnection(depth);
+  stageConnectionCalled = true;
+}
+void Impl::DummyControl::OnSceneDisconnection()
+{
+  stageDisconnectionCalled = true;
+  Control::OnSceneDisconnection();
+}
+void Impl::DummyControl::OnChildAdd(Actor& child)
+{
+  childAddCalled = true;
+}
+void Impl::DummyControl::OnChildRemove(Actor& child)
+{
+  childRemoveCalled = true;
+}
+void Impl::DummyControl::OnSizeSet(const Vector3& targetSize)
+{
+  Control::OnSizeSet(targetSize);
+  sizeSetCalled = true;
+}
+void Impl::DummyControl::OnSizeAnimation(Animation& animation, const Vector3& targetSize)
+{
+  Control::OnSizeAnimation(animation, targetSize);
+  sizeAnimationCalled = true;
+}
+bool Impl::DummyControl::OnKeyEvent(const KeyEvent& event)
+{
+  keyEventCalled = true;
+  return false;
+}
 void Impl::DummyControl::OnKeyInputFocusGained()
 {
   if(this->HasKeyInputFocus())
@@ -283,41 +337,41 @@ void Impl::DummyControl::OnKeyInputFocusLost()
   }
 }
 
-void Impl::DummyControl::SetLayout( Property::Index visualIndex, Property::Map& map )
+void Impl::DummyControl::SetLayout(Property::Index visualIndex, Property::Map& map)
 {
-  Property::Value value( map );
+  Property::Value value(map);
   mLayouts[visualIndex] = value;
 }
 
-void Impl::DummyControl::OnRelayout( const Vector2& size, RelayoutContainer& container )
+void Impl::DummyControl::OnRelayout(const Vector2& size, RelayoutContainer& container)
 {
-  if ( mRelayoutCallback )
+  if(mRelayoutCallback)
   {
-    mRelayoutCallback( size );  // Execute callback if set
+    mRelayoutCallback(size); // Execute callback if set
   }
 
   Property::Map emptyMap;
 
-  for( VisualIndices::iterator iter = mRegisteredVisualIndices.begin(); iter != mRegisteredVisualIndices.end() ; ++iter )
+  for(VisualIndices::iterator iter = mRegisteredVisualIndices.begin(); iter != mRegisteredVisualIndices.end(); ++iter)
   {
-    Visual::Base visual = GetVisual(*iter);
-    Property::Value value = mLayouts[*iter];
-    Property::Map* map = NULL;
+    Visual::Base    visual = GetVisual(*iter);
+    Property::Value value  = mLayouts[*iter];
+    Property::Map*  map    = NULL;
 
-    if( value.GetType() != Property::NONE )
+    if(value.GetType() != Property::NONE)
     {
       map = value.GetMap();
     }
-    if( map == NULL )
+    if(map == NULL)
     {
       map = &emptyMap;
     }
 
-    visual.SetTransformAndSize( *map, size );
+    visual.SetTransformAndSize(*map, size);
   }
 }
 
-void Impl::DummyControl::SetRelayoutCallback( RelayoutCallbackFunc callback  )
+void Impl::DummyControl::SetRelayoutCallback(RelayoutCallbackFunc callback)
 {
   mRelayoutCallback = callback;
 }
@@ -326,25 +380,23 @@ Vector3 Impl::DummyControl::GetNaturalSize()
 {
   Vector2 currentSize;
 
-  for( auto elem : mRegisteredVisualIndices )
+  for(auto elem : mRegisteredVisualIndices)
   {
-    Vector2 naturalSize;
+    Vector2      naturalSize;
     Visual::Base visual = GetVisual(elem);
-    visual.GetNaturalSize( naturalSize );
-    currentSize.width = std::max( naturalSize.width, currentSize.width );
-    currentSize.height = std::max( naturalSize.height, currentSize.height );
+    visual.GetNaturalSize(naturalSize);
+    currentSize.width  = std::max(naturalSize.width, currentSize.width);
+    currentSize.height = std::max(naturalSize.height, currentSize.height);
   }
 
-  return Vector3( currentSize );
+  return Vector3(currentSize);
 }
 
-
-
-DummyControl DummyControl::New( bool override )
+DummyControl DummyControl::New(bool override)
 {
   DummyControl control;
 
-  if (override)
+  if(override)
   {
     control = Impl::DummyControl::New();
   }
@@ -356,13 +408,13 @@ DummyControl DummyControl::New( bool override )
   return control;
 }
 
-DummyControl::DummyControl( DummyControlImpl& implementation )
-: Control( implementation )
+DummyControl::DummyControl(DummyControlImpl& implementation)
+: Control(implementation)
 {
 }
 
-DummyControl::DummyControl( Dali::Internal::CustomActor* internal )
-: Control( internal )
+DummyControl::DummyControl(Dali::Internal::CustomActor* internal)
+: Control(internal)
 {
   VerifyCustomActorPointer<DummyControlImpl>(internal);
 }
index 6f79c36..2908ad1 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_TEST_DUMMY_CONTROL_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 namespace Dali
 {
-
 namespace Toolkit
 {
-
 class DummyControlImpl;
 class TransitionData;
 
@@ -47,7 +45,7 @@ public:
   enum PropertyRange
   {
     PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, ///< @SINCE_1_0.0
-    PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000              ///< Reserve property index
+    PROPERTY_END_INDEX   = PROPERTY_START_INDEX + 1000              ///< Reserve property index
   };
 
   struct Property
@@ -66,17 +64,15 @@ public:
   DummyControl(const DummyControl& control);
   ~DummyControl();
 
-  static DummyControl New( bool override = false );
-
-  static DummyControl DownCast( BaseHandle handle );
+  static DummyControl New(bool override = false);
 
+  static DummyControl DownCast(BaseHandle handle);
 
   DummyControl& operator=(const DummyControl& control);
 
 public: // Not intended for application developers
-
-  DummyControl( DummyControlImpl& implementation );
-  DummyControl( Dali::Internal::CustomActor* internal );
+  DummyControl(DummyControlImpl& implementation);
+  DummyControl(Dali::Internal::CustomActor* internal);
 };
 
 /**
@@ -86,40 +82,57 @@ public: // Not intended for application developers
 class DummyControlImpl : public Toolkit::Internal::Control
 {
 public:
-
   static DummyControl New();
 
 public:
-  inline void EnableGestureDetection(GestureType::Value type) { Internal::Control::EnableGestureDetection(type); }
-  inline void DisableGestureDetection(GestureType::Value type) { Internal::Control::DisableGestureDetection(type); }
-  inline PinchGestureDetector GetPinchGestureDetector() const { return Internal::Control::GetPinchGestureDetector(); }
-  inline PanGestureDetector GetPanGestureDetector() const { return Internal::Control::GetPanGestureDetector(); }
-  inline TapGestureDetector GetTapGestureDetector() const { return Internal::Control::GetTapGestureDetector(); }
-  inline LongPressGestureDetector GetLongPressGestureDetector() const { return Internal::Control::GetLongPressGestureDetector(); }
-
-  void RegisterVisual( Property::Index index, Toolkit::Visual::Base visual);
-  void RegisterVisual( Property::Index index, Toolkit::Visual::Base visual, bool enabled );
-  void UnregisterVisual( Property::Index index );
-  void EnableVisual( Property::Index index, bool enabled );
-  bool IsVisualEnabled( Property::Index index );
-  int GetVisualCount();
-  Toolkit::Visual::Base GetVisual( Property::Index index );
-  Animation CreateTransition( const Toolkit::TransitionData& transition );
-  void DoAction( Dali::Property::Index index, Dali::Property::Index action, const Dali::Property::Value attributes );
-
-  static void SetProperty( BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value );
-
-  static Property::Value GetProperty( BaseObject* object, Dali::Property::Index propertyIndex );
+  inline void EnableGestureDetection(GestureType::Value type)
+  {
+    Internal::Control::EnableGestureDetection(type);
+  }
+  inline void DisableGestureDetection(GestureType::Value type)
+  {
+    Internal::Control::DisableGestureDetection(type);
+  }
+  inline PinchGestureDetector GetPinchGestureDetector() const
+  {
+    return Internal::Control::GetPinchGestureDetector();
+  }
+  inline PanGestureDetector GetPanGestureDetector() const
+  {
+    return Internal::Control::GetPanGestureDetector();
+  }
+  inline TapGestureDetector GetTapGestureDetector() const
+  {
+    return Internal::Control::GetTapGestureDetector();
+  }
+  inline LongPressGestureDetector GetLongPressGestureDetector() const
+  {
+    return Internal::Control::GetLongPressGestureDetector();
+  }
+
+  void                  RegisterVisual(Property::Index index, Toolkit::Visual::Base visual);
+  void                  RegisterVisual(Property::Index index, Toolkit::Visual::Base visual, bool enabled);
+  void                  RegisterVisual(Property::Index index, Toolkit::Visual::Base visual, int depthIndex);
+  void                  UnregisterVisual(Property::Index index);
+  void                  EnableVisual(Property::Index index, bool enabled);
+  bool                  IsVisualEnabled(Property::Index index);
+  int                   GetVisualCount();
+  Toolkit::Visual::Base GetVisual(Property::Index index);
+  Animation             CreateTransition(const Toolkit::TransitionData& transition);
+  void                  DoAction(Dali::Property::Index index, Dali::Property::Index action, const Dali::Property::Value attributes);
+
+  static void SetProperty(BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value);
+
+  static Property::Value GetProperty(BaseObject* object, Dali::Property::Index propertyIndex);
 
   // Used to test signal connections
-  void CustomSlot1( Actor actor );
+  void CustomSlot1(Actor actor);
 
-  bool mCustomSlot1Called;
+  bool                                 mCustomSlot1Called;
   typedef std::vector<Property::Index> VisualIndices;
-  VisualIndices mRegisteredVisualIndices;
+  VisualIndices                        mRegisteredVisualIndices;
 
 protected:
-
   DummyControlImpl();
 
   ~DummyControlImpl() override;
@@ -127,7 +140,6 @@ protected:
 
 namespace Impl
 {
-
 /**
  * Cannot create an instance of Internal::Control, so use this dummy class for the implementation.
  * This class DOES override Internal::Control's behaviour.
@@ -135,38 +147,34 @@ namespace Impl
 class DummyControl : public Toolkit::DummyControlImpl
 {
 public:
-
-  typedef std::function<void( Size )> RelayoutCallbackFunc;
+  typedef std::function<void(Size)> RelayoutCallbackFunc;
 
   static Toolkit::DummyControl New();
 
-  void SetLayout( Property::Index visualIndex, Property::Map& map );
+  void SetLayout(Property::Index visualIndex, Property::Map& map);
 
-  void SetRelayoutCallback( RelayoutCallbackFunc callback );
+  void SetRelayoutCallback(RelayoutCallbackFunc callback);
 
 private:
-
   DummyControl();
 
   ~DummyControl() override;
 
 private: // From Internal::Control
-
   void OnInitialize() override;
   bool OnAccessibilityActivated() override;
-  bool OnAccessibilityValueChange( bool isIncrease ) override;
+  bool OnAccessibilityValueChange(bool isIncrease) override;
 
-  void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change ) override;
-  void OnPinch(const PinchGesture& pinch) override;
-  void OnPan(const PanGesture& pan) override;
-  void OnTap(const TapGesture& tap) override;
-  void OnLongPress(const LongPressGesture& longPress) override;
+  void    OnStyleChange(Toolkit::StyleManager styleManager, StyleChange::Type change) override;
+  void    OnPinch(const PinchGesture& pinch) override;
+  void    OnPan(const PanGesture& pan) override;
+  void    OnTap(const TapGesture& tap) override;
+  void    OnLongPress(const LongPressGesture& longPress) override;
   Vector3 GetNaturalSize() override;
-  bool OnKeyEvent(const KeyEvent& event) override;
+  bool    OnKeyEvent(const KeyEvent& event) override;
 
 private: // From CustomActorImpl
-
-  void OnSceneConnection( int depth ) override;
+  void OnSceneConnection(int depth) override;
   void OnSceneDisconnection() override;
   void OnChildAdd(Actor& child) override;
   void OnChildRemove(Actor& child) override;
@@ -174,39 +182,37 @@ private: // From CustomActorImpl
   void OnSizeAnimation(Animation& animation, const Vector3& targetSize) override;
   void OnKeyInputFocusGained() override;
   void OnKeyInputFocusLost() override;
-  void OnRelayout( const Vector2& size, RelayoutContainer& container ) override;
+  void OnRelayout(const Vector2& size, RelayoutContainer& container) override;
 
-  DALI_INTERNAL DummyControl( const DummyControl& );
-  DALI_INTERNAL DummyControl& operator=( const DummyControl& );
+  DALI_INTERNAL DummyControl(const DummyControl&);
+  DALI_INTERNAL DummyControl& operator=(const DummyControl&);
 
 public:
-
-  bool initializeCalled;
-  bool activatedCalled;
-  bool onAccValueChangeCalled;
-  bool themeChangeCalled;
-  bool fontChangeCalled;
-  bool pinchCalled;
-  bool panCalled;
-  bool tapCalled;
-  bool longPressCalled;
-  bool stageConnectionCalled;
-  bool stageDisconnectionCalled;
-  bool childAddCalled;
-  bool childRemoveCalled;
-  bool sizeSetCalled;
-  bool sizeAnimationCalled;
-  bool hoverEventCalled;
-  bool wheelEventCalled;
-  bool keyEventCalled;
-  bool keyInputFocusGained;
-  bool keyInputFocusLost;
+  bool       initializeCalled;
+  bool       activatedCalled;
+  bool       onAccValueChangeCalled;
+  bool       themeChangeCalled;
+  bool       fontChangeCalled;
+  bool       pinchCalled;
+  bool       panCalled;
+  bool       tapCalled;
+  bool       longPressCalled;
+  bool       stageConnectionCalled;
+  bool       stageDisconnectionCalled;
+  bool       childAddCalled;
+  bool       childRemoveCalled;
+  bool       sizeSetCalled;
+  bool       sizeAnimationCalled;
+  bool       hoverEventCalled;
+  bool       wheelEventCalled;
+  bool       keyEventCalled;
+  bool       keyInputFocusGained;
+  bool       keyInputFocusLost;
   static int constructorCount;
   static int destructorCount;
 
-  Property::Map mLayouts;
+  Property::Map        mLayouts;
   RelayoutCallbackFunc mRelayoutCallback;
-
 };
 
 } // namespace Impl
index 70e46e2..e2659ff 100644 (file)
@@ -3762,11 +3762,11 @@ int UtcDaliRegisterVisualOrder(void)
   dummyImpl.RegisterVisual(DummyControl::Property::FOCUS_VISUAL, focusVisual);
   DALI_TEST_CHECK(focusVisual.GetDepthIndex() > foregroundVisual.GetDepthIndex());
 
-  tet_infoline("Set depth index on a new visual before registering, the depth index should not have been changed");
+  tet_infoline("Set depth index on a new visual before registering, the depth index should not have been changed, and be clampled");
   Visual::Base labelVisual = factory.CreateVisual(propertyMap);
-  labelVisual.SetDepthIndex(-2000);
+  labelVisual.SetDepthIndex(static_cast<int>(Toolkit::DepthIndex::MINIMUM_DEPTH_INDEX) - 100);
   dummyImpl.RegisterVisual(DummyControl::Property::LABEL_VISUAL, labelVisual);
-  DALI_TEST_EQUALS(labelVisual.GetDepthIndex(), -2000, TEST_LOCATION);
+  DALI_TEST_EQUALS(labelVisual.GetDepthIndex(), static_cast<int>(Toolkit::DepthIndex::MINIMUM_DEPTH_INDEX), TEST_LOCATION);
 
   tet_infoline("Replace visual, the depth index should be the same as what was previously set");
   const int    testVisual2DepthIndex  = testVisual2.GetDepthIndex();
@@ -3775,11 +3775,11 @@ int UtcDaliRegisterVisualOrder(void)
   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL2, testVisual2Replacement);
   DALI_TEST_EQUALS(testVisual2Replacement.GetDepthIndex(), testVisual2DepthIndex, TEST_LOCATION);
 
-  tet_infoline("Replace visual and set a depth index on the replacement, the depth index of the replacement should be honoured");
+  tet_infoline("Replace visual and set a depth index on the replacement, the depth index of the replacement should be honoured, and be clampled");
   Visual::Base anotherTestVisual2Replacement = factory.CreateVisual(propertyMap);
-  anotherTestVisual2Replacement.SetDepthIndex(2000);
+  anotherTestVisual2Replacement.SetDepthIndex(static_cast<int>(Toolkit::DepthIndex::MAXIMUM_DEPTH_INDEX) + 100);
   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL2, anotherTestVisual2Replacement);
-  DALI_TEST_EQUALS(anotherTestVisual2Replacement.GetDepthIndex(), 2000, TEST_LOCATION);
+  DALI_TEST_EQUALS(anotherTestVisual2Replacement.GetDepthIndex(), static_cast<int>(Toolkit::DepthIndex::MAXIMUM_DEPTH_INDEX), TEST_LOCATION);
 
   dummyControl.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
   application.GetScene().Add(dummyControl);
@@ -3806,7 +3806,7 @@ int UtcDaliRegisterVisualOrder02(void)
 
   dummyControl.SetProperty(Control::Property::BACKGROUND, propertyMap);
 
-  const int TEST_VISUAL_1_DEPTH_INDEX = 0;
+  const int TEST_VISUAL_1_DEPTH_INDEX = static_cast<int>(Toolkit::DepthIndex::CONTENT);
   tet_printf("Register visual, should have depth index of %d\n", TEST_VISUAL_1_DEPTH_INDEX);
   Visual::Base testVisual1 = factory.CreateVisual(propertyMap);
   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, testVisual1);
@@ -3815,7 +3815,14 @@ int UtcDaliRegisterVisualOrder02(void)
   tet_printf("Register another visual, should have a depth index greater than previous(%d)\n", TEST_VISUAL_1_DEPTH_INDEX);
   Visual::Base testVisual2 = factory.CreateVisual(propertyMap);
   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL2, testVisual2);
-  DALI_TEST_CHECK(testVisual2.GetDepthIndex() > testVisual1.GetDepthIndex());
+  DALI_TEST_GREATER(testVisual2.GetDepthIndex(), testVisual1.GetDepthIndex(), TEST_LOCATION);
+
+  const int TEST_VISUAL_2_DEPTH_INDEX = testVisual2.GetDepthIndex();
+
+  tet_printf("Register other visual, should have a depth index greater than previous(%d)\n", TEST_VISUAL_2_DEPTH_INDEX);
+  Visual::Base testVisual3 = factory.CreateVisual(propertyMap);
+  dummyImpl.RegisterVisual(DummyControl::Property::FOREGROUND_VISUAL, testVisual3, Toolkit::DepthIndex::AUTO_INDEX);
+  DALI_TEST_GREATER(testVisual3.GetDepthIndex(), testVisual2.GetDepthIndex(), TEST_LOCATION);
 
   dummyControl.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
   application.GetScene().Add(dummyControl);
index 3aa0c9f..e66c4ee 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_DEVEL_CONTROL_DEPTH_INDEX_RANGES_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,25 +30,41 @@ namespace DepthIndex
 // The negative value for background effect and background has been
 // chosen so that newer controls can have content without setting
 // depth index, and go in front of native controls with a background.
-// This backround negative value means that the highest possible value
-// is SIBLING_ORDER_MULTIPLIER-BACKGROUND_EFFECT-1.  The divisor of
-// 100 ensures the range fits within the sibling order range, and has
-// enough gaps to allow Control Authors to use other intermediate depths.
+// The lowest possible value is MINIMUM_DEPTH_INDEX, and highest possible
+// value is MAXIMUM_DEPTH_INDEX. The divisor of 10 ensures the range fits
+// within the sibling order range, and has enough gaps to allow Control
+// Authors to use other intermediate depths.
+//
+// Note : AUTO_INDEX is special value. It means that the depth index will be
+// automatically assigned when we register visual into the control.
+// Other values will be clamped to the range.
 
 enum Ranges
 {
-  BACKGROUND_EFFECT = -2 * DevelLayer::SIBLING_ORDER_MULTIPLIER / 100,
-  BACKGROUND        = -1 * DevelLayer::SIBLING_ORDER_MULTIPLIER / 100,
-  CONTENT           = 0,
-  DECORATION        = 1 * DevelLayer::SIBLING_ORDER_MULTIPLIER / 100,
-  FOREGROUND_EFFECT = 2 * DevelLayer::SIBLING_ORDER_MULTIPLIER / 100
+  MINIMUM_DEPTH_INDEX = -5 * DevelLayer::SIBLING_ORDER_MULTIPLIER / 10 + 1,
+  BACKGROUND_EFFECT   = -2 * DevelLayer::SIBLING_ORDER_MULTIPLIER / 10,
+  BACKGROUND          = -1 * DevelLayer::SIBLING_ORDER_MULTIPLIER / 10,
+  CONTENT             = 0,
+  DECORATION          = 1 * DevelLayer::SIBLING_ORDER_MULTIPLIER / 10,
+  FOREGROUND_EFFECT   = 2 * DevelLayer::SIBLING_ORDER_MULTIPLIER / 10,
+  MAXIMUM_DEPTH_INDEX = 5 * DevelLayer::SIBLING_ORDER_MULTIPLIER / 10,
+
+  AUTO_INDEX = MINIMUM_DEPTH_INDEX - 1, ///< Special value to indicate that the depth index should be automatically calculated.
+                                        ///  If visual replaced by another visual, the depth index of the new visual will be set to previous visual.
+                                        ///  Otherwise, depth index will be set as the maximum depth index + 1
+                                        ///  what given control already has, or CONTENT if no visuals.
 };
 
 static_assert((unsigned int)DevelLayer::ACTOR_DEPTH_MULTIPLIER > (unsigned int)DevelLayer::SIBLING_ORDER_MULTIPLIER);
+static_assert(MINIMUM_DEPTH_INDEX < BACKGROUND_EFFECT);
 static_assert(BACKGROUND_EFFECT < BACKGROUND);
 static_assert(BACKGROUND < CONTENT);
 static_assert(CONTENT < DECORATION);
 static_assert(DECORATION < FOREGROUND_EFFECT);
+static_assert(FOREGROUND_EFFECT < MAXIMUM_DEPTH_INDEX);
+
+// AUTO_INDEX should not be inside of the valid range.
+static_assert(!(MINIMUM_DEPTH_INDEX <= AUTO_INDEX && AUTO_INDEX <= MAXIMUM_DEPTH_INDEX));
 
 } // namespace DepthIndex
 
index fe2548f..465041a 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_CONTROL_DEVEL_H
 
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -236,8 +236,7 @@ enum
  *
  * @note Derived class should not call visual.SetOnScene(actor). It is the responsibility of the base class to connect/disconnect registered visual to stage.
  *       Use below API with enabled set to false if derived class wishes to control when visual is staged.
- * @note If the depth-index is not set on the visual, then it is set to be above the currently registered visuals.
- * @note If replacing a visual, then the depth-index of the visual being replaced is used for the visual.
+ * @note depth-index be used to Dali::Toolkit::DepthIndex::Ranges::AUTO_INDEX.
  */
 DALI_TOOLKIT_API void RegisterVisual(Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual);
 
@@ -247,7 +246,9 @@ DALI_TOOLKIT_API void RegisterVisual(Internal::Control& control, Dali::Property:
  * @param[in] control The control
  * @param[in] index The Property index of the visual, used to reference visual
  * @param[in] visual The visual to register
- * @param[in] depthIndex The visual's depth-index is set to this
+ * @param[in] depthIndex The visual's depth-index is set to this. If the depth-index is set to DepthIndex::Ranges::AUTO_INDEX,
+ *                       the actual depth-index of visual will be determind automatically (Use previous visuals depth-index, or placed on top of all other visuals.)
+ *                       Otherwise, the visual's depth-index is set to clamped value, between DepthIndex::Ranges::MINIMUM_DEPTH_INDEX and DepthIndex::Ranges::MAXIMUM_DEPTH_INDEX.
  *
  * @note Derived class should not call visual.SetOnScene(actor). It is the responsibility of the base class to connect/disconnect registered visual to stage.
  *       Use below API with enabled set to false if derived class wishes to control when visual is staged.
@@ -265,8 +266,7 @@ DALI_TOOLKIT_API void RegisterVisual(Internal::Control& control, Dali::Property:
  * @param[in] visual The visual to register
  * @param[in] enabled false if derived class wants to control when visual is set on stage.
  *
- * @note If the depth-index is not set on the visual, then it is set to be above the currently registered visuals.
- * @note If replacing a visual, then the depth-index of the visual being replaced is used for the visual.
+ * @note depth-index be used to Dali::Toolkit::DepthIndex::Ranges::AUTO_INDEX.
  *
  * @see EnableVisual()
  */
@@ -279,7 +279,9 @@ DALI_TOOLKIT_API void RegisterVisual(Internal::Control& control, Dali::Property:
  * @param[in] index The Property index of the visual, used to reference visual
  * @param[in] visual The visual to register
  * @param[in] enabled false if derived class wants to control when visual is set on stage.
- * @param[in] depthIndex The visual's depth-index is set to this
+ * @param[in] depthIndex The visual's depth-index is set to this. If the depth-index is set to DepthIndex::Ranges::AUTO_INDEX,
+ *                       the actual depth-index of visual will be determind automatically (Use previous visuals depth-index, or placed on top of all other visuals.)
+ *                       Otherwise, the visual's depth-index is set to clamped value, between DepthIndex::Ranges::MINIMUM_DEPTH_INDEX and DepthIndex::Ranges::MAXIMUM_DEPTH_INDEX.
  *
  * @see EnableVisual()
  * @see Visual::Base::GetDepthIndex()
index 3b03dbe..dc31868 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef DALI_TOOLKIT_VISUAL_BASE_H
 #define DALI_TOOLKIT_VISUAL_BASE_H
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -167,14 +167,20 @@ public:
    * @brief Set the depth index of this visual.
    *
    * Depth-index controls draw-order for overlapping visuals.
-   * Visuals with higher depth indices are rendered in front of other visual with smaller values
+   * Visuals with higher depth indices are rendered in front of other visual with smaller values.
+   *
+   * @note The value of index will be clamped between DepthIndex::Ranges::MINIMUM_DEPTH_INDEX and
+   * DepthIndex::Ranges::MAXIMUM_DEPTH_INDEX.
+   * @note If we call this API at least 1 time, we cannot set as DepthIndex::AUTO_INDEX after.
    *
    * @param[in] index The depth index of this visual.
    */
   void SetDepthIndex(int index);
 
   /**
-   * @brief Get the depth index of this visual
+   * @brief Get the depth index of this visual which clamped between
+   * DepthIndex::Ranges::MINIMUM_DEPTH_INDEX and DepthIndex::Ranges::MAXIMUM_DEPTH_INDEX.
+   * Or DepthIndex::Ranges::AUTO_INDEX if we never set depth index before.
    *
    * @return The depth index of this visual.
    */
index 1479e35..5dd9b87 100644 (file)
@@ -325,7 +325,7 @@ void ToggleButton::PrepareVisual(Property::Index index, Toolkit::Visual::Base& v
     DevelControl::UnregisterVisual(*this, index);
   }
 
-  DevelControl::RegisterVisual(*this, index, visual, enabled);
+  DevelControl::RegisterVisual(*this, index, visual, enabled, DepthIndex::CONTENT);
 }
 
 void ToggleButton::RelayoutVisual(Property::Index index, const Vector2& size)
index e67be8e..5488957 100644 (file)
@@ -798,6 +798,10 @@ void Control::Impl::RegisterVisual(Property::Index index, Toolkit::Visual::Base&
     requiredDepthIndex = depthIndex;
   }
 
+  // Change the depth index value automatically if the visual has DepthIndex to AUTO_INDEX
+  // or if RegisterVisual set DepthIndex to AUTO_INDEX.
+  const bool requiredDepthIndexChanged = (requiredDepthIndex == DepthIndex::AUTO_INDEX);
+
   // Visual replacement, existing visual should only be removed from stage when replacement ready.
   if(!mVisuals.Empty())
   {
@@ -839,11 +843,11 @@ void Control::Impl::RegisterVisual(Property::Index index, Toolkit::Visual::Base&
           mVisuals.Erase(registeredVisualsiter);
         }
 
-        // If we've not set the depth-index value and the new visual does not have a depth index applied to it, then use the previously set depth-index for this index
-        if((depthIndexValueSet == DepthIndexValue::NOT_SET) &&
-           (visual.GetDepthIndex() == 0))
+        // If the visual have a depth index as AUTO_INDEX and the new visual does not have a depth index applied to it, then use the previously set depth-index for this index
+        if(requiredDepthIndexChanged)
         {
           requiredDepthIndex = currentDepthIndex;
+          DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Use replaced visual index. VisualDepthIndex AUTO_INDEX set as: %d\n", requiredDepthIndex);
         }
       }
 
@@ -866,12 +870,10 @@ void Control::Impl::RegisterVisual(Property::Index index, Toolkit::Visual::Base&
 
   if(!visualReplaced) // New registration entry
   {
-    // If we've not set the depth-index value, we have more than one visual and the visual does not have a depth index, then set it to be the highest
-    if((depthIndexValueSet == DepthIndexValue::NOT_SET) &&
-       (mVisuals.Size() > 0) &&
-       (visual.GetDepthIndex() == 0))
+    // If we have more than one visual and the visual have a depth index as AUTO_INDEX, then set it to be the highest
+    if((mVisuals.Size() > 0) && requiredDepthIndexChanged)
     {
-      int maxDepthIndex = std::numeric_limits<int>::min();
+      int maxDepthIndex = static_cast<int>(DepthIndex::CONTENT) - 1; // Start at DepthIndex::CONTENT if maxDepth index belongs to a background or no visuals have been added yet.
 
       RegisteredVisualContainer::ConstIterator       iter;
       const RegisteredVisualContainer::ConstIterator endIter = mVisuals.End();
@@ -883,13 +885,20 @@ void Control::Impl::RegisterVisual(Property::Index index, Toolkit::Visual::Base&
           maxDepthIndex = visualDepthIndex;
         }
       }
-      ++maxDepthIndex;                                 // Add one to the current maximum depth index so that our added visual appears on top
-      requiredDepthIndex = std::max(0, maxDepthIndex); // Start at zero if maxDepth index belongs to a background
+      requiredDepthIndex = ++maxDepthIndex; // Add one to the current maximum depth index so that our added visual appears on top.
+      DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Use top of all visuals. VisualDepthIndex AUTO_INDEX set as: %d\n", requiredDepthIndex);
     }
   }
 
   if(visual)
   {
+    // If required depth index still DepthIndex::AUTO_INDEX, Make it as DepthIndex::CONTENT now
+    if(requiredDepthIndex == static_cast<int>(DepthIndex::AUTO_INDEX))
+    {
+      requiredDepthIndex = static_cast<int>(DepthIndex::CONTENT);
+      DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Some strange cases. VisualDepthIndex AUTO_INDEX set as: %d\n", requiredDepthIndex);
+    }
+
     // Set determined depth index
     visual.SetDepthIndex(requiredDepthIndex);
 
index b2109ee..ed38e3f 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_CONTROL_DATA_IMPL_H
 
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  */
 
 // EXTERNAL INCLUDES
-#include <dali-toolkit/devel-api/controls/control-devel.h>
 #include <dali/devel-api/adaptor-framework/accessibility.h>
 #include <dali/public-api/object/property-notification.h>
 #include <dali/public-api/object/type-registry.h>
 #include <string>
 
 // INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
+#include <dali-toolkit/devel-api/controls/control-devel.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
 #include <dali-toolkit/internal/builder/dictionary.h>
 #include <dali-toolkit/internal/builder/style.h>
@@ -501,12 +502,14 @@ private:
    * @param[in,out] visual The visual to register, which can be altered in this function
    * @param[in] enabled false if derived class wants to control when visual is set on stage
    * @param[in] depthIndexValueSet Set to true if the depthIndex has actually been set manually
-   * @param[in] depthIndex The visual's depth-index is set to this
+   * @param[in] depthIndex The visual's depth-index is set to this. If the depth-index is set to DepthIndex::Ranges::AUTO_INDEX,
+   *                       the actual depth-index of visual will be determind automatically (Use previous visuals depth-index, or placed on top of all other visuals.)
+   *                       Otherwise, the visual's depth-index is set to clamped value, between DepthIndex::Ranges::MINIMUM_DEPTH_INDEX and DepthIndex::Ranges::MAXIMUM_DEPTH_INDEX.
    *
    * @note Registering a visual with an index that already has a registered visual will replace it. The replacement will
    *       occur once the replacement visual is ready (loaded).
    */
-  void RegisterVisual(Property::Index index, Toolkit::Visual::Base& visual, VisualState::Type enabled, DepthIndexValue::Type depthIndexValueSet, int depthIndex = 0);
+  void RegisterVisual(Property::Index index, Toolkit::Visual::Base& visual, VisualState::Type enabled, DepthIndexValue::Type depthIndexValueSet, int depthIndex = static_cast<int>(Toolkit::DepthIndex::AUTO_INDEX));
 
   /**
    * @brief Emits the resource ready signal.
index 7f11261..a59ac36 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 #include <dali/public-api/object/type-registry.h>
 
 // INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
 #include <dali-toolkit/devel-api/controls/control-devel.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
 #include <dali-toolkit/devel-api/visuals/visual-actions-devel.h>
@@ -45,13 +46,13 @@ namespace
 {
 const Vector4 FULL_TEXTURE_RECT(0.f, 0.f, 1.f, 1.f);
 
-constexpr float FULL_OPACITY = 1.0f;
-constexpr float LOW_OPACITY  = 0.2f;
+constexpr float FULL_OPACITY            = 1.0f;
+constexpr float LOW_OPACITY             = 0.2f;
 constexpr float TRANSITION_EFFECT_SPEED = 0.3f;
 
-constexpr int PLACEHOLDER_DEPTH_INDEX = -2;
-constexpr int PREVIOUS_VISUAL_DEPTH_INDEX  = -1;
-constexpr int CURRENT_VISUAL_DEPTH_INDEX = 0;
+constexpr int PLACEHOLDER_DEPTH_INDEX     = -2;
+constexpr int PREVIOUS_VISUAL_DEPTH_INDEX = -1;
+constexpr int CURRENT_VISUAL_DEPTH_INDEX  = 0;
 
 BaseHandle Create()
 {
@@ -173,7 +174,7 @@ void ImageView::SetImage(const Property::Map& map)
       visualImpl.SetCustomShader(mShaderMap);
     }
 
-    DevelControl::RegisterVisual(*this, Toolkit::ImageView::Property::IMAGE, visual);
+    DevelControl::RegisterVisual(*this, Toolkit::ImageView::Property::IMAGE, visual, DepthIndex::CONTENT);
   }
   else
   {
@@ -210,8 +211,6 @@ void ImageView::SetImage(const std::string& url, ImageDimensions size)
     mPreviousVisual = mVisual;
   }
 
-  
-
   // Don't bother comparing if we had a visual previously, just drop old visual and create new one
   mUrl       = url;
   mImageSize = size;
@@ -239,7 +238,7 @@ void ImageView::SetImage(const std::string& url, ImageDimensions size)
       visualImpl.SetCustomShader(mShaderMap);
     }
 
-    DevelControl::RegisterVisual(*this, Toolkit::ImageView::Property::IMAGE, visual);
+    DevelControl::RegisterVisual(*this, Toolkit::ImageView::Property::IMAGE, visual, DepthIndex::CONTENT);
   }
   else
   {
@@ -563,7 +562,7 @@ void ImageView::ApplyFittingMode(const Vector2& size)
   bool zeroPadding = (padding == Extents());
 
   Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>(
-  Self().GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get<int>());
+    Self().GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get<int>());
   if(Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection)
   {
     std::swap(padding.start, padding.end);
@@ -707,7 +706,7 @@ void ImageView::TransitionImageWithEffect()
       Dali::KeyFrames fadeinKeyFrames = Dali::KeyFrames::New();
       fadeinKeyFrames.Add(0.0f, LOW_OPACITY);
       fadeinKeyFrames.Add(1.0f, destinationAlpha);
-      mTransitionAnimation.AnimateBetween(DevelControl::GetVisualProperty(handle, Toolkit::ImageView::Property::IMAGE, Toolkit::Visual::Property::OPACITY), fadeinKeyFrames,  AlphaFunction::EASE_IN_OUT);
+      mTransitionAnimation.AnimateBetween(DevelControl::GetVisualProperty(handle, Toolkit::ImageView::Property::IMAGE, Toolkit::Visual::Property::OPACITY), fadeinKeyFrames, AlphaFunction::EASE_IN_OUT);
       imageVisual.SetDepthIndex(imageVisual.GetDepthIndex() + CURRENT_VISUAL_DEPTH_INDEX);
     }
 
index fcdcd7a..29302e1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@
 #include <dali-toolkit/internal/controls/progress-bar/progress-bar-impl.h>
 
 // EXTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
 #include <dali-toolkit/devel-api/controls/control-devel.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
@@ -77,7 +78,7 @@ struct ProgressDepthIndex
   // Enum to make sure the visual order
   enum
   {
-    TRACK_VISUAL,
+    TRACK_VISUAL = Toolkit::DepthIndex::CONTENT,
     SECONDARY_PROGRESS_VISUAL,
     PROGRESS_VISUAL,
     LABEL_VISUAL,
index 27d2998..3063429 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -71,7 +71,7 @@ const unsigned int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::DevelText::DEFAULT
  * The alignment depends on the alignment value of the text label (Use Text::VerticalAlignment enumerations).
  */
 const float VERTICAL_ALIGNMENT_TABLE[Text::VerticalAlignment::BOTTOM + 1] =
-{
+  {
     0.0f, // VerticalAlignment::TOP
     0.5f, // VerticalAlignment::CENTER
     1.0f  // VerticalAlignment::BOTTOM
@@ -89,7 +89,7 @@ Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT
 #endif
 
 const Scripting::StringEnum AUTO_SCROLL_STOP_MODE_TABLE[] =
-{
+  {
     {"IMMEDIATE", Toolkit::TextLabel::AutoScrollStopMode::IMMEDIATE},
     {"FINISH_LOOP", Toolkit::TextLabel::AutoScrollStopMode::FINISH_LOOP},
 };
@@ -944,7 +944,7 @@ void TextLabel::OnInitialize()
   propertyMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::TEXT);
 
   mVisual = Toolkit::VisualFactory::Get().CreateVisual(propertyMap);
-  DevelControl::RegisterVisual(*this, Toolkit::TextLabel::Property::TEXT, mVisual);
+  DevelControl::RegisterVisual(*this, Toolkit::TextLabel::Property::TEXT, mVisual, DepthIndex::CONTENT);
 
   TextVisual::SetAnimatableTextColorProperty(mVisual, Toolkit::TextLabel::Property::TEXT_COLOR);
 
index c121cc7..9edac2d 100644 (file)
@@ -41,6 +41,7 @@
 #include <dali/public-api/object/type-registry.h>
 
 // INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
 #include <dali-toolkit/devel-api/controls/control-devel.h>
 #include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h>
 #include <dali-toolkit/devel-api/controls/web-view/web-settings.h>
@@ -867,7 +868,7 @@ void WebView::OnFrameRendered()
 
     if(mVisual)
     {
-      DevelControl::RegisterVisual(*this, Toolkit::WebView::Property::URL, mVisual);
+      DevelControl::RegisterVisual(*this, Toolkit::WebView::Property::URL, mVisual, DepthIndex::CONTENT);
       EnableBlendMode(!mVideoHoleEnabled);
     }
   }
index b3d8201..aee602d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 #include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
 #include <dali-toolkit/internal/helpers/property-helper.h>
 #include <dali-toolkit/internal/visuals/visual-string-constants.h>
@@ -121,7 +122,7 @@ Internal::Visual::Base::Impl::Impl(FittingMode fittingMode, Toolkit::Visual::Typ
   mMixColor(Color::WHITE),
   mControlSize(Vector2::ZERO),
   mDecorationData(nullptr),
-  mDepthIndex(0.0f),
+  mDepthIndex(Toolkit::DepthIndex::AUTO_INDEX),
   mFittingMode(fittingMode),
   mFlags(0),
   mResourceStatus(Toolkit::Visual::ResourceStatus::PREPARING),
index 3d8e79e..42f945d 100644 (file)
@@ -27,6 +27,7 @@
 #include <dali/public-api/rendering/visual-renderer.h>
 
 //INTERNAL HEARDER
+#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
 #include <dali-toolkit/devel-api/visuals/color-visual-properties-devel.h>
 #include <dali-toolkit/devel-api/visuals/visual-actions-devel.h>
 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
@@ -519,10 +520,16 @@ void Visual::Base::DoActionExtension(const Dali::Property::Index actionId, const
 
 void Visual::Base::SetDepthIndex(int index)
 {
-  mImpl->mDepthIndex = index;
-  if(mImpl->mRenderer)
+  // Clamp input value as valid range.
+  Dali::ClampInPlace(index, static_cast<int>(Toolkit::DepthIndex::MINIMUM_DEPTH_INDEX), static_cast<int>(Toolkit::DepthIndex::MAXIMUM_DEPTH_INDEX));
+
+  if(mImpl->mDepthIndex != index)
   {
-    mImpl->mRenderer.SetProperty(Renderer::Property::DEPTH_INDEX, mImpl->mDepthIndex);
+    mImpl->mDepthIndex = index;
+    if(mImpl->mRenderer)
+    {
+      mImpl->mRenderer.SetProperty(Renderer::Property::DEPTH_INDEX, mImpl->mDepthIndex);
+    }
   }
 }
 
@@ -542,7 +549,14 @@ void Visual::Base::SetOnScene(Actor& actor)
     if(mImpl->mRenderer)
     {
       mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, IsPreMultipliedAlphaEnabled());
-      mImpl->mRenderer.SetProperty(Renderer::Property::DEPTH_INDEX, mImpl->mDepthIndex);
+      if(mImpl->mDepthIndex == static_cast<int>(DepthIndex::AUTO_INDEX))
+      {
+        mImpl->mRenderer.SetProperty(Renderer::Property::DEPTH_INDEX, static_cast<int>(DepthIndex::CONTENT));
+      }
+      else
+      {
+        mImpl->mRenderer.SetProperty(Renderer::Property::DEPTH_INDEX, mImpl->mDepthIndex);
+      }
     }
 
     mImpl->mFlags |= Impl::IS_ON_SCENE;