- Vector2 padding = GetPadding(dimension);
-
- return GetLatestSize(dimension) + padding.x + padding.y;
-}
-
-float Actor::NegotiateFromParent(Dimension::Type dimension)
-{
- Actor* parent = GetParent();
- if(parent)
- {
- Vector2 padding(GetPadding(dimension));
- Vector2 parentPadding(parent->GetPadding(dimension));
- return parent->CalculateChildSize(Dali::Actor(this), dimension) - parentPadding.x - parentPadding.y - padding.x - padding.y;
- }
-
- return 0.0f;
-}
-
-float Actor::NegotiateFromChildren(Dimension::Type dimension)
-{
- float maxDimensionPoint = 0.0f;
-
- for(uint32_t i = 0, count = GetChildCount(); i < count; ++i)
- {
- ActorPtr child = GetChildAt(i);
-
- if(!child->RelayoutDependentOnParent(dimension))
- {
- // Calculate the min and max points that the children range across
- float childPosition = GetDimensionValue(child->GetTargetPosition(), dimension);
- float dimensionSize = child->GetRelayoutSize(dimension);
- maxDimensionPoint = std::max(maxDimensionPoint, childPosition + dimensionSize);
- }
- }
-
- return maxDimensionPoint;
-}
-
-float Actor::GetSize(Dimension::Type dimension) const
-{
- return GetDimensionValue(mTargetSize, dimension);
-}
-
-float Actor::GetNaturalSize(Dimension::Type dimension) const
-{
- return GetDimensionValue(GetNaturalSize(), dimension);
-}
-
-float Actor::CalculateSize(Dimension::Type dimension, const Vector2& maximumSize)
-{
- switch(GetResizePolicy(dimension))
- {
- case ResizePolicy::USE_NATURAL_SIZE:
- {
- return GetNaturalSize(dimension);
- }
-
- case ResizePolicy::FIXED:
- {
- return GetDimensionValue(GetPreferredSize(), dimension);
- }
-
- case ResizePolicy::USE_ASSIGNED_SIZE:
- {
- return GetDimensionValue(maximumSize, dimension);
- }
-
- case ResizePolicy::FILL_TO_PARENT:
- case ResizePolicy::SIZE_RELATIVE_TO_PARENT:
- case ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT:
- {
- return NegotiateFromParent(dimension);
- }
-
- case ResizePolicy::FIT_TO_CHILDREN:
- {
- return NegotiateFromChildren(dimension);
- }
-
- case ResizePolicy::DIMENSION_DEPENDENCY:
- {
- const Dimension::Type dimensionDependency = GetDimensionDependency(dimension);
-
- // Custom rules
- if(dimension == Dimension::WIDTH && dimensionDependency == Dimension::HEIGHT)
- {
- return GetWidthForHeight(GetNegotiatedDimension(Dimension::HEIGHT));
- }
-
- if(dimension == Dimension::HEIGHT && dimensionDependency == Dimension::WIDTH)
- {
- return GetHeightForWidth(GetNegotiatedDimension(Dimension::WIDTH));
- }
-
- break;
- }
-
- default:
- {
- break;
- }
- }
-
- return 0.0f; // Default
-}
-
-Vector2 Actor::ApplySizeSetPolicy(const Vector2& size)
-{
- return mRelayoutData->ApplySizeSetPolicy(*this, size);
-}
-
-void Actor::SetNegotiatedSize(RelayoutContainer& container)
-{
- // Do the set actor size
- Vector2 negotiatedSize(GetLatestSize(Dimension::WIDTH), GetLatestSize(Dimension::HEIGHT));
-
- // Adjust for size set policy
- negotiatedSize = ApplySizeSetPolicy(negotiatedSize);
-
- // Lock the flag to stop recursive relayouts on set size
- mRelayoutData->insideRelayout = true;
- SetSize(negotiatedSize);
- mRelayoutData->insideRelayout = false;
-
- // Clear flags for all dimensions
- SetLayoutDirty(false);
-
- // Give deriving classes a chance to respond
- OnRelayout(negotiatedSize, container);
-
- if(!mOnRelayoutSignal.Empty())
- {
- Dali::Actor handle(this);
- mOnRelayoutSignal.Emit(handle);
- }