diff --git a/src/eepp/ui/uicontrol.cpp b/src/eepp/ui/uicontrol.cpp index d144426f4..88e42b1e8 100644 --- a/src/eepp/ui/uicontrol.cpp +++ b/src/eepp/ui/uicontrol.cpp @@ -158,12 +158,14 @@ void UIControl::setInternalSize( const Sizei& size ) { mSize = size; mRealSize = Sizei( size.x * PixelDensity::getPixelDensity(), size.y * PixelDensity::getPixelDensity() ); updateCenter(); + sendCommonEvent( UIEvent::EventOnSizeChange ); } void UIControl::setInternalPixelsSize( const Sizei& size ) { mSize = PixelDensity::pxToDpI( size ); mRealSize = size; updateCenter(); + sendCommonEvent( UIEvent::EventOnSizeChange ); } UIControl * UIControl::setSize( const Sizei& Size ) { @@ -696,7 +698,6 @@ void UIControl::onPositionChange() { } void UIControl::onSizeChange() { - sendCommonEvent( UIEvent::EventOnSizeChange ); } Rectf UIControl::getRectf() { diff --git a/src/eepp/ui/uigridlayout.cpp b/src/eepp/ui/uigridlayout.cpp index 2a562e5d9..6dc7a85f2 100644 --- a/src/eepp/ui/uigridlayout.cpp +++ b/src/eepp/ui/uigridlayout.cpp @@ -129,12 +129,10 @@ void UIGridLayout::pack() { if ( getLayoutWidthRules() == MATCH_PARENT ) { setInternalWidth( getParent()->getSize().getWidth() - mLayoutMargin.Left - mLayoutMargin.Right ); - sendCommonEvent( UIEvent::EventOnSizeChange ); } if ( getLayoutHeightRules() == MATCH_PARENT ) { setInternalHeight( getParent()->getSize().getHeight() - mLayoutMargin.Top - mLayoutMargin.Bottom ); - sendCommonEvent( UIEvent::EventOnSizeChange ); } UIControl * ChildLoop = mChild; @@ -145,9 +143,11 @@ void UIGridLayout::pack() { if ( getHorizontalAlign() == UI_HALIGN_RIGHT ) pos.x = mSize.getWidth() - mPadding.Right; + bool usedLastRow = true; while ( NULL != ChildLoop ) { if ( ChildLoop->isWidget() && ChildLoop->isVisible() ) { UIWidget * widget = static_cast( ChildLoop ); + usedLastRow = true; if ( widget->getLayoutWeight() != 0.f ) targetSize.x = widget->getLayoutWeight() * ( mSize.getWidth() - mPadding.Left - mPadding.Right ); @@ -161,6 +161,7 @@ void UIGridLayout::pack() { pos.x = getHorizontalAlign() == UI_HALIGN_RIGHT ? mSize.getWidth() - mPadding.Right : mPadding.Left; pos.y += targetSize.getHeight() + mSpan.y; + usedLastRow = false; } else { pos.x += getHorizontalAlign() == UI_HALIGN_RIGHT ? -mSpan.x : mSpan.x; } @@ -170,8 +171,7 @@ void UIGridLayout::pack() { } if ( getLayoutHeightRules() == WRAP_CONTENT ) { - setInternalHeight( pos.y + targetSize.getHeight() ); - sendCommonEvent( UIEvent::EventOnSizeChange ); + setInternalHeight( pos.y + ( usedLastRow ? targetSize.getHeight() : 0 ) ); } } diff --git a/src/eepp/ui/uilinearlayout.cpp b/src/eepp/ui/uilinearlayout.cpp index d6ff0e717..51fb47151 100644 --- a/src/eepp/ui/uilinearlayout.cpp +++ b/src/eepp/ui/uilinearlayout.cpp @@ -70,12 +70,10 @@ void UILinearLayout::pack() { void UILinearLayout::packVertical() { if ( getLayoutWidthRules() == MATCH_PARENT && 0 == mLayoutWeight ) { setInternalWidth( getParent()->getSize().getWidth() - mLayoutMargin.Left - mLayoutMargin.Right ); - sendCommonEvent( UIEvent::EventOnSizeChange ); } if ( getLayoutHeightRules() == MATCH_PARENT ) { setInternalHeight( getParent()->getSize().getHeight() - mLayoutMargin.Top - mLayoutMargin.Bottom ); - sendCommonEvent( UIEvent::EventOnSizeChange ); } UIControl * ChildLoop = mChild; @@ -161,7 +159,6 @@ void UILinearLayout::packVertical() { if ( getLayoutHeightRules() == WRAP_CONTENT ) { setInternalHeight( curY ); notifyLayoutAttrChangeParent(); - sendCommonEvent( UIEvent::EventOnSizeChange ); } else if ( getLayoutHeightRules() == MATCH_PARENT ) { setInternalHeight( getParent()->getSize().getHeight() - mLayoutMargin.Top - mLayoutMargin.Bottom ); } @@ -170,7 +167,6 @@ void UILinearLayout::packVertical() { setInternalWidth( maxX ); packVertical(); notifyLayoutAttrChangeParent(); - sendCommonEvent( UIEvent::EventOnSizeChange ); } alignAgainstLayout(); @@ -179,12 +175,10 @@ void UILinearLayout::packVertical() { void UILinearLayout::packHorizontal() { if ( getLayoutWidthRules() == MATCH_PARENT ) { setInternalWidth( getParent()->getSize().getWidth() - mLayoutMargin.Left - mLayoutMargin.Right ); - sendCommonEvent( UIEvent::EventOnSizeChange ); } if ( getLayoutHeightRules() == MATCH_PARENT && 0 == mLayoutWeight ) { setInternalHeight( getParent()->getSize().getHeight() - mLayoutMargin.Top - mLayoutMargin.Bottom ); - sendCommonEvent( UIEvent::EventOnSizeChange ); } UIControl * ChildLoop = mChild; @@ -270,17 +264,14 @@ void UILinearLayout::packHorizontal() { if ( getLayoutWidthRules() == WRAP_CONTENT ) { setInternalWidth( curX ); notifyLayoutAttrChangeParent(); - sendCommonEvent( UIEvent::EventOnSizeChange ); } else if ( getLayoutWidthRules() == MATCH_PARENT ) { setInternalWidth( getParent()->getSize().getWidth() - mLayoutMargin.Left - mLayoutMargin.Right ); - sendCommonEvent( UIEvent::EventOnSizeChange ); } if ( getLayoutHeightRules() == WRAP_CONTENT && mSize.getHeight() != maxY ) { setInternalHeight( maxY ); packHorizontal(); notifyLayoutAttrChangeParent(); - sendCommonEvent( UIEvent::EventOnSizeChange ); } alignAgainstLayout(); diff --git a/src/eepp/ui/uirelativelayout.cpp b/src/eepp/ui/uirelativelayout.cpp index 84ffc38cc..ac90d3dda 100644 --- a/src/eepp/ui/uirelativelayout.cpp +++ b/src/eepp/ui/uirelativelayout.cpp @@ -42,12 +42,10 @@ void UIRelativeLayout::fixChilds() { if ( getLayoutWidthRules() == MATCH_PARENT ) { setInternalWidth( getParent()->getSize().getWidth() - mLayoutMargin.Left - mLayoutMargin.Right ); - sendCommonEvent( UIEvent::EventOnSizeChange ); } if ( getLayoutHeightRules() == MATCH_PARENT ) { setInternalHeight( getParent()->getSize().getHeight() - mLayoutMargin.Top - mLayoutMargin.Bottom ); - sendCommonEvent( UIEvent::EventOnSizeChange ); } UIControl * child = mChild; diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index c7ad02a60..a2d652c4c 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -750,7 +750,6 @@ void EETest::createNewUI() { "" ); - /* UIManager::instance()->loadLayoutFromString( "" " " @@ -778,7 +777,6 @@ void EETest::createNewUI() { } } } - */ } void EETest::createMapEditor() {