diff options
Diffstat (limited to 'dw')
-rw-r--r-- | dw/alignedtablecell.cc | 5 | ||||
-rw-r--r-- | dw/alignedtablecell.hh | 2 | ||||
-rw-r--r-- | dw/bullet.cc | 5 | ||||
-rw-r--r-- | dw/image.cc | 3 | ||||
-rw-r--r-- | dw/listitem.cc | 5 | ||||
-rw-r--r-- | dw/listitem.hh | 2 | ||||
-rw-r--r-- | dw/ruler.cc | 2 | ||||
-rw-r--r-- | dw/simpletablecell.cc | 5 | ||||
-rw-r--r-- | dw/simpletablecell.hh | 2 | ||||
-rw-r--r-- | dw/table.cc | 40 | ||||
-rw-r--r-- | dw/table.hh | 4 | ||||
-rw-r--r-- | dw/tablecell.hh | 2 | ||||
-rw-r--r-- | dw/textblock.cc | 23 | ||||
-rw-r--r-- | dw/textblock.hh | 18 | ||||
-rw-r--r-- | dw/textblock_linebreaking.cc | 24 | ||||
-rw-r--r-- | dw/types.hh | 1 | ||||
-rw-r--r-- | dw/ui.cc | 2 | ||||
-rw-r--r-- | dw/widget.cc | 9 |
18 files changed, 121 insertions, 33 deletions
diff --git a/dw/alignedtablecell.cc b/dw/alignedtablecell.cc index 633c4e68..3dbb73a2 100644 --- a/dw/alignedtablecell.cc +++ b/dw/alignedtablecell.cc @@ -58,6 +58,11 @@ bool AlignedTableCell::isBlockLevel () return tablecell::isBlockLevel (); } +bool AlignedTableCell::mustBeWidenedToAvailWidth () +{ + return tablecell::mustBeWidenedToAvailWidth (); +} + int AlignedTableCell::getAvailWidthOfChild (Widget *child, bool forceValue) { DBG_OBJ_ENTER ("resize", 0, "AlignedTableCell/getAvailWidthOfChild", diff --git a/dw/alignedtablecell.hh b/dw/alignedtablecell.hh index 5ea606d7..57b92d5f 100644 --- a/dw/alignedtablecell.hh +++ b/dw/alignedtablecell.hh @@ -37,6 +37,8 @@ public: int applyPerHeight (int containerHeight, core::style::Length perHeight); bool isBlockLevel (); + + bool mustBeWidenedToAvailWidth (); }; } // namespace dw diff --git a/dw/bullet.cc b/dw/bullet.cc index acaf81cc..40c197e6 100644 --- a/dw/bullet.cc +++ b/dw/bullet.cc @@ -44,10 +44,9 @@ void Bullet::sizeRequestImpl (core::Requisition *requisition) void Bullet::getExtremesImpl (core::Extremes *extremes) { - extremes->minWidth = extremes->maxWidth = + extremes->minWidth = extremes->maxWidth = extremes->adjustmentWidth = + extremes->minWidthIntrinsic = extremes->maxWidthIntrinsic = lout::misc::max (getStyle()->font->xHeight * 4 / 5, 1); - extremes->minWidthIntrinsic = extremes->minWidth; - extremes->maxWidthIntrinsic = extremes->maxWidth; } void Bullet::containerSizeChangedForChildren () diff --git a/dw/image.cc b/dw/image.cc index f6bf6434..b9a1abeb 100644 --- a/dw/image.cc +++ b/dw/image.cc @@ -265,6 +265,9 @@ void Image::getExtremesImpl (core::Extremes *extremes) extremes->maxWidthIntrinsic = extremes->maxWidth; correctExtremes (extremes); + + extremes->adjustmentWidth = + misc::min (extremes->minWidthIntrinsic, extremes->minWidth); } void Image::sizeAllocateImpl (core::Allocation *allocation) diff --git a/dw/listitem.cc b/dw/listitem.cc index 65293d8d..8bd2a93a 100644 --- a/dw/listitem.cc +++ b/dw/listitem.cc @@ -40,6 +40,11 @@ ListItem::~ListItem() DBG_OBJ_DELETE (); } +bool ListItem::mustBeWidenedToAvailWidth () +{ + return true; +} + void ListItem::initWithWidget (core::Widget *widget, core::style::Style *style) { diff --git a/dw/listitem.hh b/dw/listitem.hh index 2e303d5d..20fa6e9d 100644 --- a/dw/listitem.hh +++ b/dw/listitem.hh @@ -18,6 +18,8 @@ public: ListItem(ListItem *ref, bool limitTextWidth); ~ListItem(); + bool mustBeWidenedToAvailWidth (); + void initWithWidget (core::Widget *widget, core::style::Style *style); void initWithText (const char *text, core::style::Style *style); }; diff --git a/dw/ruler.cc b/dw/ruler.cc index 3fdbfb6d..73651257 100644 --- a/dw/ruler.cc +++ b/dw/ruler.cc @@ -44,6 +44,8 @@ void Ruler::getExtremesImpl (core::Extremes *extremes) extremes->minWidthIntrinsic = extremes->minWidth; extremes->maxWidthIntrinsic = extremes->maxWidth; correctExtremes (extremes); + extremes->adjustmentWidth = + lout::misc::min (extremes->minWidthIntrinsic, extremes->minWidth); } bool Ruler::isBlockLevel () diff --git a/dw/simpletablecell.cc b/dw/simpletablecell.cc index 02f92db6..a5851680 100644 --- a/dw/simpletablecell.cc +++ b/dw/simpletablecell.cc @@ -50,6 +50,11 @@ bool SimpleTableCell::isBlockLevel () return tablecell::isBlockLevel (); } +bool SimpleTableCell::mustBeWidenedToAvailWidth () +{ + return tablecell::mustBeWidenedToAvailWidth (); +} + int SimpleTableCell::getAvailWidthOfChild (Widget *child, bool forceValue) { DBG_OBJ_ENTER ("resize", 0, "SimpleTableCell/getAvailWidthOfChild", diff --git a/dw/simpletablecell.hh b/dw/simpletablecell.hh index 4c18b454..6eef5096 100644 --- a/dw/simpletablecell.hh +++ b/dw/simpletablecell.hh @@ -28,6 +28,8 @@ public: int applyPerHeight (int containerHeight, core::style::Length perHeight); bool isBlockLevel (); + + bool mustBeWidenedToAvailWidth (); }; } // namespace dw diff --git a/dw/table.cc b/dw/table.cc index afb308ee..3a7a0a41 100644 --- a/dw/table.cc +++ b/dw/table.cc @@ -133,12 +133,13 @@ void Table::getExtremesImpl (core::Extremes *extremes) if (numCols == 0) extremes->minWidth = extremes->minWidthIntrinsic = extremes->maxWidth = - extremes->maxWidthIntrinsic = boxDiffWidth (); + extremes->maxWidthIntrinsic = extremes->adjustmentWidth = + boxDiffWidth (); else { forceCalcColumnExtremes (); extremes->minWidth = extremes->minWidthIntrinsic = extremes->maxWidth = - extremes->maxWidthIntrinsic = + extremes->maxWidthIntrinsic = extremes->adjustmentWidth = (numCols + 1) * getStyle()->hBorderSpacing + boxDiffWidth (); for (int col = 0; col < numCols; col++) { extremes->minWidth += colExtremes->getRef(col)->minWidth; @@ -147,6 +148,7 @@ void Table::getExtremesImpl (core::Extremes *extremes) extremes->maxWidth += colExtremes->getRef(col)->maxWidth; extremes->maxWidthIntrinsic += colExtremes->getRef(col)->maxWidthIntrinsic; + extremes->adjustmentWidth += colExtremes->getRef(col)->adjustmentWidth; } } @@ -1151,6 +1153,7 @@ void Table::forceCalcColumnExtremes () colExtremes->getRef(col)->minWidthIntrinsic = 0; colExtremes->getRef(col)->maxWidth = 0; colExtremes->getRef(col)->maxWidthIntrinsic = 0; + colExtremes->getRef(col)->adjustmentWidth = 0; for (int row = 0; row < numRows; row++) { DBG_OBJ_MSGF ("resize", 1, "row %d", row); @@ -1182,6 +1185,10 @@ void Table::forceCalcColumnExtremes () colExtremes->getRef(col)->maxWidth, cellExtremes.maxWidth); + colExtremes->getRef(col)->adjustmentWidth = + misc::max (colExtremes->getRef(col)->adjustmentWidth, + cellExtremes.adjustmentWidth); + core::style::Length childWidth = children->get(n)->cell.widget->getStyle()->width; if (childWidth != core::style::LENGTH_AUTO) { @@ -1220,9 +1227,10 @@ void Table::forceCalcColumnExtremes () core::Extremes cellExtremes; children->get(n)->cell.widget->getExtremes (&cellExtremes); - calcExtremesSpanMulteCols (col, cs, &cellExtremes, MIN, MAX, NULL); - calcExtremesSpanMulteCols (col, cs, &cellExtremes, MIN_INTR, MAX_INTR, + calcExtremesSpanMultiCols (col, cs, &cellExtremes, MIN, MAX, NULL); + calcExtremesSpanMultiCols (col, cs, &cellExtremes, MIN_INTR, MAX_INTR, NULL); + calcAdjustmentWidthSpanMultiCols (col, cs, &cellExtremes); core::style::Length childWidth = children->get(n)->cell.widget->getStyle()->width; @@ -1278,7 +1286,7 @@ void Table::forceCalcColumnExtremes () DBG_OBJ_LEAVE (); } -void Table::calcExtremesSpanMulteCols (int col, int cs, +void Table::calcExtremesSpanMultiCols (int col, int cs, core::Extremes *cellExtremes, ExtrMod minExtrMod, ExtrMod maxExtrMod, void *extrData) @@ -1329,6 +1337,28 @@ void Table::calcExtremesSpanMulteCols (int col, int cs, DBG_OBJ_LEAVE (); } +void Table::calcAdjustmentWidthSpanMultiCols (int col, int cs, + core::Extremes *cellExtremes) +{ + DBG_OBJ_ENTER ("resize", 0, "calcAdjustmentWidthSpanMultiCols", + "%d, %d, ...", col, cs); + + int sumAdjustmentWidth = 0; + for (int j = 0; j < cs; j++) + sumAdjustmentWidth += colExtremes->getRef(col + j)->adjustmentWidth; + + if (cellExtremes->adjustmentWidth > sumAdjustmentWidth) { + misc::SimpleVector<int> newAdjustmentWidth; + apportion2 (cellExtremes->adjustmentWidth, col, col + cs - 1, MIN, MAX, + NULL, &newAdjustmentWidth, 0); + for (int j = 0; j < cs; j++) + colExtremes->getRef(col + j)->adjustmentWidth = + newAdjustmentWidth.get (j); + } + + DBG_OBJ_LEAVE (); +} + /** * \brief Actual apportionment function. */ diff --git a/dw/table.hh b/dw/table.hh index 1c581a5d..9ea7056f 100644 --- a/dw/table.hh +++ b/dw/table.hh @@ -441,10 +441,12 @@ private: void _unused_calcColumnExtremes (); void forceCalcColumnExtremes (); - void calcExtremesSpanMulteCols (int col, int cs, + void calcExtremesSpanMultiCols (int col, int cs, core::Extremes *cellExtremes, ExtrMod minExtrMod, ExtrMod maxExtrMod, void *extrData); + void calcAdjustmentWidthSpanMultiCols (int col, int cs, + core::Extremes *cellExtremes); void apportion2 (int totalWidth, int firstCol, int lastCol, ExtrMod minExtrMod, ExtrMod maxExtrMod, void *extrData, diff --git a/dw/tablecell.hh b/dw/tablecell.hh index 2e26c8e8..95c2e78e 100644 --- a/dw/tablecell.hh +++ b/dw/tablecell.hh @@ -7,6 +7,8 @@ namespace dw { namespace tablecell { +inline bool mustBeWidenedToAvailWidth () { return true; } + bool getAdjustMinWidth (); bool isBlockLevel (); diff --git a/dw/textblock.cc b/dw/textblock.cc index 9b4d5380..e3873b11 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -465,7 +465,8 @@ void Textblock::getWordExtremes (Word *word, core::Extremes *extremes) word->content.widget->getExtremes (extremes); else extremes->minWidth = extremes->minWidthIntrinsic = extremes->maxWidth = - extremes->maxWidthIntrinsic = word->size.width; + extremes->maxWidthIntrinsic = extremes->adjustmentWidth = + word->size.width; } void Textblock::getExtremesImpl (core::Extremes *extremes) @@ -493,12 +494,14 @@ void Textblock::getExtremesImpl (core::Extremes *extremes) extremes->minWidthIntrinsic = 0; extremes->maxWidth = 0; extremes->maxWidthIntrinsic = 0; + extremes->adjustmentWidth = 0; } else { Paragraph *lastPar = paragraphs->getLastRef (); extremes->minWidth = lastPar->maxParMin; extremes->minWidthIntrinsic = lastPar->maxParMinIntrinsic; extremes->maxWidth = lastPar->maxParMax; extremes->maxWidthIntrinsic = lastPar->maxParMaxIntrinsic; + extremes->adjustmentWidth = lastPar->maxParAdjustmentWidth; DBG_OBJ_MSGF ("resize", 1, "paragraphs[%d]->maxParMin = %d (%d)", paragraphs->size () - 1, lastPar->maxParMin, @@ -517,6 +520,7 @@ void Textblock::getExtremesImpl (core::Extremes *extremes) extremes->minWidthIntrinsic += diff; extremes->maxWidth += diff; extremes->maxWidthIntrinsic += diff; + extremes->adjustmentWidth += diff; DBG_OBJ_MSGF ("resize", 0, "after adding diff: %d (%d) / %d (%d)", extremes->minWidth, extremes->minWidthIntrinsic, @@ -543,6 +547,8 @@ void Textblock::getExtremesImpl (core::Extremes *extremes) extremes->maxWidth = misc::max (extremes->maxWidth, oofMaxWidth); extremes->maxWidthIntrinsic = misc::max (extremes->maxWidthIntrinsic, oofMinWidth); + extremes->adjustmentWidth = + misc::max (extremes->adjustmentWidth, oofMinWidth); } DBG_OBJ_MSGF ("resize", 0, @@ -2938,6 +2944,21 @@ void Textblock::setVerticalOffset (int verticalOffset) DBG_OBJ_LEAVE (); } +bool Textblock::mustBeWidenedToAvailWidth () +{ + DBG_OBJ_ENTER0 ("resize", 0, "mustBeWidenedToAvailWidth"); + bool toplevel = getParent () == NULL, + block = getStyle()->display == core::style::DISPLAY_BLOCK, + vloat = getStyle()->vloat != core::style::FLOAT_NONE, + result = toplevel || (block && !vloat); + DBG_OBJ_MSGF ("resize", 0, + "=> %s (toplevel: %s, block: %s, float: %s)", + result ? "true" : "false", toplevel ? "true" : "false", + block ? "true" : "false", vloat ? "true" : "false"); + DBG_OBJ_LEAVE (); + return result; +} + /** * Called by dw::OutOfFlowMgr when the border has changed due to a * float (or some floats). diff --git a/dw/textblock.hh b/dw/textblock.hh index 6c80c474..cb040c0a 100644 --- a/dw/textblock.hh +++ b/dw/textblock.hh @@ -351,6 +351,7 @@ protected: hyphen width etc.) since the last possible break within this paragraph. */ int parMinIntrinsic; + int parAdjustmentWidth; int parMax; /* The sum of all word maxima in this paragraph (plus spaces, hyphen width etc.). */ @@ -359,6 +360,7 @@ protected: int maxParMin; /* Maximum of all paragraph minima (value of "parMin"), including this paragraph. */ int maxParMinIntrinsic; + int maxParAdjustmentWidth; int maxParMax; /* Maximum of all paragraph maxima (value of "parMax""), including this paragraph. */ int maxParMaxIntrinsic; @@ -876,21 +878,7 @@ public: void changeWordStyle (int from, int to, core::style::Style *style, bool includeFirstSpace, bool includeLastSpace); - inline bool mustBeWidenedToAvailWidth () { - DBG_OBJ_ENTER0 ("resize", 0, "mustBeWidenedToAvailWidth"); - bool toplevel = getParent () == NULL, - block = getStyle()->display == core::style::DISPLAY_BLOCK, - listitem = getStyle()->display == core::style::DISPLAY_LIST_ITEM, - vloat = getStyle()->vloat != core::style::FLOAT_NONE, - result = toplevel || ((block || listitem) && !vloat); - DBG_OBJ_MSGF ("resize", 0, - "=> %s (toplevel: %s, block: %s, listitem: %s, float: %s)", - result ? "true" : "false", toplevel ? "true" : "false", - block ? "true" : "false", listitem ? "true" : "false", - vloat ? "true" : "false"); - DBG_OBJ_LEAVE (); - return result; - } + virtual bool mustBeWidenedToAvailWidth (); void borderChanged (int y, core::Widget *vloat); void clearPositionChanged (); diff --git a/dw/textblock_linebreaking.cc b/dw/textblock_linebreaking.cc index ee91d596..cb5bad75 100644 --- a/dw/textblock_linebreaking.cc +++ b/dw/textblock_linebreaking.cc @@ -1238,8 +1238,8 @@ void Textblock::handleWordExtremes (int wordIndex) Paragraph *par = paragraphs->getLastRef(); par->firstWord = par->lastWord = wordIndex; - par->parMin = par->parMinIntrinsic = par->parMax = par->parMaxIntrinsic - = 0; + par->parMin = par->parMinIntrinsic = par->parMax = par->parMaxIntrinsic = + par->parAdjustmentWidth = 0; if (prevPar) { par->maxParMin = prevPar->maxParMin; @@ -1280,9 +1280,13 @@ void Textblock::handleWordExtremes (int wordIndex) lastPar->parMin += wordExtremes.minWidth + word->hyphenWidth + corrDiffMin; lastPar->parMinIntrinsic += wordExtremes.minWidthIntrinsic + word->hyphenWidth + corrDiffMin; + lastPar->parAdjustmentWidth += + wordExtremes.adjustmentWidth + word->hyphenWidth + corrDiffMin; lastPar->maxParMin = misc::max (lastPar->maxParMin, lastPar->parMin); lastPar->maxParMinIntrinsic = misc::max (lastPar->maxParMinIntrinsic, lastPar->parMinIntrinsic); + lastPar->maxParAdjustmentWidth = + misc::max (lastPar->maxParAdjustmentWidth, lastPar->parAdjustmentWidth); DBG_OBJ_ARRATTRSET_NUM ("paragraphs", paragraphs->size() - 1, "parMin", lastPar->parMin); @@ -1292,15 +1296,24 @@ void Textblock::handleWordExtremes (int wordIndex) lastPar->maxParMin); DBG_OBJ_ARRATTRSET_NUM ("paragraphs", paragraphs->size() - 1, "maxParMinIntrinsic", lastPar->maxParMinIntrinsic); + DBG_OBJ_ARRATTRSET_NUM ("paragraphs", paragraphs->size() - 1, + "parAdjustmentWidth", lastPar->parAdjustmentWidth); + DBG_OBJ_ARRATTRSET_NUM ("paragraphs", paragraphs->size() - 1, + "maxParAdjustmentWidth", + lastPar->maxParAdjustmentWidth); if (word->badnessAndPenalty.lineCanBeBroken (1) && (word->flags & Word::UNBREAKABLE_FOR_MIN_WIDTH) == 0) { - lastPar->parMin = lastPar->parMinIntrinsic = 0; + lastPar->parMin = lastPar->parMinIntrinsic = lastPar->parAdjustmentWidth + = 0; DBG_OBJ_ARRATTRSET_NUM ("paragraphs", paragraphs->size() - 1, "parMin", lastPar->parMin); DBG_OBJ_ARRATTRSET_NUM ("paragraphs", paragraphs->size() - 1, "parMinIntrinsic", lastPar->parMinIntrinsic); + DBG_OBJ_ARRATTRSET_NUM ("paragraphs", paragraphs->size() - 1, + "parAdjustmentWidth", + lastPar->parAdjustmentWidth); } // Maximum: between two *necessary* breaks. @@ -1333,8 +1346,9 @@ void Textblock::correctLastWordExtremes () Word *word = words->getLastRef (); if (word->badnessAndPenalty.lineCanBeBroken (1) && (word->flags & Word::UNBREAKABLE_FOR_MIN_WIDTH) == 0) { - paragraphs->getLastRef()->parMin = - paragraphs->getLastRef()->parMinIntrinsic = 0; + Paragraph *lastPar = paragraphs->getLastRef(); + lastPar->parMin = lastPar->parMinIntrinsic = + lastPar->parAdjustmentWidth = 0; PRINTF (" => corrected; parMin = %d\n", paragraphs->getLastRef()->parMin); } diff --git a/dw/types.hh b/dw/types.hh index 36d6caa1..b6b4ca0b 100644 --- a/dw/types.hh +++ b/dw/types.hh @@ -182,6 +182,7 @@ struct Extremes int maxWidth; int minWidthIntrinsic; int maxWidthIntrinsic; + int adjustmentWidth; }; struct Content @@ -57,6 +57,8 @@ void Embed::getExtremesImpl (Extremes *extremes) { resource->getExtremes (extremes); correctExtremes (extremes); + extremes->adjustmentWidth = + misc::max (extremes->minWidthIntrinsic, extremes->minWidth); } void Embed::sizeAllocateImpl (Allocation *allocation) diff --git a/dw/widget.cc b/dw/widget.cc index 7b0d4c99..ac46daf5 100644 --- a/dw/widget.cc +++ b/dw/widget.cc @@ -544,10 +544,12 @@ int Widget::getMinWidth (Extremes *extremes, bool useCorrected, bool forceValue) // be called. We ignore the minimal width then. if (extremes) { if (useCorrected) - minWidth = - misc::max (extremes->minWidth, extremes->minWidthIntrinsic); + minWidth = extremes->adjustmentWidth; else - minWidth = extremes->minWidthIntrinsic; + // UseCorrected is set to false when called for the + // correction of extemes. This is not supported anymore, + // so we return 0. TODO: Should be cleaned up again. + minWidth = 0; } else minWidth = 0; } else @@ -932,6 +934,7 @@ void Widget::getExtremes (Extremes *extremes) DBG_OBJ_SET_NUM ("extremes.maxWidth", extremes->maxWidth); DBG_OBJ_SET_NUM ("extremes.maxWidthIntrinsic", extremes->maxWidthIntrinsic); + DBG_OBJ_SET_NUM ("extremes.adjustmentWidth", extremes->adjustmentWidth); } else *extremes = this->extremes; |