X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Fpublic-api%2Fcontrols%2Fcontrol-impl.cpp;h=49064a824ac2544fb7b41e6cd0f2a0c81d54060b;hb=refs%2Fchanges%2F31%2F164731%2F7;hp=cba530868079bc99971b7ebbc273a300fa095aa6;hpb=9dbf20fa1a7c08df5bb0824255c36f126ac91e05;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 cba5308..49064a8 100755 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -30,18 +30,19 @@ #include // INTERNAL INCLUDES -#include +#include #include +#include #include #include +#include #include #include -#include #include +#include #include #include #include -#include #include namespace Dali @@ -61,6 +62,30 @@ Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_CO #endif /** + * @brief Replace the background visual if it's a color visual with the renderIfTransparent property set as required. + * @param[in] controlImpl The control implementation + * @param[in] renderIfTransaparent Whether we should render if the color is transparent + */ +void ChangeBackgroundColorVisual( Control& controlImpl, bool renderIfTransparent ) +{ + Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl ); + + Toolkit::Visual::Base backgroundVisual = controlDataImpl.GetVisual( Toolkit::Control::Property::BACKGROUND ); + if( backgroundVisual ) + { + Property::Map map; + backgroundVisual.CreatePropertyMap( map ); + Property::Value* typeValue = map.Find( Toolkit::Visual::Property::TYPE ); + if( typeValue && typeValue->Get< int >() == Toolkit::Visual::COLOR ) + { + // Only change it if it's a color visual + map[ Toolkit::DevelColorVisual::Property::RENDER_IF_TRANSPARENT ] = renderIfTransparent; + controlImpl.SetBackground( map ); + } + } +} + +/** * @brief Creates a clipping renderer if required. * (EG. If no renders exist and clipping is enabled). * @param[in] controlImpl The control implementation. @@ -72,13 +97,34 @@ void CreateClippingRenderer( Control& controlImpl ) int clippingMode = ClippingMode::DISABLED; if( self.GetProperty( Actor::Property::CLIPPING_MODE ).Get( clippingMode ) ) { - Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl ); - - if( ( clippingMode == ClippingMode::CLIP_CHILDREN ) && - controlDataImpl.mVisuals.Empty() && - ( self.GetRendererCount() == 0u ) ) + switch( clippingMode ) { - controlImpl.SetBackgroundColor( Color::TRANSPARENT ); + case ClippingMode::CLIP_CHILDREN: + { + if( self.GetRendererCount() == 0u ) + { + Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl ); + if( controlDataImpl.mVisuals.Empty() ) + { + controlImpl.SetBackgroundColor( Color::TRANSPARENT ); + } + else + { + // We have visuals, check if we've set the background and re-create it to + // render even if transparent (only if it's a color visual) + ChangeBackgroundColorVisual( controlImpl, true ); + } + } + break; + } + + case ClippingMode::DISABLED: + case ClippingMode::CLIP_TO_BOUNDING_BOX: + { + // If we have a background visual, check if it's a color visual and remove the render if transparent flag + ChangeBackgroundColorVisual( controlImpl, false ); + break; + } } } } @@ -168,6 +214,14 @@ void Control::SetBackgroundColor( const Vector4& color ) map[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::COLOR; map[ Toolkit::ColorVisual::Property::MIX_COLOR ] = color; + int clippingMode = ClippingMode::DISABLED; + if( ( Self().GetProperty( Actor::Property::CLIPPING_MODE ).Get( clippingMode ) ) && + ( clippingMode == ClippingMode::CLIP_CHILDREN ) ) + { + // If clipping-mode is set to CLIP_CHILDREN, then force visual to add the render even if transparent + map[ Toolkit::DevelColorVisual::Property::RENDER_IF_TRANSPARENT ] = true; + } + SetBackground( map ); } @@ -657,11 +711,13 @@ void Control::OnRelayout( const Vector2& size, RelayoutContainer& container ) newChildSize.width = size.width - ( padding.start + padding.end ); newChildSize.height = size.height - ( padding.top + padding.bottom ); - Vector3 childPosition = child.GetTargetSize(); - childPosition.x += ( mImpl->mMargin.start + padding.start ); - childPosition.y += ( mImpl->mMargin.top + padding.top ); + // Cannot use childs Position property as it can already have padding and margin applied on it, + // so we end up cumulatively applying them over and over again. + Vector2 childOffset( 0.f, 0.f ); + childOffset.x += ( mImpl->mMargin.start + padding.start ); + childOffset.y += ( mImpl->mMargin.top + padding.top ); - child.SetPosition( childPosition ); + child.SetPosition( childOffset.x, childOffset.y ); } container.Add( child, newChildSize );