diff options
author | Sebastian Geerken <devnull@localhost> | 2015-01-31 14:42:28 +0100 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2015-01-31 14:42:28 +0100 |
commit | eac1c960c8c875715fdb8d123e4c19302d93eb00 (patch) | |
tree | 5160a48e11c0047f31a9898de6144dea894358db | |
parent | e1eaf4d64bcafcd5b2f50153dd7db0106223012c (diff) |
Relative positions, part 5: more bug fixes.
-rw-r--r-- | dw/ooffloatsmgr.cc | 6 | ||||
-rw-r--r-- | dw/ooffloatsmgr.hh | 3 | ||||
-rw-r--r-- | dw/oofpositionedmgr.cc | 6 | ||||
-rw-r--r-- | dw/oofpositionedmgr.hh | 3 | ||||
-rw-r--r-- | dw/oofposrelmgr.cc | 10 | ||||
-rw-r--r-- | dw/outofflowmgr.hh | 14 | ||||
-rw-r--r-- | dw/textblock_linebreaking.cc | 22 |
7 files changed, 51 insertions, 13 deletions
diff --git a/dw/ooffloatsmgr.cc b/dw/ooffloatsmgr.cc index c509af8d..4bf69450 100644 --- a/dw/ooffloatsmgr.cc +++ b/dw/ooffloatsmgr.cc @@ -1523,7 +1523,7 @@ Widget *OOFFloatsMgr::getFloatWidgetAtPoint (SortedFloatsVector *list, int x, return widgetAtPoint; } -void OOFFloatsMgr::tellPosition (Widget *widget, int x, int y) +void OOFFloatsMgr::tellPosition1 (Widget *widget, int x, int y) { DBG_OBJ_ENTER ("resize.oofm", 0, "tellPosition", "%p, %d, %d", widget, x, y); @@ -1606,6 +1606,10 @@ void OOFFloatsMgr::tellPosition (Widget *widget, int x, int y) DBG_OBJ_LEAVE (); } +void OOFFloatsMgr::tellPosition2 (Widget *widget, int x, int y) +{ +} + bool OOFFloatsMgr::collidesV (Float *vloat, Float *other, SFVType type, int *yReal, bool useAllocation) { diff --git a/dw/ooffloatsmgr.hh b/dw/ooffloatsmgr.hh index 94a67fea..1a66e2ff 100644 --- a/dw/ooffloatsmgr.hh +++ b/dw/ooffloatsmgr.hh @@ -358,7 +358,8 @@ public: void moveExternalIndices (OOFAwareWidget *generatingBlock, int oldStartIndex, int diff); - void tellPosition (core::Widget *widget, int x, int y); + void tellPosition1 (core::Widget *widget, int x, int y); + void tellPosition2 (core::Widget *widget, int x, int y); void getSize (core::Requisition *cbReq, int *oofWidth, int *oofHeight); bool containerMustAdjustExtraSpace (); diff --git a/dw/oofpositionedmgr.cc b/dw/oofpositionedmgr.cc index 1d2248d7..5834a729 100644 --- a/dw/oofpositionedmgr.cc +++ b/dw/oofpositionedmgr.cc @@ -163,7 +163,11 @@ Widget *OOFPositionedMgr::getWidgetAtPoint (int x, int y, return widgetAtPoint; } -void OOFPositionedMgr::tellPosition (Widget *widget, int x, int y) +void OOFPositionedMgr::tellPosition1 (Widget *widget, int x, int y) +{ +} + +void OOFPositionedMgr::tellPosition2 (Widget *widget, int x, int y) { DBG_OBJ_ENTER ("resize.oofm", 0, "tellPosition", "%p, %d, %d", widget, x, y); diff --git a/dw/oofpositionedmgr.hh b/dw/oofpositionedmgr.hh index 00941da5..272cc62b 100644 --- a/dw/oofpositionedmgr.hh +++ b/dw/oofpositionedmgr.hh @@ -65,7 +65,8 @@ public: void moveExternalIndices (OOFAwareWidget *generator, int oldStartIndex, int diff); - void tellPosition (core::Widget *widget, int x, int y); + void tellPosition1 (core::Widget *widget, int x, int y); + void tellPosition2 (core::Widget *widget, int x, int y); bool containerMustAdjustExtraSpace (); diff --git a/dw/oofposrelmgr.cc b/dw/oofposrelmgr.cc index 90cc47ae..8820f8b5 100644 --- a/dw/oofposrelmgr.cc +++ b/dw/oofposrelmgr.cc @@ -79,11 +79,11 @@ void OOFPosRelMgr::sizeAllocateEnd (OOFAwareWidget *caller) Requisition childReq; child->widget->sizeRequest (&childReq); - Allocation childAlloc; - childAlloc.x = containerAllocation.x + - container->getStyle()->boxOffsetX () + child->x; - childAlloc.y = containerAllocation.y + - container->getStyle()->boxOffsetY () + child->y; + Allocation *genAlloc = child->generator == container ? + &containerAllocation : child->generator->getAllocation (), + childAlloc; + childAlloc.x = genAlloc->x + child->x; + childAlloc.y = genAlloc->y + child->y; childAlloc.width = childReq.width; childAlloc.ascent = childReq.ascent; childAlloc.descent = childReq.descent; diff --git a/dw/outofflowmgr.hh b/dw/outofflowmgr.hh index 1632499e..9f8bf870 100644 --- a/dw/outofflowmgr.hh +++ b/dw/outofflowmgr.hh @@ -43,7 +43,19 @@ public: virtual void moveExternalIndices (OOFAwareWidget *generator, int oldStartIndex, int diff) = 0; - virtual void tellPosition (core::Widget *widget, int x, int y) = 0; + /** + * \brief Called before tellPosition2, see there for more. + */ + virtual void tellPosition1 (core::Widget *widget, int x, int y) = 0; + + /** + * \brief Called after tellPosition1. + * + * An implementation should only implement either tellPosition1 or + * tellPosition2. Coordinates are relative to the allocation of the + * generator. + */ + virtual void tellPosition2 (core::Widget *widget, int x, int y) = 0; virtual void getSize (core::Requisition *containerReq, int *oofWidth, int *oofHeight) = 0; diff --git a/dw/textblock_linebreaking.cc b/dw/textblock_linebreaking.cc index 974d64f4..6df26081 100644 --- a/dw/textblock_linebreaking.cc +++ b/dw/textblock_linebreaking.cc @@ -503,12 +503,27 @@ Textblock::Line *Textblock::addLine (int firstWord, int lastWord, //printf ("\n"); int xWidget = line->textOffset; + int yLine = lineYOffsetWidget (line); for (int i = firstWord; i <= lastWord; i++) { Word *word = words->getRef (i); if (word->wordImgRenderer) word->wordImgRenderer->setData (xWidget, lines->size () - 1); if (word->spaceImgRenderer) word->spaceImgRenderer->setData (xWidget, lines->size () - 1); + + if (word->content.type == core::Content::WIDGET_OOF_REF) { + Widget *widget = word->content.widget; + oof::OutOfFlowMgr *oofm = + searchOutOfFlowMgr (getWidgetOOFIndex (widget)); + // See also Textblock::sizeAllocate, and notes there about + // vertical alignment. Calculating the vertical position + // should probably be centralized. + if (oofm) + oofm->tellPosition2 (widget, xWidget, + yLine + (line->borderAscent + - word->size.ascent)); + } + xWidget += word->size.width + word->effSpace; } @@ -793,7 +808,7 @@ int Textblock::wrapWordInFlow (int wordIndex, bool wrapAll) oof::OutOfFlowMgr *oofm = searchOutOfFlowMgr (getWidgetOOFIndex (widget)); if (oofm && oofm->mayAffectBordersAtAll ()) - oofm->tellPosition (widget, boxOffsetX (), yNewLine); + oofm->tellPosition1 (widget, boxOffsetX (), yNewLine); balanceBreakPosAndHeight (wordIndex, firstIndex, &searchUntil, tempNewLine, penaltyIndex, false, @@ -880,13 +895,14 @@ int Textblock::wrapWordOofRef (int wordIndex, bool wrapAll) int yNewLine = yOffsetOfLineToBeCreated (); // Floats, which affect either border, are handled in wrapWordInFlow; this - // is rather for positioned elements. + // is rather for positioned elements (but only for completeness: + // tellPosition1 is not implemented for positioned elements). oof::OutOfFlowMgr *oofm = searchOutOfFlowMgr (getWidgetOOFIndex (widget)); DBG_OBJ_MSGF ("construct.word", 1, "parentRef = %d, oofm = %p", widget->parentRef, oofm); if (oofm && !oofm->mayAffectBordersAtAll ()) // TODO Again, "x" is not correct (see above). - oofm->tellPosition (widget, boxOffsetX (), yNewLine); + oofm->tellPosition1 (widget, boxOffsetX (), yNewLine); DBG_OBJ_LEAVE (); |