-void Control::NegotiateSize( const Vector2& allocatedSize, ActorSizeContainer& container )
-{
- Vector2 size;
-
- if ( mImpl->mWidthPolicy == Toolkit::Control::Fixed )
- {
- if ( mImpl->mHeightPolicy == Toolkit::Control::Fixed )
- {
- // If a control says it has a fixed size, then use the size set by the application / control.
- Vector2 setSize( mImpl->mNaturalSize );
- if ( setSize != Vector2::ZERO )
- {
- size = setSize;
-
- // Policy is set to Fixed, so if the application / control has not set one of the dimensions,
- // then we should use the natural size of the control rather than the full allocation.
- if ( EqualsZero( size.width ) )
- {
- size.width = GetWidthForHeight( size.height );
- }
- else if ( EqualsZero( size.height ) )
- {
- size.height = GetHeightForWidth( size.width );
- }
- }
- else
- {
- // If that is not set then set the size to the control's natural size
- size = Vector2( GetNaturalSize() );
- }
- }
- else
- {
- // Width is fixed so if the application / control has set it, then use that.
- if ( !EqualsZero( mImpl->mNaturalSize.width ) )
- {
- size.width = mImpl->mNaturalSize.width;
- }
- else
- {
- // Otherwise, set the width to what has been allocated.
- size.width = allocatedSize.width;
- }
-
- // Height is flexible so ask control what the height should be for our width.
- size.height = GetHeightForWidth( size.width );
-
- // Ensure height is within our policy rules
- size.height = Calculate( mImpl->mHeightPolicy, GetMinimumSize().height, GetMaximumSize().height, size.height );
- }
- }
- else
- {
- if ( mImpl->mHeightPolicy == Toolkit::Control::Fixed )
- {
- // Height is fixed so if the application / control has set it, then use that.
- if ( !EqualsZero( mImpl->mNaturalSize.height ) )
- {
- size.height = mImpl->mNaturalSize.height;
- }
- else
- {
- // Otherwise, set the height to what has been allocated.
- size.height = allocatedSize.height;
- }
-
- // Width is flexible so ask control what the width should be for our height.
- size.width = GetWidthForHeight( size.height );
-
- // Ensure width is within our policy rules
- size.width = Calculate( mImpl->mWidthPolicy, mImpl->GetMinimumSize().width, mImpl->GetMaximumSize().width, size.width );
- }
- else
- {
- // Width and height are BOTH flexible.
- // Calculate the width and height using the policy rules.
- size.width = Calculate( mImpl->mWidthPolicy, mImpl->GetMinimumSize().width, mImpl->GetMaximumSize().width, allocatedSize.width );
- size.height = Calculate( mImpl->mHeightPolicy, mImpl->GetMinimumSize().height, mImpl->GetMaximumSize().height, allocatedSize.height );
- }
- }
-
- // If the width has not been set, then set to the allocated width.
- // Also if the width set is greater than the allocated, then set to allocated (no exceed support).
- if ( EqualsZero( size.width ) || ( size.width > allocatedSize.width ) )
- {
- size.width = allocatedSize.width;
- }
-
- // If the height has not been set, then set to the allocated height.
- // Also if the height set is greater than the allocated, then set to allocated (no exceed support).
- if ( EqualsZero( size.height ) || ( size.height > allocatedSize.height ) )
- {
- size.height = allocatedSize.height;
- }
-
- DALI_LOG_INFO( gLogFilter, Debug::Verbose,
- "%p: Natural: [%.2f, %.2f] Allocated: [%.2f, %.2f] Set: [%.2f, %.2f]\n",
- Self().GetObjectPtr(),
- GetNaturalSize().x, GetNaturalSize().y,
- allocatedSize.x, allocatedSize.y,
- size.x, size.y );
-
- // Avoids relayout again when OnSizeSet callback arrives as a function of us or deriving class calling SetSize()
- mImpl->mInsideRelayout = true;
- Self().SetSize( size );
- // Only relayout controls which requested to be relaid out.
- OnRelayout( size, container );
- mImpl->mInsideRelayout = false;
-}
-