X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Fpublic-api%2Fcontrols%2Fcontrol-impl.cpp;h=b41b6300ae3d247a5eea44f96fe4b2dfb0e134a6;hp=649946c76f1e17de5ef41cea4e3f70c86dbd1701;hb=12ba8f6537fee9e4ad8c4fc11bbbea01691833b2;hpb=46fe497b39cfdec35dade509903cde6f4d7f7e89 diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp index 649946c..b41b630 100644 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -40,7 +40,6 @@ #include #include #include -#include namespace Dali { @@ -165,6 +164,7 @@ TypeAction registerAction( typeRegistration, ACTION_ACCESSIBILITY_ACTIVATED, &Do DALI_TYPE_REGISTRATION_END() const char * const BACKGROUND_COLOR_NAME("color"); +const char * const COLOR_RENDERER_COLOR_NAME("blendColor"); } // unnamed namespace @@ -399,42 +399,28 @@ const std::string& Control::GetStyleName() const 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(); - - 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 { + 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; } @@ -450,28 +436,21 @@ void Control::SetBackground(const Property::Map& map) Actor self( Self() ); mImpl->mBackgroundRenderer.RemoveAndReset( self ); - 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(); - - 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()