(Visuals) If depth index not specified, then visual depth indices are set in order... 74/132474/4
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Mon, 5 Jun 2017 12:34:35 +0000 (13:34 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Mon, 5 Jun 2017 16:12:17 +0000 (17:12 +0100)
Change-Id: I720bbee7cd9588332b759621d204fa7cd20224ff

14 files changed:
automated-tests/src/dali-toolkit/utc-Dali-ControlWrapper.cpp
automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp
dali-toolkit/devel-api/controls/control-devel.cpp
dali-toolkit/devel-api/controls/control-devel.h
dali-toolkit/devel-api/controls/control-wrapper-impl.cpp
dali-toolkit/devel-api/controls/control-wrapper-impl.h
dali-toolkit/internal/controls/buttons/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/effects-view/effects-view-impl.cpp
dali-toolkit/internal/controls/progress-bar/progress-bar-impl.cpp
dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp
dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp
dali-toolkit/public-api/controls/control-impl.cpp

index 8caf518..93e47ff 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -405,6 +405,43 @@ int UtcDaliControlWrapperRegisterVisualToSelf(void)
   END_TEST;
 }
 
   END_TEST;
 }
 
+int UtcDaliControlWrapperRegisterVisualWithDepthIndexToSelf(void)
+{
+  ToolkitTestApplication application;
+
+  Test::ObjectDestructionTracker objectDestructionTracker;
+
+  {
+    Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
+    ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
+
+    objectDestructionTracker.Start( controlWrapper );
+
+    Property::Index index = 1;
+
+    Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+    Toolkit::Visual::Base visual;
+
+    Property::Map map;
+    map[Visual::Property::TYPE] = Visual::COLOR;
+    map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+
+    visual = visualFactory.CreateVisual( map );
+    DALI_TEST_CHECK( visual );
+
+    // Register to self
+    controlWrapperImpl->RegisterVisual( index, visual, 4.0f );
+
+    DALI_TEST_EQUALS( objectDestructionTracker.IsDestroyed(), false, TEST_LOCATION ); // Control not destroyed yet
+    DALI_TEST_EQUALS( controlWrapperImpl->GetVisual( index ), visual, TEST_LOCATION );
+    DALI_TEST_EQUALS( visual.GetDepthIndex(), 4.0f, TEST_LOCATION );
+  }
+
+  DALI_TEST_EQUALS( objectDestructionTracker.IsDestroyed(), true, TEST_LOCATION ); // Should be destroyed
+
+  END_TEST;
+}
+
 int UtcDaliControlWrapperRegisterDisabledVisual(void)
 {
   ToolkitTestApplication application;
 int UtcDaliControlWrapperRegisterDisabledVisual(void)
 {
   ToolkitTestApplication application;
@@ -447,6 +484,49 @@ int UtcDaliControlWrapperRegisterDisabledVisual(void)
   END_TEST;
 }
 
   END_TEST;
 }
 
