diff options
author | Sebastian Geerken <devnull@localhost> | 2015-10-10 13:28:59 +0200 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2015-10-10 13:28:59 +0200 |
commit | b7d71aed37122b8277fee0c39da06c0cd3156742 (patch) | |
tree | 5e64d49790b54729df09a31f287650d65a8690cc | |
parent | 55ef9e15acdc335458adef22a72648a7753fd9e9 (diff) |
SRDOP: clear (still buggy).
-rw-r--r-- | dw/oofawarewidget.cc | 6 | ||||
-rw-r--r-- | dw/oofawarewidget.hh | 6 | ||||
-rw-r--r-- | dw/ooffloatsmgr.cc | 91 | ||||
-rw-r--r-- | dw/ooffloatsmgr.hh | 5 | ||||
-rw-r--r-- | dw/textblock.cc | 12 | ||||
-rw-r--r-- | dw/textblock.hh | 1 |
6 files changed, 48 insertions, 73 deletions
diff --git a/dw/oofawarewidget.cc b/dw/oofawarewidget.cc index fe5302d8..61c403a6 100644 --- a/dw/oofawarewidget.cc +++ b/dw/oofawarewidget.cc @@ -565,6 +565,12 @@ int OOFAwareWidget::getGeneratorX (int oofmIndex) return 0; } +int OOFAwareWidget::getGeneratorY (int oofmIndex) +{ + assertNotReached (); + return 0; +} + int OOFAwareWidget::getGeneratorWidth () { assertNotReached (); diff --git a/dw/oofawarewidget.hh b/dw/oofawarewidget.hh index 4b6a2fd0..4492bac5 100644 --- a/dw/oofawarewidget.hh +++ b/dw/oofawarewidget.hh @@ -288,6 +288,12 @@ public: virtual int getGeneratorX (int oofmIndex); /** + * Return position relative to container, not regarding + * margin/border/padding, Called by OOFFloatsMgr to position floats. + */ + virtual int getGeneratorY (int oofmIndex); + + /** * Return width including margin/border/padding Called by OOFFloatsMgr to * position floats. */ diff --git a/dw/ooffloatsmgr.cc b/dw/ooffloatsmgr.cc index 79b76580..4690eac6 100644 --- a/dw/ooffloatsmgr.cc +++ b/dw/ooffloatsmgr.cc @@ -300,8 +300,6 @@ OOFFloatsMgr::TBInfo::TBInfo (OOFFloatsMgr *oofm, OOFAwareWidget *textblock, leftFloats = new Vector<Float> (1, false); rightFloats = new Vector<Float> (1, false); - - clearPosition = 0; } OOFFloatsMgr::TBInfo::~TBInfo () @@ -371,22 +369,9 @@ void OOFFloatsMgr::sizeAllocateEnd (OOFAwareWidget *caller) { DBG_OBJ_ENTER ("resize.oofm", 0, "sizeAllocateEnd", "%p", caller); - if (isOOFAwareWidgetRegistered (caller)) { - // The checks below do not cover "clear position" in all cases, - // so this is done here separately. This position is stored in - // TBInfo and calculated at this points; changes will be noticed - // to the textblock. - TBInfo *tbInfo = getOOFAwareWidget (caller); - int newClearPosition = calcClearPosition (caller); - if (newClearPosition != tbInfo->clearPosition) { - tbInfo->clearPosition = newClearPosition; - caller->clearPositionChanged (); - } - - if (caller == container) { - sizeAllocateFloats (LEFT); - sizeAllocateFloats (RIGHT); - } + if (caller == container) { + sizeAllocateFloats (LEFT); + sizeAllocateFloats (RIGHT); } DBG_OBJ_LEAVE (); @@ -1151,20 +1136,15 @@ int OOFFloatsMgr::getFloatHeight (Side side, int y, int h, /** * Returns position relative to the textblock "tb". */ -int OOFFloatsMgr::getClearPosition (OOFAwareWidget *textblock) -{ - return getOOFAwareWidget(textblock)->clearPosition; -} - -int OOFFloatsMgr::calcClearPosition (OOFAwareWidget *textblock) +int OOFFloatsMgr::getClearPosition (OOFAwareWidget *widget) { - DBG_OBJ_ENTER ("resize.oofm", 0, "getClearPosition", "%p", textblock); + DBG_OBJ_ENTER ("resize.oofm", 0, "getClearPosition", "%p", widget); int pos; - if (textblock->getStyle()) { + if (widget->getStyle()) { bool left = false, right = false; - switch (textblock->getStyle()->clear) { + switch (widget->getStyle()->clear) { case CLEAR_NONE: break; case CLEAR_LEFT: left = true; break; case CLEAR_RIGHT: right = true; break; @@ -1172,8 +1152,8 @@ int OOFFloatsMgr::calcClearPosition (OOFAwareWidget *textblock) default: assertNotReached (); } - pos = max (left ? calcClearPosition (textblock, LEFT) : 0, - right ? calcClearPosition (textblock, RIGHT) : 0); + pos = max (left ? getClearPosition (widget, LEFT) : 0, + right ? getClearPosition (widget, RIGHT) : 0); } else pos = 0; @@ -1198,56 +1178,29 @@ bool OOFFloatsMgr::mayAffectBordersAtAll () return true; } -int OOFFloatsMgr::calcClearPosition (OOFAwareWidget *textblock, Side side) +int OOFFloatsMgr::getClearPosition (OOFAwareWidget *widget, Side side) { - // TODO (SRDOP) Implementation - return 0; - -#if 0 DBG_OBJ_ENTER ("resize.oofm", 0, "getClearPosition", "%p, %s", - textblock, side == LEFT ? "LEFT" : "RIGHT"); + widget, side == LEFT ? "LEFT" : "RIGHT"); int pos; + SortedFloatsVector *list = side == LEFT ? leftFloats : rightFloats; - if (!wasAllocated (textblock)) - // There is no relation yet to floats generated by other - // textblocks, and this textblocks floats are unimportant for - // the "clear" property. + // Search the last float before (therfore -1) this widget. + int i = list->findFloatIndex (widget, -1); + if (i < 0) pos = 0; else { - SortedFloatsVector *list = side == LEFT ? leftFloats : rightFloats; - - // Search the last float before (therfore -1) this textblock. - int i = list->findFloatIndex (textblock, -1); - if (i < 0) { - pos = 0; - DBG_OBJ_MSG ("resize.oofm", 1, "no float"); - } else { - Float *vloat = list->get(i); - assert (vloat->generatingBlock != textblock); - if (!wasAllocated (vloat->generatingBlock)) - pos = 0; // See above. - else { - ensureFloatSize (vloat); - pos = max (getAllocation(vloat->generatingBlock)->y + vloat->yReal - + vloat->size.ascent + vloat->size.descent - - getAllocation(textblock)->y, - 0); - DBG_OBJ_MSGF ("resize.oofm", 1, - "float %p => max (%d + %d + (%d + %d) - %d, 0)", - vloat->getWidget (), - getAllocation(vloat->generatingBlock)->y, - vloat->yReal, vloat->size.ascent, vloat->size.descent, - getAllocation(textblock)->y); - } - } + Float *vloat = list->get(i); + assert (vloat->generator != widget); + ensureFloatSize (vloat); + pos = max (vloat->yReal + vloat->size.ascent + vloat->size.descent + - vloat->generator->getGeneratorY (oofmIndex), 0); } - - DBG_OBJ_MSGF ("resize.oofm", 1, "=> %d", pos); - DBG_OBJ_LEAVE (); + + DBG_OBJ_LEAVE_VAL ("%d", pos); return pos; -#endif } void OOFFloatsMgr::ensureFloatSize (Float *vloat) diff --git a/dw/ooffloatsmgr.hh b/dw/ooffloatsmgr.hh index 521ccd90..27d296a9 100644 --- a/dw/ooffloatsmgr.hh +++ b/dw/ooffloatsmgr.hh @@ -131,8 +131,6 @@ private: TBInfo *parent; int parentExtIndex; - int clearPosition; - // These two lists store all floats of a generator, in the order // in which they are defined. Used for optimization lout::container::typed::Vector<Float> *leftFloats, *rightFloats; @@ -193,8 +191,7 @@ private: int getFloatHeight (Side side, int y, int h, OOFAwareWidget *lastGB, int lastExtIndex); - int calcClearPosition (OOFAwareWidget *textblock); - int calcClearPosition (OOFAwareWidget *textblock, Side side); + int getClearPosition (OOFAwareWidget *widget, Side side); void ensureFloatSize (Float *vloat); diff --git a/dw/textblock.cc b/dw/textblock.cc index bc6639da..e5561f6a 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -3179,6 +3179,18 @@ void Textblock::oofSizeChanged (bool extremesChanged) DBG_OBJ_LEAVE (); } +int Textblock::getGeneratorY (int oofmIndex) +{ + int yRef; + if (findSizeRequestReference (oofmIndex, NULL, &yRef)) + return yRef; + else { + // Only called for floats, so this should not happen: + assertNotReached (); + return 0; + } +} + int Textblock::getGeneratorX (int oofmIndex) { int xRef; diff --git a/dw/textblock.hh b/dw/textblock.hh index e4bf5138..70070975 100644 --- a/dw/textblock.hh +++ b/dw/textblock.hh @@ -914,6 +914,7 @@ public: void clearPositionChanged (); void oofSizeChanged (bool extremesChanged); int getGeneratorX (int oofmIndex); + int getGeneratorY (int oofmIndex); int getGeneratorWidth (); bool isPossibleContainer (int oofmIndex); bool isPossibleContainerParent (int oofmIndex); |