diff options
author | Sebastian Geerken <devnull@localhost> | 2015-09-22 20:23:27 +0200 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2015-09-22 20:23:27 +0200 |
commit | d11f25560a31a68d56a72abc6d888bc8cf2634b7 (patch) | |
tree | 84a1fed01439eecf6551fba096edf6d91d5312f9 /dw/textblock.cc | |
parent | af3aa61519ae6c37dd4984100697f7aa032403de (diff) |
SRDOP: OOFFloatsMgr now regards positions relative to container. (Code compiles, not more!)
Diffstat (limited to 'dw/textblock.cc')
-rw-r--r-- | dw/textblock.cc | 270 |
1 files changed, 135 insertions, 135 deletions
diff --git a/dw/textblock.cc b/dw/textblock.cc index 7dea2048..e66ab66a 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -2998,152 +2998,152 @@ bool Textblock::mustBeWidenedToAvailWidth () return result; } -/** - * Called by dw::OOFFloatsMgr when the border has changed due to a - * float (or some floats). - * - * "y", which given in widget coordinates, denotes the minimal - * position (when more than one float caused this), "vloat" the - * floating widget belonging to "y". - */ -void Textblock::borderChanged (int y, Widget *vloat) -{ - DBG_OBJ_ENTER ("resize", 0, "borderChanged", "%d, %p", y, vloat); - - int lineIndex = findLineIndex (y); - DBG_OBJ_MSGF ("resize", 1, "Line index: %d (of %d).", - lineIndex, lines->size ()); - - // Nothing to do at all, when lineIndex >= lines->size (), - // i. e. the change is below the bottom of this widget. - if (lineIndex < lines->size ()) { - int wrapLineIndex; - if (lineIndex < 0) - // Rewrap all. - wrapLineIndex = 0; - else - wrapLineIndex = lineIndex; - - int realWrapLineIndex = wrapLineIndex; - // The following two variables are only used for debugging: - int minWrapLineIndex = wrapLineIndex, maxWrapLineIndex = wrapLineIndex; - - if (vloat->getGenerator() == this && lines->size () > 0) { - bool found = false; - // Sometimes, the respective word is not yet part of a - // line. Nothing to do, but because of the assertion below - // (and also for performace reasons) this should be - // considered. TODO: Integrate this below. - for (int wordIndex = - lines->size() > 0 ? lines->getLastRef()->lastWord + 1 : 0; - !found && wordIndex < words->size(); wordIndex++) { - Word *word = words->getRef (wordIndex); - if (word->content.type == core::Content::WIDGET_OOF_REF && - word->content.widget == vloat) - found = true; - } - - // We search for the line of the float reference. There are - // two cases when this is not the line corresponsing to y: - // - // (1) When the float was moved down, due to collisions with - // other floats: in this case, the line number gets - // smaller (since the float reference is before). - // - // (2) In some cases, the line number may become larger, due - // to the per-line optimization of the words: initially, - // lines->size() - 1 is assigned, but it may happen that - // the float reference is put into another line. - // - // Only in the first case, a correction is neccessary, but a - // test for the second case is useful. (TODO: I've forgotten - // why a correction is neccessary.) - // - // Searched is done in the following order: - // - // - wrapLineIndex, - // - wrapLineIndex - 1, - // - wrapLineIndex + 1, - // - wrapLineIndex - 2, - // - wrapLineIndex + 2, - // - // etc. until either the float reference has been found or - // all lines have been searched (the latter triggers an - // abortion). - - bool exceedsBeginning = false, exceedsEnd = false; - for (int i = 0; !found; i++) { - bool exceeds; - int lineIndex2; - if (i % 2 == 0) { - // even: +0, +1, +2, ... - lineIndex2 = realWrapLineIndex + i / 2; - if (i > 0) - exceeds = exceedsEnd = lineIndex2 >= lines->size (); - else - exceeds = exceedsEnd = false; - } else { - // odd: -1, -2, ... - lineIndex2 = realWrapLineIndex - (i + 1) / 2; - exceeds = exceedsBeginning = lineIndex2 < 0; +void Textblock::borderChanged (int oofmIndex, int y, Widget *widgetOOF) +{ + DBG_OBJ_ENTER ("resize", 0, "borderChanged", "%s, %d, %p", + OOFM_NAME[oofmIndex], y, widgetOOF); + + // Calculate the widget coordinate of `y`. Since this method is only called + // for floats, `findSizeRequestReference` returning `false` means than + // `sizeRequest` has not been called yet, so queuing is not necessary. + int yRef; + if (findSizeRequestReference (oofmIndex, NULL, &yRef)) { + int yWidget = y - yRef; + int lineIndex = findLineIndex (yWidget); + DBG_OBJ_MSGF ("resize", 1, "Line index: %d (of %d).", + lineIndex, lines->size ()); + + // Nothing to do at all, when lineIndex >= lines->size (), + // i. e. the change is below the bottom of this widget. + if (lineIndex < lines->size ()) { + int wrapLineIndex; + if (lineIndex < 0) + // Rewrap all. + wrapLineIndex = 0; + else + wrapLineIndex = lineIndex; + + int realWrapLineIndex = wrapLineIndex; + // The following two variables are only used for debugging: + int minWrapLineIndex = wrapLineIndex, maxWrapLineIndex = wrapLineIndex; + + if (widgetOOF->getGenerator() == this && lines->size () > 0) { + bool found = false; + // Sometimes, the respective word is not yet part of a + // line. Nothing to do, but because of the assertion below + // (and also for performace reasons) this should be + // considered. TODO: Integrate this below. + for (int wordIndex = + lines->size() > 0 ? lines->getLastRef()->lastWord + 1 : 0; + !found && wordIndex < words->size(); wordIndex++) { + Word *word = words->getRef (wordIndex); + if (word->content.type == core::Content::WIDGET_OOF_REF && + word->content.widget == widgetOOF) + found = true; } - DBG_OBJ_MSGF ("resize", 2, - "lineIndex2 = %d (of %d), exceeds = %s, " - "exceedsBeginning = %s, exceedsEnd = %s", - lineIndex2, lines->size (), - exceeds ? "true" : "false", - exceedsBeginning ? "true" : "false", - exceedsEnd ? "true" : "false"); + // We search for the line of the float reference. There are + // two cases when this is not the line corresponsing to y: + // + // (1) When the float was moved down, due to collisions with + // other floats: in this case, the line number gets + // smaller (since the float reference is before). + // + // (2) In some cases, the line number may become larger, due + // to the per-line optimization of the words: initially, + // lines->size() - 1 is assigned, but it may happen that + // the float reference is put into another line. + // + // Only in the first case, a correction is neccessary, but a + // test for the second case is useful. (TODO: I've forgotten + // why a correction is neccessary.) + // + // Searched is done in the following order: + // + // - wrapLineIndex, + // - wrapLineIndex - 1, + // - wrapLineIndex + 1, + // - wrapLineIndex - 2, + // - wrapLineIndex + 2, + // + // etc. until either the float reference has been found or + // all lines have been searched (the latter triggers an + // abortion). + + bool exceedsBeginning = false, exceedsEnd = false; + for (int i = 0; !found; i++) { + bool exceeds; + int lineIndex2; + if (i % 2 == 0) { + // even: +0, +1, +2, ... + lineIndex2 = realWrapLineIndex + i / 2; + if (i > 0) + exceeds = exceedsEnd = lineIndex2 >= lines->size (); + else + exceeds = exceedsEnd = false; + } else { + // odd: -1, -2, ... + lineIndex2 = realWrapLineIndex - (i + 1) / 2; + exceeds = exceedsBeginning = lineIndex2 < 0; + } - if (exceedsBeginning && exceedsEnd) - break; + DBG_OBJ_MSGF ("resize", 2, + "lineIndex2 = %d (of %d), exceeds = %s, " + "exceedsBeginning = %s, exceedsEnd = %s", + lineIndex2, lines->size (), + exceeds ? "true" : "false", + exceedsBeginning ? "true" : "false", + exceedsEnd ? "true" : "false"); + + if (exceedsBeginning && exceedsEnd) + break; - if (!exceeds) { - Line *line = lines->getRef (lineIndex2); - for (int wordIndex = line->firstWord; - !found && wordIndex <= line->lastWord; wordIndex++) { - Word *word = words->getRef (wordIndex); - if (word->content.type == core::Content::WIDGET_OOF_REF && - word->content.widget == vloat) { - found = true; - // Correct only by smaller values (case (1) above): - realWrapLineIndex = - misc::min (realWrapLineIndex, lineIndex2); + if (!exceeds) { + Line *line = lines->getRef (lineIndex2); + for (int wordIndex = line->firstWord; + !found && wordIndex <= line->lastWord; wordIndex++) { + Word *word = words->getRef (wordIndex); + if (word->content.type == core::Content::WIDGET_OOF_REF && + word->content.widget == widgetOOF) { + found = true; + // Correct only by smaller values (case (1) above): + realWrapLineIndex = + misc::min (realWrapLineIndex, lineIndex2); + } } - } - minWrapLineIndex = misc::min (minWrapLineIndex, lineIndex2); - maxWrapLineIndex = misc::max (maxWrapLineIndex, lineIndex2); + minWrapLineIndex = misc::min (minWrapLineIndex, lineIndex2); + maxWrapLineIndex = misc::max (maxWrapLineIndex, lineIndex2); + } } - } - assert (found); - } - - DBG_OBJ_MSGF ("resize", 1, - "wrapLineIndex: corrected from %d to %d (%d lines total); " - "searched between %d and %d; this is the GB: %s", - wrapLineIndex, realWrapLineIndex, lines->size (), - minWrapLineIndex, maxWrapLineIndex, - vloat->getGenerator() == this ? "yes" : "no"); + assert (found); + } - queueResize (makeParentRefInFlow (realWrapLineIndex), true); + DBG_OBJ_MSGF ("resize", 1, + "wrapLineIndex: corrected from %d to %d (%d lines " + "total); searched between %d and %d; this is the GB: %s", + wrapLineIndex, realWrapLineIndex, lines->size (), + minWrapLineIndex, maxWrapLineIndex, + widgetOOF->getGenerator() == this ? "yes" : "no"); - // Notice that the line no. realWrapLineIndex may not exist yet. - if (realWrapLineIndex == 0) - lastWordDrawn = misc::min (lastWordDrawn, -1); - else - lastWordDrawn = - misc::min (lastWordDrawn, - lines->getRef(realWrapLineIndex - 1)->lastWord); - DBG_OBJ_SET_NUM ("lastWordDrawn", lastWordDrawn); + queueResize (makeParentRefInFlow (realWrapLineIndex), true); - // TODO Is the following necessary? Or even useless? - //redrawY = - // misc::min (redrawY, - // lineYOffsetWidget (lines->getRef (realWrapLineIndex))); - //DBG_OBJ_SET_NUM ("redrawY", redrawY); + // Notice that the line no. realWrapLineIndex may not exist yet. + if (realWrapLineIndex == 0) + lastWordDrawn = misc::min (lastWordDrawn, -1); + else + lastWordDrawn = + misc::min (lastWordDrawn, + lines->getRef(realWrapLineIndex - 1)->lastWord); + DBG_OBJ_SET_NUM ("lastWordDrawn", lastWordDrawn); + + // TODO Is the following necessary? Or even useless? + //redrawY = + // misc::min (redrawY, + // lineYOffsetWidget (lines->getRef (realWrapLineIndex))); + //DBG_OBJ_SET_NUM ("redrawY", redrawY); + } } DBG_OBJ_LEAVE (); |