+int UtcDaliControlWrapperRegisterDisabledVisualWithDepthIndex(void)
+{
+  ToolkitTestApplication application;
+
+  Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
+  ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
+
+  Property::Index TEST_PROPERTY = 1;
+
+  Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+  Toolkit::Visual::Base visual;
+
+  Property::Map map;
+  map[Visual::Property::TYPE] = Visual::COLOR;
+  map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+
+  visual = visualFactory.CreateVisual( map );
+  DALI_TEST_CHECK(visual);
+
+  // Register index with a color visual
+  controlWrapperImpl->RegisterVisual( TEST_PROPERTY, visual, false, 10.0f );
+
+  DALI_TEST_EQUALS( controlWrapperImpl->GetVisual( TEST_PROPERTY ), visual, TEST_LOCATION );
+  DALI_TEST_EQUALS( controlWrapperImpl->IsVisualEnabled( TEST_PROPERTY ), false, TEST_LOCATION );
+  DALI_TEST_EQUALS( visual.GetDepthIndex(), 10.0f, TEST_LOCATION );
+
+  Stage::GetCurrent().Add( controlWrapper );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( controlWrapperImpl->IsVisualEnabled( TEST_PROPERTY ), false, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( controlWrapper.OnStage(), true, TEST_LOCATION );
+
+  controlWrapperImpl->EnableVisual( TEST_PROPERTY, true );
+
+  DALI_TEST_EQUALS( controlWrapperImpl->IsVisualEnabled( TEST_PROPERTY ), true, TEST_LOCATION );
+
+  END_TEST;
+}
+
 int UtcDaliControlWrapperRegisterUnregisterVisual(void)
 {
   ToolkitTestApplication application;
 int UtcDaliControlWrapperRegisterUnregisterVisual(void)
 {
   ToolkitTestApplication application;
index 1222bd5..c121a53 100644 (file)
@@ -23,6 +23,7 @@
 #include <dali/public-api/rendering/texture-set.h>
 #include <dali/public-api/rendering/shader.h>
 #include <dali/devel-api/object/handle-devel.h>
 #include <dali/public-api/rendering/texture-set.h>
 #include <dali/public-api/rendering/shader.h>
 #include <dali/devel-api/object/handle-devel.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/visual-factory/transition-data.h>
 #include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
 #include <dali-toolkit/devel-api/visual-factory/transition-data.h>
 #include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
@@ -2080,3 +2081,97 @@ int UtcDaliVisualPremultipliedAlpha(void)
 
   END_TEST;
 }
 
   END_TEST;
 }
+
+int UtcDaliRegisterVisualOrder(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline( "Register Visual Order" );
+
+  DummyControl dummyControl = DummyControl::New(true);
+  Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
+
+  VisualFactory factory = VisualFactory::Get();
+  Property::Map propertyMap;
+  propertyMap.Insert(Visual::Property::TYPE,  Visual::COLOR);
+  propertyMap.Insert(ColorVisual::Property::MIX_COLOR,  Color::BLUE);
+
+  tet_infoline( "Register visual, should have depth index of 0.0f" );
+  Visual::Base testVisual = factory.CreateVisual( propertyMap );
+  dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, testVisual );
+  DALI_TEST_EQUALS( testVisual.GetDepthIndex(), 0.0f, TEST_LOCATION );
+
+  tet_infoline( "Register more visuals, each added one should have a depth index greater than previous" );
+
+  Visual::Base testVisual2 = factory.CreateVisual( propertyMap );
+  dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, testVisual2 );
+  DALI_TEST_CHECK( testVisual2.GetDepthIndex() > testVisual.GetDepthIndex() );
+
+  Visual::Base foregroundVisual = factory.CreateVisual( propertyMap );
+  dummyImpl.RegisterVisual( DummyControl::Property::FOREGROUND_VISUAL, foregroundVisual );
+  DALI_TEST_CHECK( foregroundVisual.GetDepthIndex() > testVisual2.GetDepthIndex() );
+
+  Visual::Base focusVisual = factory.CreateVisual( propertyMap );
+  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" );
+  Visual::Base labelVisual = factory.CreateVisual( propertyMap );
+  labelVisual.SetDepthIndex( -2000.0f );
+  dummyImpl.RegisterVisual( DummyControl::Property::LABEL_VISUAL, labelVisual );
+  DALI_TEST_EQUALS( labelVisual.GetDepthIndex(), -2000.0f, TEST_LOCATION );
+
+  tet_infoline( "Replace visual, the depth index should be the same as what was previously set" );
+  const float testVisual2DepthIndex = testVisual2.GetDepthIndex();
+  Visual::Base testVisual2Replacement = factory.CreateVisual( propertyMap );
+  DALI_TEST_CHECK( testVisual2Replacement.GetDepthIndex() != testVisual2DepthIndex );
+  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" );
+  Visual::Base anotherTestVisual2Replacement = factory.CreateVisual( propertyMap );
+  anotherTestVisual2Replacement.SetDepthIndex( 2000.0f );
+  dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, anotherTestVisual2Replacement );
+  DALI_TEST_EQUALS( anotherTestVisual2Replacement.GetDepthIndex(), 2000.0f, TEST_LOCATION );
+
+  dummyControl.SetSize(200.f, 200.f);
+  Stage::GetCurrent().Add( dummyControl );
+
+  END_TEST;
+}
+
+int UtcDaliRegisterVisualWithDepthIndex(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline( "Register a Visual With Depth Index" );
+
+  DummyControl dummyControl = DummyControl::New(true);
+  Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
+
+  VisualFactory factory = VisualFactory::Get();
+  Property::Map propertyMap;
+  propertyMap.Insert(Visual::Property::TYPE,  Visual::COLOR);
+  propertyMap.Insert(ColorVisual::Property::MIX_COLOR,  Color::BLUE);
+
+  tet_infoline( "Register a visual with a depth index, it should be enabled by default too" );
+  Visual::Base testVisual = factory.CreateVisual( propertyMap );
+  DevelControl::RegisterVisual( dummyImpl, DummyControl::Property::TEST_VISUAL, testVisual, 203.0f );
+  DALI_TEST_EQUALS( testVisual.GetDepthIndex(), 203.0f, TEST_LOCATION );
+  DALI_TEST_EQUALS( DevelControl::IsVisualEnabled( dummyImpl, DummyControl::Property::TEST_VISUAL ), true, TEST_LOCATION );
+
+  tet_infoline( "Register another visual with a depth index and it disabled" );
+  Visual::Base testVisual2 = factory.CreateVisual( propertyMap );
+  DevelControl::RegisterVisual( dummyImpl, DummyControl::Property::TEST_VISUAL2, testVisual2, false, 450.0f );
+  DALI_TEST_EQUALS( testVisual2.GetDepthIndex(), 450.0f, TEST_LOCATION );
+  DALI_TEST_EQUALS( DevelControl::IsVisualEnabled( dummyImpl, DummyControl::Property::TEST_VISUAL2 ), false, TEST_LOCATION );
+
+  tet_infoline( "Register another visual with a depth index and it enabled using the enabled API" );
+  Visual::Base testVisual3 = factory.CreateVisual( propertyMap );
+  DevelControl::RegisterVisual( dummyImpl, DummyControl::Property::TEST_VISUAL2, testVisual3, true, 300.0f );
+  DALI_TEST_EQUALS( testVisual3.GetDepthIndex(), 300.0f, TEST_LOCATION );
+  DALI_TEST_EQUALS( DevelControl::IsVisualEnabled( dummyImpl, DummyControl::Property::TEST_VISUAL2 ), true, TEST_LOCATION );
+
+  dummyControl.SetSize(200.f, 200.f);
+  Stage::GetCurrent().Add( dummyControl );
+
+  END_TEST;
+}
index 77b2368..ba249a9 100644 (file)
@@ -57,12 +57,24 @@ void RegisterVisual( Internal::Control& control, Dali::Property::Index index, To
   controlImpl.RegisterVisual( index, visual );
 }
 
   controlImpl.RegisterVisual( index, visual );
 }
 
