From 557f681c6e435dbe1452c3cf2ff6fd16d65cb1e0 Mon Sep 17 00:00:00 2001 From: Sebastian Geerken Date: Sat, 23 Apr 2016 17:56:58 +0200 Subject: GROWS: Fix rounding errors. --- dw/widget.cc | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'dw/widget.cc') diff --git a/dw/widget.cc b/dw/widget.cc index 3360a799..324c1687 100644 --- a/dw/widget.cc +++ b/dw/widget.cc @@ -758,13 +758,18 @@ void Widget::correctRequisition (Requisition *requisition, // For layout->viewportHeight, see comment in getAvailHeight(). int height = calcHeight (getStyle()->height, false, layout->viewportHeight, NULL, false); + adjustHeight (&height, allowDecreaseHeight, requisition->ascent, + requisition->descent); + int minHeight = calcHeight (getStyle()->minHeight, false, layout->viewportHeight, NULL, false); - if (!allowDecreaseHeight && - minHeight < requisition->ascent + requisition->descent) - minHeight = requisition->ascent + requisition->descent; + adjustHeight (&minHeight, allowDecreaseHeight, requisition->ascent, + requisition->descent); + int maxHeight = calcHeight (getStyle()->maxHeight, false, layout->viewportHeight, NULL, false); + adjustHeight (&maxHeight, allowDecreaseHeight, requisition->ascent, + requisition->descent); // TODO Perhaps split first, then add box ascent and descent. if (height != -1) @@ -972,6 +977,13 @@ int Widget::calcHeight (style::Length cssValue, bool usePercentage, return height; } +void Widget::adjustHeight (int *height, bool allowDecreaseHeight, int ascent, + int descent) +{ + if (!allowDecreaseHeight && *height != -1 && *height < ascent + descent) + *height = ascent + descent; +} + /** * \brief Wrapper for Widget::getExtremesImpl(). */ @@ -1805,13 +1817,18 @@ void Widget::correctReqHeightOfChild (Widget *child, Requisition *requisition, int height = child->calcHeight (child->getStyle()->height, false, -1, this, false); + adjustHeight (&height, allowDecreaseHeight, requisition->ascent, + requisition->descent); + int minHeight = child->calcHeight (child->getStyle()->minHeight, false, -1, this, false); - if (!allowDecreaseHeight && - minHeight < requisition->ascent + requisition->descent) - minHeight = requisition->ascent + requisition->descent; + adjustHeight (&minHeight, allowDecreaseHeight, requisition->ascent, + requisition->descent); + int maxHeight = child->calcHeight (child->getStyle()->maxHeight, false, -1, this, false); + adjustHeight (&maxHeight, allowDecreaseHeight, requisition->ascent, + requisition->descent); // TODO Perhaps split first, then add box ascent and descent. if (height != -1) -- cgit v1.2.3