From 5bd0ea1d103295721c04f22e44d7ada6dd8d0b2c Mon Sep 17 00:00:00 2001 From: and3md Date: Wed, 16 Aug 2017 20:43:18 +0200 Subject: [PATCH] Ignore percent layout size if there is only one widget. --- src/dlangui/widgets/layouts.d | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/dlangui/widgets/layouts.d b/src/dlangui/widgets/layouts.d index 25aebe0e..b6bdb6ef 100644 --- a/src/dlangui/widgets/layouts.d +++ b/src/dlangui/widgets/layouts.d @@ -110,7 +110,6 @@ class LayoutItems { _maxSecondarySize = 0; _measureParentSize.x = parentWidth; _measureParentSize.y = parentHeight; - // bool bool hasPercentSizeWidget = false; size_t percenSizeWidgetIndex; // measure @@ -133,8 +132,8 @@ class LayoutItems { } if (hasPercentSizeWidget) { LayoutItem * item = &_list[percenSizeWidgetIndex]; - - item._measuredSize = to!int(_totalSize * ((1 / (1 - cast (double) (fromPercentSize(item._layoutSize, 100))/100)) - 1)); + if (_totalSize > 0) + item._measuredSize = to!int(_totalSize * ((1 / (1 - cast (double) (fromPercentSize(item._layoutSize, 100))/100)) - 1)); _totalSize += item._measuredSize; } return _orientation == Orientation.Horizontal ? Point(_totalSize, _maxSecondarySize) : Point(_maxSecondarySize, _totalSize);