+void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, float depthIndex )
+{
+  Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
+  controlImpl.RegisterVisual( index, visual, depthIndex );
+}
+
 void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, bool enabled )
 {
   Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
   controlImpl.RegisterVisual( index, visual, enabled );
 }
 
 void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, bool enabled )
 {
   Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
   controlImpl.RegisterVisual( index, visual, enabled );
 }
 
+void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, bool enabled, float depthIndex )
+{
+  Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
+  controlImpl.RegisterVisual( index, visual, enabled, depthIndex );
+}
+
 void UnregisterVisual( Internal::Control& control, Dali::Property::Index index )
 {
   Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
 void UnregisterVisual( Internal::Control& control, Dali::Property::Index index )
 {
   Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
index 7795df1..f6d5b38 100644 (file)
@@ -139,34 +139,66 @@ DALI_IMPORT_API ResourceReadySignalType& ResourceReadySignal( Control& control )
 DALI_IMPORT_API bool IsResourceReady( const Control& control );
 
 /**
 DALI_IMPORT_API bool IsResourceReady( const Control& control );
 
 /**
- * @brief Register a visual by Property Index, linking an Actor to visual when required.
- * In the case of the visual being an actor or control deeming visual not required then visual should be an empty handle.
- * No parenting is done during registration, this should be done by derived class.
+ * @brief Register a visual by Property Index.
  *
  * @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] control The control
  * @param[in] index The Property index of the visual, used to reference visual
  * @param[in] visual The visual to register
+ *
  * @note Derived class should not call visual.SetOnStage(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 Derived class should not call visual.SetOnStage(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.
  */
 DALI_IMPORT_API void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual );
 
 /**
  */
 DALI_IMPORT_API void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual );
 
 /**
- * @brief Register a visual by Property Index, linking an Actor to visual when required.
+ * @brief Register a visual by Property Index with a depth index.
+ *
+ * @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
  *
  *
- * In the case of the visual being an actor or control deeming visual not required then visual should be an empty handle.
- * If enabled is false then the visual is not set on stage until enabled by the derived class.
- * @see EnableVisual
+ * @note Derived class should not call visual.SetOnStage(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.
+ *
+ * @see Visual::Base::GetDepthIndex()
+ * @see Visual::Base::SetDepthIndex()
+ */
+DALI_IMPORT_API void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, float depthIndex );
+
+/**
+ * @brief Register a visual by Property Index with the option of enabling/disabling it.
  *
  * @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] enabled false if derived class wants to control when visual is set on stage.
  *
  *
  * @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] 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.
+ *
+ * @see EnableVisual()
  */
 DALI_IMPORT_API void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, bool enabled );
 
 /**
  */
 DALI_IMPORT_API void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, bool enabled );
 
 /**
+ * @brief Register a visual by Property Index with a depth index with the option of enabling/disabling it.
+ *
+ * @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] 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
+ *
+ * @see EnableVisual()
+ * @see Visual::Base::GetDepthIndex()
+ * @see Visual::Base::SetDepthIndex()
+ */
+DALI_IMPORT_API void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, bool enabled, float depthIndex );
+
+/**
  * @brief Erase the entry matching the given index from the list of registered visuals
  *
  * @param[in] control The control
  * @brief Erase the entry matching the given index from the list of registered visuals
  *
  * @param[in] control The control
index fbbfa2e..8c7a76e 100755 (executable)
@@ -125,11 +125,21 @@ void ControlWrapper::RegisterVisual( Property::Index index, Toolkit::Visual::Bas
   DevelControl::RegisterVisual( *this, index, visual );
 }
 
   DevelControl::RegisterVisual( *this, index, visual );
 }
 
+void ControlWrapper::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, float depthIndex )
+{
+  DevelControl::RegisterVisual( *this, index, visual, depthIndex );
+}
+
 void ControlWrapper::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled )
 {
   DevelControl::RegisterVisual( *this, index, visual, enabled );
 }
 
 void ControlWrapper::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled )
 {
   DevelControl::RegisterVisual( *this, index, visual, enabled );
 }
 
+void ControlWrapper::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled, float depthIndex )
+{
+  DevelControl::RegisterVisual( *this, index, visual, enabled, depthIndex );
+}
+
 void ControlWrapper::UnregisterVisual( Property::Index index )
 {
   DevelControl::UnregisterVisual( *this, index );
 void ControlWrapper::UnregisterVisual( Property::Index index )
 {
   DevelControl::UnregisterVisual( *this, index );
index 85bc26c..8a35ee9 100755 (executable)
@@ -118,9 +118,19 @@ public: // From Control
   /**
    * @ref Dali::Toolkit::DevelControl::RegisterVisual()
    */
   /**
    * @ref Dali::Toolkit::DevelControl::RegisterVisual()
    */
