diff options
author | Sebastian Geerken <devnull@localhost> | 2016-04-23 17:56:58 +0200 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2016-04-23 17:56:58 +0200 |
commit | 557f681c6e435dbe1452c3cf2ff6fd16d65cb1e0 (patch) | |
tree | f5b211b1ad3beb163f69f05bd8c4ab4874629988 | |
parent | 03a906f7726e7496239ddf74369e9d1f1a5f8c63 (diff) |
GROWS: Fix rounding errors.
-rw-r--r-- | dw/widget.cc | 29 | ||||
-rw-r--r-- | dw/widget.hh | 2 |
2 files changed, 25 insertions, 6 deletions
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) diff --git a/dw/widget.hh b/dw/widget.hh index a1d0f908..cf0ffe46 100644 --- a/dw/widget.hh +++ b/dw/widget.hh @@ -506,6 +506,8 @@ public: int limitMinWidth, bool forceValue, int *finalWidth); int calcHeight (style::Length cssValue, bool usePercentage, int refHeight, Widget *refWidget, bool forceValue); + static void adjustHeight (int *height, bool allowDecreaseHeight, int ascent, + int descent); virtual int applyPerWidth (int containerWidth, style::Length perWidth); virtual int applyPerHeight (int containerHeight, style::Length perHeight); |