- else
- {
- // Centre option text
- captionTextLabel.SetAnchorPoint( AnchorPoint::CENTER );
- captionTextLabel.SetParentOrigin( ParentOrigin::CENTER );
- pressedCaptionTextLabel.SetAnchorPoint( AnchorPoint::CENTER );
- pressedCaptionTextLabel.SetParentOrigin( ParentOrigin::CENTER );
- }
-
- // Calculate the size of the text.
- Vector3 textSize = captionTextLabel.GetNaturalSize();
- textSize.width = std::min( textSize.width, OPTION_MAX_WIDTH - 2.f * OPTION_MARGIN_WIDTH );
-
- // Set the size to the text. Text will be ellipsized if exceeds the max width.
- captionTextLabel.SetPreferredSize( textSize.GetVectorXY() );
- pressedCaptionTextLabel.SetPreferredSize( textSize.GetVectorXY() );
-
- // 4. Calculate the size of option.
-
- // The width is the max size of the text or the icon plus the margins clamped between the option min and max size.
- // The height is the whole popup height minus the ninepatch margins.
- const Vector2 optionSize( std::min( OPTION_MAX_WIDTH, std::max( OPTION_MIN_WIDTH, std::max( textSize.width, OPTION_ICON_SIZE.width ) + 2.f * OPTION_MARGIN_WIDTH ) ),
- DEFAULT_POPUP_MAX_SIZE.height - mNinePatchMargins.z - mNinePatchMargins.w );
-
- optionContainer.SetPreferredSize( optionSize );
- optionPressedContainer.SetPreferredSize( optionSize );