+  void RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, float depthIndex );
+
+  /**
+   * @ref Dali::Toolkit::DevelControl::RegisterVisual()
+   */
   void RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled );
 
   /**
   void RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled );
 
   /**
+   * @ref Dali::Toolkit::DevelControl::RegisterVisual()
+   */
+  void RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled, float depthIndex );
+
+  /**
    * @ref Dali::Toolkit::DevelControl::UnregisterVisual()
    */
   void UnregisterVisual( Property::Index index );
    * @ref Dali::Toolkit::DevelControl::UnregisterVisual()
    */
   void UnregisterVisual( Property::Index index );
index b52e46c..e8378cb 100644 (file)
@@ -453,8 +453,7 @@ void Button::CreateVisualsForComponent( Property::Index index, const Property::V
   {
     DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "CreateVisualsForComponent RegisterVisual index(%d) enabled(%s)\n",
                    index, DevelControl::IsVisualEnabled( *this, index )?"true":"false" );
   {
     DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "CreateVisualsForComponent RegisterVisual index(%d) enabled(%s)\n",
                    index, DevelControl::IsVisualEnabled( *this, index )?"true":"false" );
-    buttonVisual.SetDepthIndex( visualDepth );
-    DevelControl::RegisterVisual( *this, index, buttonVisual, DevelControl::IsVisualEnabled( *this, index ) );
+    DevelControl::RegisterVisual( *this, index, buttonVisual, DevelControl::IsVisualEnabled( *this, index ), visualDepth );
   }
   else
   {
   }
   else
   {
index f20e489..b04aa2a 100644 (file)
@@ -27,6 +27,7 @@
 #include <dali/integration-api/debug.h>
 #include <dali/public-api/object/type-registry-helper.h>
 #include <cstring>
 #include <dali/integration-api/debug.h>
 #include <dali/public-api/object/type-registry-helper.h>
 #include <cstring>
+#include <limits>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
@@ -383,11 +384,26 @@ bool Control::Impl::IsResourceReady() const
 
 void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual )
 {
 
 void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual )
 {
-  RegisterVisual( index, visual, true );
+  RegisterVisual( index, visual, VisualState::ENABLED, DepthIndexValue::NOT_SET );
+}
+
+void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, float depthIndex )
+{
+  RegisterVisual( index, visual, VisualState::ENABLED, DepthIndexValue::SET, depthIndex );
 }
 
 void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled )
 {
 }
 
 void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled )
 {
+  RegisterVisual( index, visual, ( enabled ? VisualState::ENABLED : VisualState::DISABLED ), DepthIndexValue::NOT_SET );
+}
+
+void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled, float depthIndex )
+{
+  RegisterVisual( index, visual, ( enabled ? VisualState::ENABLED : VisualState::DISABLED ), DepthIndexValue::SET, depthIndex );
+}
+
+void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, VisualState::Type enabled, DepthIndexValue::Type depthIndexValueSet, float depthIndex )
+{
   bool visualReplaced ( false );
   Actor self = mControlImpl.Self();
 
   bool visualReplaced ( false );
   Actor self = mControlImpl.Self();
 
@@ -402,10 +418,19 @@ void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base
         Toolkit::GetImplementation((*iter)->visual).SetOffStage( self );
       }
 
         Toolkit::GetImplementation((*iter)->visual).SetOffStage( self );
       }
 
