X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Fpublic-api%2Fcontrols%2Fcontrol-impl.cpp;h=68fd55ad3457c1b982f77889b3fdd87338348c6d;hb=9601caa4c6862e87f072a6f0cba8a0a19036e55d;hp=05f7ab32f5ac667241d21eb7b899389ecf00453f;hpb=d26f555fd84d43b0a3e650c66a0e626e841dd9c6;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp index 05f7ab3..68fd55a 100644 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -36,12 +36,12 @@ #include #include #include -#include +#include #include #include #include #include -#include +#include #include namespace Dali @@ -60,13 +60,30 @@ namespace Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_CONTROL_VISUALS"); #endif -DALI_ENUM_TO_STRING_TABLE_BEGIN( CLIPPING_MODE ) -DALI_ENUM_TO_STRING_WITH_SCOPE( ClippingMode, DISABLED ) -DALI_ENUM_TO_STRING_WITH_SCOPE( ClippingMode, CLIP_CHILDREN ) -DALI_ENUM_TO_STRING_TABLE_END( CLIPPING_MODE ) +/** + * @brief Creates a clipping renderer if required. + * (EG. If no renders exist and clipping is enabled). + * @param[in] controlImpl The control implementation. + */ +void CreateClippingRenderer( Control& controlImpl ) +{ + // We want to add a transparent background if we do not have one for clipping. + Actor self( controlImpl.Self() ); + int clippingMode = ClippingMode::DISABLED; + if( self.GetProperty( Actor::Property::CLIPPING_MODE ).Get( clippingMode ) ) + { + Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl ); -} // unnamed namespace + if( ( clippingMode == ClippingMode::CLIP_CHILDREN ) && + controlDataImpl.mVisuals.Empty() && + ( self.GetRendererCount() == 0u ) ) + { + controlImpl.SetBackgroundColor( Color::TRANSPARENT ); + } + } +} +} // unnamed namespace Toolkit::Control Control::New() @@ -108,7 +125,7 @@ void Control::SetBackgroundColor( const Vector4& color ) { mImpl->mBackgroundColor = color; Property::Map map; - map[ Toolkit::DevelVisual::Property::TYPE ] = Toolkit::Visual::COLOR; + map[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::COLOR; map[ Toolkit::ColorVisual::Property::MIX_COLOR ] = color; SetBackground( map ); @@ -498,21 +515,8 @@ void Control::OnStageConnection( int depth ) } } - if( mImpl->mVisuals.Empty() && ! self.GetRendererCount() ) - { - Property::Value clippingValue = self.GetProperty( Actor::Property::CLIPPING_MODE ); - int clippingMode = ClippingMode::DISABLED; - if( clippingValue.Get( clippingMode ) ) - { - // Add a transparent background if we do not have any renderers or visuals so we clip our children - - if( clippingMode == ClippingMode::CLIP_CHILDREN ) - { - // Create a transparent background visual which will also get staged. - SetBackgroundColor( Color::TRANSPARENT ); - } - } - } + // The clipping renderer is only created if required. + CreateClippingRenderer( *this ); } void Control::OnStageDisconnection() @@ -544,24 +548,12 @@ void Control::OnChildRemove(Actor& child) void Control::OnPropertySet( Property::Index index, Property::Value propertyValue ) { - Actor self( Self() ); - if( index == Actor::Property::CLIPPING_MODE ) + // If the clipping mode has been set, we may need to create a renderer. + // Only do this if we are already on-stage as the OnStageConnection will handle the off-stage clipping controls. + if( ( index == Actor::Property::CLIPPING_MODE ) && Self().OnStage() ) { - // Only set the background if we're already on the stage and have no renderers or visuals - - if( mImpl->mVisuals.Empty() && ! self.GetRendererCount() && self.OnStage() ) - { - ClippingMode::Type clippingMode = ClippingMode::DISABLED; - if( Scripting::GetEnumerationProperty< ClippingMode::Type >( propertyValue, CLIPPING_MODE_TABLE, CLIPPING_MODE_TABLE_COUNT, clippingMode ) ) - { - // Add a transparent background if we do not have one so we clip children - - if( clippingMode == ClippingMode::CLIP_CHILDREN ) - { - SetBackgroundColor( Color::TRANSPARENT ); - } - } - } + // Note: This method will handle whether creation of the renderer is required. + CreateClippingRenderer( *this ); } }