Browse Source

Fix width/height GUI container computation to take into account paddings when adapWithToChildren = true

Popov72 5 years ago
parent
commit
c7b20b0fd9
2 changed files with 3 additions and 2 deletions
  1. 1 0
      dist/preview release/what's new.md
  2. 2 2
      gui/src/2D/controls/container.ts

+ 1 - 0
dist/preview release/what's new.md

@@ -237,6 +237,7 @@
 - Fixed wrong display when setting `DefaultRenderingPipeline.imageProcessingEnabled` to `false` ([Popov72](https://github.com/Popov72))
 - Fix crash when loading a .obj file with vertex colors ([Popov72](https://github.com/Popov72))
 - Fix skeleton viewer still visible when `isEnabled = false` ([Popov72](https://github.com/Popov72))
+- Fix width/height GUI container computation to take into account paddings when `adapWithToChildren = true` ([Popov72](https://github.com/Popov72))
 
 ## Breaking changes
 

+ 2 - 2
gui/src/2D/controls/container.ts

@@ -331,10 +331,10 @@ export class Container extends Control {
                     if (child._layout(this._measureForChildren, context)) {
 
                         if (this.adaptWidthToChildren && child._width.isPixel) {
-                            computedWidth = Math.max(computedWidth, child._currentMeasure.width);
+                            computedWidth = Math.max(computedWidth, child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels);
                         }
                         if (this.adaptHeightToChildren && child._height.isPixel) {
-                            computedHeight = Math.max(computedHeight, child._currentMeasure.height);
+                            computedHeight = Math.max(computedHeight, child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels);
                         }
                     }
                 }