+      // 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 ) &&
+          EqualsZero( visual.GetDepthIndex() ) )
+      {
+        const float currentDepthIndex = (*iter)->visual.GetDepthIndex();
+        visual.SetDepthIndex( currentDepthIndex );
+      }
+
       StopObservingVisual( (*iter)->visual );
       StartObservingVisual( visual );
 
       (*iter)->visual = visual;
       StopObservingVisual( (*iter)->visual );
       StartObservingVisual( visual );
 
       (*iter)->visual = visual;
+      (*iter)->enabled = ( enabled == VisualState::ENABLED ) ? true : false;
       visualReplaced = true;
     }
   }
       visualReplaced = true;
     }
   }
@@ -433,16 +458,47 @@ void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base
 
   if( !visualReplaced ) // New registration entry
   {
 
   if( !visualReplaced ) // New registration entry
   {
-    mVisuals.PushBack( new RegisteredVisual( index, visual, enabled ) );
+    mVisuals.PushBack( new RegisteredVisual( index, visual, ( enabled == VisualState::ENABLED ? true : false ) ) );
 
     // monitor when the visuals resources are ready
     StartObservingVisual( visual );
 
 
     // monitor when the visuals resources are ready
     StartObservingVisual( visual );
 
+    // 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() > 1 ) &&
+        EqualsZero( visual.GetDepthIndex() ) )
+    {
+      float maxDepthIndex = std::numeric_limits< float >::min();
+
+      RegisteredVisualContainer::ConstIterator iter;
+      const RegisteredVisualContainer::ConstIterator endIter = mVisuals.End();
+      for ( iter = mVisuals.Begin(); iter != endIter; iter++ )
+      {
+        const float visualDepthIndex = (*iter)->visual.GetDepthIndex();
+        if ( visualDepthIndex > maxDepthIndex )
+        {
+          maxDepthIndex = visualDepthIndex;
+        }
+      }
+
+      ++maxDepthIndex; // Add one to the current maximum depth index so that our added visual appears on top
+      visual.SetDepthIndex( maxDepthIndex );
+    }
   }
 
   }
 
