- // Set the popup size
- Vector2 popupSize;
- popupSize.width = size.width - 2.f * ( POPUP_OUT_MARGIN_WIDTH + mPopupStyle->margin );
- popupSize.height = size.height - 2.f * ( POPUP_OUT_MARGIN_WIDTH + mPopupStyle->margin );
-
- // Update sizes of all popup's components.
-
- // Relayout background image.
- // Adjust background position and size relative to parent to cater to outer Border.
- // Some backgrounds are intended to over-spill. That is some content
- // should appear outside the Dialog on all sides i.e. Shadows, glow effects.
- const Vector4 outerBorder = mPopupStyle->backgroundOuterBorder;
-
- if( mBackgroundImage )
- {
- mBackgroundImage.SetSize(BackgroundSize(outerBorder, Vector3(size)));
- mBackgroundImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- mBackgroundImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
- mBackgroundImage.SetPosition( -outerBorder.x, -outerBorder.y, 0.0f );
- }
-
- if( mPopupBg && mButtonAreaImage )
- {
- // If there are no buttons, button background is also removed.
- if ( mButtons.size() == 0 )
- {
- mPopupBg.Remove( mButtonAreaImage );
- }
- else
- {
- mButtonAreaImage.SetSize( ButtonAreaSize(outerBorder, Vector3(size)) );
- mButtonAreaImage.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
- mButtonAreaImage.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
- mButtonAreaImage.SetY( -outerBorder.z - POPUP_OUT_MARGIN_HEIGHT );
-
- mPopupBg.Add( mButtonAreaImage );
- }
- }
-
- // Relayout title
- Vector3 positionOffset( 0.0f, mPopupStyle->margin + POPUP_OUT_MARGIN_WIDTH, CONTENT_DEPTH );
- // TODO
-
- // Relayout content
- if( mContent )
- {
- // If the content width is greater than popup width then scale it down/wrap text as needed
- Vector2 contentSize( RelayoutHelper::GetNaturalSize( mContent ) );
- if( contentSize.width > popupSize.width )
- {
- contentSize.width = popupSize.width;
- contentSize.height = RelayoutHelper::GetHeightForWidth( mContent, contentSize.width );
- }
-
- mContent.SetSize( contentSize );
- Relayout( mContent, contentSize, container );
-
- mContent.SetParentOrigin(ParentOrigin::TOP_CENTER);
- mContent.SetAnchorPoint(AnchorPoint::TOP_CENTER);
-
- mContent.SetPosition( positionOffset );
-
- positionOffset.y += contentSize.height + mPopupStyle->margin;
- }
-
- // Relayout Button Area
- if( mBottomBg )
- {
- mBottomBg.SetSize( popupSize.width, mPopupStyle->bottomSize.height );
-
- mBottomBg.SetParentOrigin(ParentOrigin::TOP_CENTER);
- mBottomBg.SetAnchorPoint(AnchorPoint::TOP_CENTER);
-
- mBottomBg.SetPosition( positionOffset );
- }