Change-Id: If6cce8812d0ff68c7ed263796ca098460c89b905
DALI_TEST_CHECK( resultMap->Find( "blendColor" ) );
DALI_TEST_CHECK( resultMap->Find( "blendColor" )->Get<Vector4>() == Color::RED );
DALI_TEST_CHECK( resultMap->Find( "blendColor" ) );
DALI_TEST_CHECK( resultMap->Find( "blendColor" )->Get<Vector4>() == Color::RED );
+ DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::RED, TEST_LOCATION );
+
control.SetBackgroundColor( Color::YELLOW );
propValue = control.GetProperty( Control::Property::BACKGROUND );
control.SetBackgroundColor( Color::YELLOW );
propValue = control.GetProperty( Control::Property::BACKGROUND );
DALI_TEST_CHECK( resultMap->Find( "blendColor" ) );
DALI_TEST_CHECK( resultMap->Find( "blendColor" )->Get<Vector4>() == Color::YELLOW );
DALI_TEST_CHECK( resultMap->Find( "blendColor" ) );
DALI_TEST_CHECK( resultMap->Find( "blendColor" )->Get<Vector4>() == Color::YELLOW );
+ DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::YELLOW, TEST_LOCATION );
+
#include <dali-toolkit/devel-api/styling/style-manager.h>
#include <dali-toolkit/internal/styling/style-manager-impl.h>
#include <dali-toolkit/internal/controls/renderers/color/color-renderer.h>
#include <dali-toolkit/devel-api/styling/style-manager.h>
#include <dali-toolkit/internal/styling/style-manager-impl.h>
#include <dali-toolkit/internal/controls/renderers/color/color-renderer.h>
-#include <dali-toolkit/internal/controls/renderers/image/image-renderer.h>
DALI_TYPE_REGISTRATION_END()
const char * const BACKGROUND_COLOR_NAME("color");
DALI_TYPE_REGISTRATION_END()
const char * const BACKGROUND_COLOR_NAME("color");
+const char * const COLOR_RENDERER_COLOR_NAME("blendColor");
return mImpl->mStyleName;
}
return mImpl->mStyleName;
}
-void Control::UpdateBackgroundState()
-{
- // Set the depth of the background renderer after creating/modifying it.
- // We do this regardless of whether or not it is on stage as the index
- // is relative and still valid if this control is re-parented.
- if( mImpl->mBackgroundRenderer )
- {
- mImpl->mBackgroundRenderer.SetDepthIndex( BACKGROUND_DEPTH_INDEX );
-
- Actor self( Self() );
- if( self.OnStage() )
- {
- mImpl->mBackgroundRenderer.SetOnStage( self );
- }
- }
-}
-
void Control::SetBackgroundColor( const Vector4& color )
{
Actor self( Self() );
Toolkit::RendererFactory factory = Toolkit::RendererFactory::Get();
void Control::SetBackgroundColor( const Vector4& color )
{
Actor self( Self() );
Toolkit::RendererFactory factory = Toolkit::RendererFactory::Get();
-
- if( mImpl->mBackgroundRenderer )
- {
- factory.ResetRenderer( mImpl->mBackgroundRenderer, self, color );
- }
- else
- {
- mImpl->mBackgroundRenderer = factory.GetControlRenderer( color );
- }
-
- UpdateBackgroundState();
+ factory.ResetRenderer( mImpl->mBackgroundRenderer, self, color );
+ mImpl->mBackgroundRenderer.SetDepthIndex( BACKGROUND_DEPTH_INDEX );
}
Vector4 Control::GetBackgroundColor() const
{
}
Vector4 Control::GetBackgroundColor() const
{
+ if( mImpl->mBackgroundRenderer && ( &typeid( GetImplementation(mImpl->mBackgroundRenderer) ) == &typeid( ColorRenderer ) ) )
+ {
+ Property::Map map;
+ mImpl->mBackgroundRenderer.CreatePropertyMap( map );
+ const Property::Value* colorValue = map.Find( COLOR_RENDERER_COLOR_NAME );
+ Vector4 color;
+ if( colorValue && colorValue->Get(color))
+ {
+ return color;
+ }
+ }
+
return Color::TRANSPARENT;
}
return Color::TRANSPARENT;
}
Actor self( Self() );
mImpl->mBackgroundRenderer.RemoveAndReset( self );
Actor self( Self() );
mImpl->mBackgroundRenderer.RemoveAndReset( self );
Toolkit::RendererFactory factory = Toolkit::RendererFactory::Get();
mImpl->mBackgroundRenderer = factory.GetControlRenderer( map );
Toolkit::RendererFactory factory = Toolkit::RendererFactory::Get();
mImpl->mBackgroundRenderer = factory.GetControlRenderer( map );
-
- UpdateBackgroundState();
+ if( mImpl->mBackgroundRenderer && self.OnStage() ) // Request control renderer with a property map might return an empty handle
+ {
+ mImpl->mBackgroundRenderer.SetDepthIndex( BACKGROUND_DEPTH_INDEX );
+ mImpl->mBackgroundRenderer.SetOnStage( self );
+ }
}
void Control::SetBackgroundImage( Image image )
{
Actor self( Self() );
Toolkit::RendererFactory factory = Toolkit::RendererFactory::Get();
}
void Control::SetBackgroundImage( Image image )
{
Actor self( Self() );
Toolkit::RendererFactory factory = Toolkit::RendererFactory::Get();
-
- if( mImpl->mBackgroundRenderer )
- {
- factory.ResetRenderer( mImpl->mBackgroundRenderer, self, image );
- }
- else
- {
- mImpl->mBackgroundRenderer = factory.GetControlRenderer( image );
- }
-
- UpdateBackgroundState();
+ factory.ResetRenderer( mImpl->mBackgroundRenderer, self, image );
+ mImpl->mBackgroundRenderer.SetDepthIndex( BACKGROUND_DEPTH_INDEX );
}
void Control::ClearBackground()
}
void Control::ClearBackground()
*/
DALI_INTERNAL bool EmitKeyEventSignal( const KeyEvent& event );
*/
DALI_INTERNAL bool EmitKeyEventSignal( const KeyEvent& event );
-private:
-
- /**
- * Sets up the background image/color based on the current state.
- * This will set the depth index (always), and add to stage if the control is on stage.
- *
- */
- void UpdateBackgroundState();
-
protected: // For derived classes to call
/**
protected: // For derived classes to call
/**
/**
* @brief Sets the background color of the control.
*
/**
* @brief Sets the background color of the control.
*
+ * @note if SetBackgroundImage is called later, this background color is removed.
+ *
* @param[in] color The required background color of the control
*
* @note The background color fully blends with the actor color.
* @param[in] color The required background color of the control
*
* @note The background color fully blends with the actor color.