-  if( visual && self.OnStage() && enabled )
+  if( visual )
   {
   {
-    Toolkit::GetImplementation(visual).SetOnStage( self );
+    // If the caller has set the depth-index, then set it here
+    if( depthIndexValueSet == DepthIndexValue::SET )
+    {
+      visual.SetDepthIndex( depthIndex );
+    }
+
+    // Put on stage if enabled and the control is already on the stage
+    if( ( enabled == VisualState::ENABLED ) && self.OnStage() )
+    {
+      Toolkit::GetImplementation(visual).SetOnStage( self );
+    }
   }
 
   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::RegisterVisual() Registered %s(%d), enabled:%s\n",  visual.GetName().c_str(), index, enabled?"T":"F" );
   }
 
   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::RegisterVisual() Registered %s(%d), enabled:%s\n",  visual.GetName().c_str(), index, enabled?"T":"F" );
@@ -737,8 +793,7 @@ void Control::Impl::SetProperty( BaseObject* object, Property::Index index, cons
           Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( url, ImageDimensions() );
           if( visual )
           {
           Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( url, ImageDimensions() );
           if( visual )
           {
-            controlImpl.mImpl->RegisterVisual( Toolkit::Control::Property::BACKGROUND, visual );
-            visual.SetDepthIndex( DepthIndex::BACKGROUND );
+            controlImpl.mImpl->RegisterVisual( Toolkit::Control::Property::BACKGROUND, visual, float( DepthIndex::BACKGROUND ) );
           }
         }
         else if( value.Get( color ) )
           }
         }
         else if( value.Get( color ) )
index 2ee216f..5a0a351 100644 (file)
@@ -133,9 +133,19 @@ public:
   /**
    * @copydoc Dali::Toolkit::DevelControl::RegisterVisual()
    */
   /**
    * @copydoc Dali::Toolkit::DevelControl::RegisterVisual()
    */
