diff options
author | Sebastian Geerken <devnull@localhost> | 2014-05-30 23:00:24 +0200 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2014-05-30 23:00:24 +0200 |
commit | 8e3d7ef937a06cfc6bca7a6c96b3f8302ca14278 (patch) | |
tree | 64182ada9d04fdca6caad0ea0dfc97386a21a031 | |
parent | d5500ed25bcb5140ec285bbd87dc1c04638e93ba (diff) |
GROWS: 'forceValue' removed; getAvail* and friends must now return a value.
-rw-r--r-- | dw/ruler.cc | 2 | ||||
-rw-r--r-- | dw/table.cc | 4 | ||||
-rw-r--r-- | dw/textblock.cc | 72 | ||||
-rw-r--r-- | dw/textblock.hh | 2 | ||||
-rw-r--r-- | dw/widget.cc | 13 | ||||
-rw-r--r-- | dw/widget.hh | 4 |
6 files changed, 39 insertions, 58 deletions
diff --git a/dw/ruler.cc b/dw/ruler.cc index c19b30c0..3599c32a 100644 --- a/dw/ruler.cc +++ b/dw/ruler.cc @@ -34,7 +34,7 @@ Ruler::Ruler () void Ruler::sizeRequestImpl (core::Requisition *requisition) { - requisition->width = lout::misc::max (getAvailWidth (true), + requisition->width = lout::misc::max (getAvailWidth (), getStyle()->boxDiffWidth ()); requisition->ascent = getStyle()->boxOffsetY (); requisition->descent = getStyle()->boxRestHeight (); diff --git a/dw/table.cc b/dw/table.cc index e40d43ca..d15100b7 100644 --- a/dw/table.cc +++ b/dw/table.cc @@ -477,13 +477,13 @@ void Table::forceCalcCellSizes () * rendering is implemented, to handle fixed positions etc., * as defined by CSS2.) */ - int availWidth = getAvailWidth (true); + int availWidth = getAvailWidth (); totalWidth = misc::min (core::style::multiplyWithPerLength (availWidth, getStyle()->width), availWidth); } else if (getStyle()->width == core::style::LENGTH_AUTO) { - totalWidth = getAvailWidth (true); + totalWidth = getAvailWidth (); forceTotalWidth = 0; } diff --git a/dw/textblock.cc b/dw/textblock.cc index aed4f2a9..f315dd4f 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -333,7 +333,7 @@ void Textblock::sizeRequestImpl (core::Requisition *requisition) DBG_OBJ_MSG ("resize", 0, "<b>sizeRequestImpl</b> ()"); DBG_OBJ_MSG_START (); - lineBreakWidth = getAvailWidth (true); + lineBreakWidth = getAvailWidth (); rewrap (); showMissingLines (); @@ -777,13 +777,12 @@ bool Textblock::isBlockLevel () return true; } -int Textblock::getAvailWidthOfChild (Widget *child, bool forceValue) +int Textblock::getAvailWidthOfChild (Widget *child) { // TODO Implement also for ListItem (subtract space for bullet). // TODO Correct by extremes? - DBG_OBJ_MSGF ("resize", 0, "<b>getAvailWidthOfChild</b> (%p, %s)", - child, forceValue ? "true" : "false"); + DBG_OBJ_MSGF ("resize", 0, "<b>getAvailWidthOfChild</b> (%p)", child); DBG_OBJ_MSG_START (); int width; @@ -792,21 +791,13 @@ int Textblock::getAvailWidthOfChild (Widget *child, bool forceValue) // TODO What does "width" exactly stand for? (Content or all?) width = core::style::absLengthVal (child->getStyle()->width); else { - int availWidth = getAvailWidth (forceValue); - if (availWidth == -1) { - assert (!forceValue); - width = -1; - } else { - int containerWidth = availWidth - boxDiffWidth (); - if (core::style::isPerLength (child->getStyle()->width)) - width = - core::style::multiplyWithPerLength (containerWidth, - child->getStyle()->width); - else - // A textblock will use the whole width (but not the whole - // height, see getAvailHeightOfChild()). - width = forceValue ? containerWidth : 1; - } + int containerWidth = getAvailWidth () - boxDiffWidth (); + if (core::style::isPerLength (child->getStyle()->width)) + width = core::style::multiplyWithPerLength (containerWidth, + child->getStyle()->width); + else + // A textblock will use the whole width, so this is a meaningful value. + width = containerWidth; } DBG_OBJ_MSGF ("resize", 1, "=> %d", width); @@ -829,18 +820,15 @@ int Textblock::getAvailHeightOfChild (Widget *child) // TODO What does "height" exactly stand for? (Content or all?) height = core::style::absLengthVal (child->getStyle()->height); else { - int availHeight = getAvailHeight (); - if (availHeight == -1) - height = -1; - else { - int containerHeight = availHeight - boxDiffHeight (); - if (core::style::isPerLength (child->getStyle()->height)) - height = - core::style::multiplyWithPerLength (containerHeight, - child->getStyle()->height); - else - height = -1; - } + int containerHeight = getAvailHeight () - boxDiffHeight (); + if (core::style::isPerLength (child->getStyle()->height)) + height = + core::style::multiplyWithPerLength (containerHeight, + child->getStyle()->height); + else + // Although a textblock will not use the whole height, we have to + // return some value here. + height = containerHeight; } DBG_OBJ_MSGF ("resize", 1, "=> %d", height); @@ -868,13 +856,10 @@ void Textblock::correctRequisitionOfChild (Widget *child, // TODO What does "width" exactly stand for? (Content or all?) requisition->width = core::style::absLengthVal (child->getStyle()->width); else if (core::style::isPerLength (child->getStyle()->width)) { - int availWidth = getAvailWidth (false); - if (availWidth != -1) { - int containerWidth = availWidth - boxDiffWidth (); - requisition->width = - core::style::multiplyWithPerLength (containerWidth, - child->getStyle()->width); - } + int containerWidth = getAvailWidth () - boxDiffWidth (); + requisition->width = + core::style::multiplyWithPerLength (containerWidth, + child->getStyle()->width); } if (core::style::isAbsLength (child->getStyle()->height)) @@ -882,13 +867,10 @@ void Textblock::correctRequisitionOfChild (Widget *child, splitHeightFun (core::style::absLengthVal (child->getStyle()->height), &requisition->ascent, &requisition->descent); else if (core::style::isPerLength (child->getStyle()->height)) { - int availHeight = getAvailHeight (); - if (availHeight != -1) { - int containerHeight = availHeight - boxDiffHeight (); - splitHeightFun (core::style::multiplyWithPerLength - (containerHeight, child->getStyle()->height), - &requisition->ascent, &requisition->descent); - } + int containerHeight = getAvailHeight () - boxDiffHeight (); + splitHeightFun (core::style::multiplyWithPerLength + (containerHeight, child->getStyle()->height), + &requisition->ascent, &requisition->descent); } DBG_OBJ_MSGF ("resize", 1, "=> %d * (%d + %d)", diff --git a/dw/textblock.hh b/dw/textblock.hh index dfedeeef..7426c4c5 100644 --- a/dw/textblock.hh +++ b/dw/textblock.hh @@ -749,7 +749,7 @@ protected: void markSizeChange (int ref); void markExtremesChange (int ref); - int getAvailWidthOfChild (Widget *child, bool forceValue); + int getAvailWidthOfChild (Widget *child); int getAvailHeightOfChild (Widget *child); void correctRequisitionOfChild (Widget *child, core::Requisition *requisition, diff --git a/dw/widget.cc b/dw/widget.cc index 79689e48..0e44dbdf 100644 --- a/dw/widget.cc +++ b/dw/widget.cc @@ -340,12 +340,11 @@ void Widget::sizeRequest (Requisition *requisition) DBG_OBJ_MSG_END (); } -int Widget::getAvailWidth (bool forceValue) +int Widget::getAvailWidth () { // TODO Correct by extremes? - DBG_OBJ_MSGF ("resize", 0, "<b>getAvailWidth</b> (%s)", - forceValue ? "true" : "false"); + DBG_OBJ_MSG ("resize", 0, "<b>getAvailWidth</b> ()"); DBG_OBJ_MSG_START (); int width; @@ -362,10 +361,10 @@ int Widget::getAvailWidth (bool forceValue) width = style::multiplyWithPerLength (viewportWidth, getStyle()->width); } else - width = forceValue ? viewportWidth : -1; + width = viewportWidth; } } else - width = container->getAvailWidthOfChild (this, forceValue); + width = container->getAvailWidthOfChild (this); DBG_OBJ_MSGF ("resize", 1, "=> %d", width); DBG_OBJ_MSG_END (); @@ -395,7 +394,7 @@ int Widget::getAvailHeight () height = style::multiplyWithPerLength (layout->viewportHeight, getStyle()->height); else - height = -1; + height = layout->viewportHeight; } else height = container->getAvailHeightOfChild (this); @@ -924,7 +923,7 @@ void Widget::markExtremesChange (int ref) { } -int Widget::getAvailWidthOfChild (Widget *child, bool forceValue) +int Widget::getAvailWidthOfChild (Widget *child) { // Must be implemented for possible containers. misc::assertNotReached (); diff --git a/dw/widget.hh b/dw/widget.hh index 09749012..3b2a01de 100644 --- a/dw/widget.hh +++ b/dw/widget.hh @@ -312,7 +312,7 @@ protected: */ virtual void markExtremesChange (int ref); - virtual int getAvailWidthOfChild (Widget *child, bool forceValue); + virtual int getAvailWidthOfChild (Widget *child); virtual int getAvailHeightOfChild (Widget *child); virtual void correctRequisitionOfChild (Widget *child, Requisition *requisition, @@ -432,7 +432,7 @@ public: void getExtremes (Extremes *extremes); void sizeAllocate (Allocation *allocation); - int getAvailWidth (bool forceValue); + int getAvailWidth (); int getAvailHeight (); void correctRequisition (Requisition *requisition, void (*splitHeightFun)(int height, int *ascent, |