+  void RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, float depthIndex );
+
+  /**
+   * @copydoc Dali::Toolkit::DevelControl::RegisterVisual()
+   */
   void RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled );
 
   /**
   void RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled );
 
   /**
+   * @copydoc Dali::Toolkit::DevelControl::RegisterVisual()
+   */
+  void RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled, float depthIndex );
+
+  /**
    * @copydoc Dali::Toolkit::DevelControl::UnregisterVisual()
    */
   void UnregisterVisual( Property::Index index );
    * @copydoc Dali::Toolkit::DevelControl::UnregisterVisual()
    */
   void UnregisterVisual( Property::Index index );
@@ -249,6 +259,44 @@ public:
    */
   bool IsResourceReady() const;
 
    */
   bool IsResourceReady() const;
 
+private:
+
+  /**
+   * Used as an alternative to boolean so that it is obvious whether a visual is enabled/disabled.
+   */
+  struct VisualState
+  {
+    enum Type
+    {
+      DISABLED = 0, ///< Visual disabled.
+      ENABLED = 1   ///< Visual enabled.
+    };
+  };
+
+  /**
+   * Used as an alternative to boolean so that it is obvious whether a visual's depth value has been set or not by the caller.
+   */
+  struct DepthIndexValue
+  {
+    enum Type
+    {
+      NOT_SET = 0, ///< Visual depth value not set by caller.
+      SET = 1      ///< Visual depth value set by caller.
+    };
+  };
+
+  /**
+   * @brief Adds the visual to the list of registered visuals.
+   * @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] depthIndexValueSet Set to true if the depthIndex has actually been set manually
+   * @param[in] depthIndex The visual's depth-index is set to this
+   */
+  void RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, VisualState::Type enabled, DepthIndexValue::Type depthIndexValueSet, float depthIndex = 0.0f );
+
+public:
+
   Control& mControlImpl;
   DevelControl::State mState;
   std::string mSubStateName;
   Control& mControlImpl;
   DevelControl::State mState;
   std::string mSubStateName;
index db76861..4285524 100644 (file)
@@ -428,8 +428,7 @@ void EffectsView::AllocateResources()
 
     mImageForChildren = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat );
     Internal::InitializeVisual( self, mVisualForChildren, mImageForChildren );
 
     mImageForChildren = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat );
     Internal::InitializeVisual( self, mVisualForChildren, mImageForChildren );
-    DevelControl::RegisterVisual( *this, CHILD_VISUAL, mVisualForChildren );
-    mVisualForChildren.SetDepthIndex( DepthIndex::CONTENT+1 );
+    DevelControl::RegisterVisual( *this, CHILD_VISUAL, mVisualForChildren, float( DepthIndex::CONTENT + 1 ) );
 
     mImagePostFilter = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat );
     TextureSet textureSet = TextureSet::New();
 
     mImagePostFilter = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat );
     TextureSet textureSet = TextureSet::New();
index 24b1aa4..d591c5a 100755 (executable)
@@ -375,14 +375,13 @@ void ProgressBar::CreateVisualsForComponent( Property::Index index, const Proper
 
   if ( progressVisual )
   {
 
   if ( progressVisual )
   {
-    progressVisual.SetDepthIndex( visualDepth );
     if( index == Toolkit::ProgressBar::Property::INDETERMINATE_VISUAL )
     {
     if( index == Toolkit::ProgressBar::Property::INDETERMINATE_VISUAL )
     {
-      DevelControl::RegisterVisual( *this, index, progressVisual, mIndeterminate );
+      DevelControl::RegisterVisual( *this, index, progressVisual, mIndeterminate, visualDepth );
     }
     else
     {
     }
     else
     {
-      DevelControl::RegisterVisual( *this, index, progressVisual, true );
+      DevelControl::RegisterVisual( *this, index, progressVisual, true, visualDepth );
     }
   }
   else
     }
   }
   else
index 581b87e..7aa46b8 100644 (file)
@@ -174,8 +174,7 @@ void SuperBlurView::SetImage(Image inputImage)
   Actor self( Self() );
 
   mVisuals[0] = Toolkit::VisualFactory::Get().CreateVisual( mInputImage );
   Actor self( Self() );
 
   mVisuals[0] = Toolkit::VisualFactory::Get().CreateVisual( mInputImage );
-  DevelControl::RegisterVisual( *this, 0, mVisuals[0] ); // Will clean up previously registered visuals for this index.
-  mVisuals[0].SetDepthIndex(0);
+  DevelControl::RegisterVisual( *this, 0, mVisuals[0], 0.0f ); // Will clean up previously registered visuals for this index.
   // custom shader is not applied on the original image.
 
   BlurImage( 0,  inputImage);
   // custom shader is not applied on the original image.
 
   BlurImage( 0,  inputImage);
@@ -283,8 +282,7 @@ void SuperBlurView::OnSizeSet( const Vector3& targetSize )
                                                 GAUSSIAN_BLUR_RENDER_TARGET_PIXEL_FORMAT );
 
       mVisuals[i] = Toolkit::VisualFactory::Get().CreateVisual( mBlurredImage[i - 1] );
                                                 GAUSSIAN_BLUR_RENDER_TARGET_PIXEL_FORMAT );
 
       mVisuals[i] = Toolkit::VisualFactory::Get().CreateVisual( mBlurredImage[i - 1] );
-      DevelControl::RegisterVisual( *this, i, mVisuals[i] ); // Will clean up existing visual with same index.
-      mVisuals[i].SetDepthIndex( i );
+      DevelControl::RegisterVisual( *this, i, mVisuals[i], float( i ) ); // Will clean up existing visual with same index.
       SetShaderEffect( mVisuals[i] );
     }
 
       SetShaderEffect( mVisuals[i] );
     }
 
index 597fee1..3486aab 100644 (file)
@@ -850,8 +850,7 @@ void TextSelectionPopup::CreateBackgroundBorder( Property::Map& propertyMap )
 
     if( visual )
     {
 
     if( visual )
     {
-      DevelControl::RegisterVisual( *this, Toolkit::TextSelectionPopup::Property::BACKGROUND_BORDER, visual );
-      visual.SetDepthIndex( DepthIndex::CONTENT );
+      DevelControl::RegisterVisual( *this, Toolkit::TextSelectionPopup::Property::BACKGROUND_BORDER, visual, float( DepthIndex::CONTENT ) );
     }
   }
 }
     }
   }
 }
index a41a6f3..aa0ef0b 100644 (file)
@@ -124,8 +124,7 @@ void Control::SetBackground( const Property::Map& map )
   Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( map );
   if( visual )
   {
   Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( map );
   if( visual )
   {
-    mImpl->RegisterVisual( Toolkit::Control::Property::BACKGROUND, visual );
-    visual.SetDepthIndex( DepthIndex::BACKGROUND );
+    mImpl->RegisterVisual( Toolkit::Control::Property::BACKGROUND, visual, float( DepthIndex::BACKGROUND ) );
 
     // Trigger a size negotiation request that may be needed by the new visual to relayout its contents.
     RelayoutRequest();
 
     // Trigger a size negotiation request that may be needed by the new visual to relayout its contents.
     RelayoutRequest();
@@ -137,8 +136,7 @@ void Control::SetBackgroundImage( Image image )
   Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( image );
   if( visual )
   {
   Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( image );
   if( visual )
   {
-    mImpl->RegisterVisual( Toolkit::Control::Property::BACKGROUND, visual );
-    visual.SetDepthIndex( DepthIndex::BACKGROUND );
+    mImpl->RegisterVisual( Toolkit::Control::Property::BACKGROUND, visual, float( DepthIndex::BACKGROUND ) );
   }
 }
 
   }
 }