diff options
author | Sebastian Geerken <devnull@localhost> | 2015-01-23 13:17:13 +0100 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2015-01-23 13:17:13 +0100 |
commit | 80229b2b5159af52b407fdf2f535d57c669bb667 (patch) | |
tree | 1119ca90bc237648a1dea0bd5392dbd759239bca /dw | |
parent | 101b4e1ddcf164b55ccf06513fc007463bfc0662 (diff) |
Simplified interrupted drawing. (Mouse events will follow.)
Diffstat (limited to 'dw')
-rw-r--r-- | dw/alignedtablecell.cc | 8 | ||||
-rw-r--r-- | dw/bullet.cc | 3 | ||||
-rw-r--r-- | dw/bullet.hh | 3 | ||||
-rw-r--r-- | dw/fltkui.cc | 9 | ||||
-rw-r--r-- | dw/fltkui.hh | 6 | ||||
-rw-r--r-- | dw/image.cc | 3 | ||||
-rw-r--r-- | dw/image.hh | 3 | ||||
-rw-r--r-- | dw/layout.cc | 3 | ||||
-rw-r--r-- | dw/oofawarewidget.cc | 111 | ||||
-rw-r--r-- | dw/oofawarewidget.hh | 11 | ||||
-rw-r--r-- | dw/ooffloatsmgr.cc | 40 | ||||
-rw-r--r-- | dw/ooffloatsmgr.hh | 8 | ||||
-rw-r--r-- | dw/oofpositionedmgr.cc | 25 | ||||
-rw-r--r-- | dw/oofpositionedmgr.hh | 3 | ||||
-rw-r--r-- | dw/outofflowmgr.hh | 3 | ||||
-rw-r--r-- | dw/ruler.cc | 3 | ||||
-rw-r--r-- | dw/ruler.hh | 3 | ||||
-rw-r--r-- | dw/simpletablecell.cc | 8 | ||||
-rw-r--r-- | dw/stackingcontextmgr.cc | 85 | ||||
-rw-r--r-- | dw/stackingcontextmgr.hh | 15 | ||||
-rw-r--r-- | dw/table.cc | 41 | ||||
-rw-r--r-- | dw/table.hh | 5 | ||||
-rw-r--r-- | dw/tablecell.cc | 4 | ||||
-rw-r--r-- | dw/textblock.cc | 93 | ||||
-rw-r--r-- | dw/textblock.hh | 8 | ||||
-rw-r--r-- | dw/textblock_iterator.cc | 2 | ||||
-rw-r--r-- | dw/types.hh | 31 | ||||
-rw-r--r-- | dw/ui.cc | 10 | ||||
-rw-r--r-- | dw/ui.hh | 5 | ||||
-rw-r--r-- | dw/widget.cc | 156 | ||||
-rw-r--r-- | dw/widget.hh | 12 |
31 files changed, 250 insertions, 470 deletions
diff --git a/dw/alignedtablecell.cc b/dw/alignedtablecell.cc index dc7d88c9..b5e321b7 100644 --- a/dw/alignedtablecell.cc +++ b/dw/alignedtablecell.cc @@ -63,7 +63,7 @@ bool AlignedTableCell::mustBeWidenedToAvailWidth () int AlignedTableCell::getAvailWidthOfChild (Widget *child, bool forceValue) { - DBG_OBJ_ENTER ("resize", 0, "AlignedTableCell/getAvailWidthOfChild", + DBG_OBJ_ENTER ("resize", 0, "AlignedTableCell::getAvailWidthOfChild", "%p, %s", child, forceValue ? "true" : "false"); int width = tablecell::correctAvailWidthOfChild @@ -76,7 +76,7 @@ int AlignedTableCell::getAvailWidthOfChild (Widget *child, bool forceValue) int AlignedTableCell::getAvailHeightOfChild (Widget *child, bool forceValue) { - DBG_OBJ_ENTER ("resize", 0, "AlignedTableCell/getAvailHeightOfChild", + DBG_OBJ_ENTER ("resize", 0, "AlignedTableCell::getAvailHeightOfChild", "%p, %s", child, forceValue ? "true" : "false"); int height = tablecell::correctAvailHeightOfChild @@ -94,7 +94,7 @@ void AlignedTableCell::correctRequisitionOfChild (Widget *child, int*, int*)) { - DBG_OBJ_ENTER ("resize", 0, "AlignedTableCell/correctRequisitionOfChild", + DBG_OBJ_ENTER ("resize", 0, "AlignedTableCell::correctRequisitionOfChild", "%p, %d * (%d + %d), ...", child, requisition->width, requisition->ascent, requisition->descent); @@ -110,7 +110,7 @@ void AlignedTableCell::correctExtremesOfChild (Widget *child, core::Extremes *extremes, bool useAdjustmentWidth) { - DBG_OBJ_ENTER ("resize", 0, "AlignedTableCell/correctExtremesOfChild", + DBG_OBJ_ENTER ("resize", 0, "AlignedTableCell::correctExtremesOfChild", "%p, %d (%d) / %d (%d)", child, extremes->minWidth, extremes->minWidthIntrinsic, extremes->maxWidth, extremes->maxWidthIntrinsic); diff --git a/dw/bullet.cc b/dw/bullet.cc index e01191c3..98d90672 100644 --- a/dw/bullet.cc +++ b/dw/bullet.cc @@ -57,8 +57,7 @@ void Bullet::containerSizeChangedForChildren () } void Bullet::draw (core::View *view, core::Rectangle *area, - core::StackingIteratorStack *iteratorStack, - Widget **interruptedWidget) + core::DrawingContext *context) { int x, y, l; bool filled = true; diff --git a/dw/bullet.hh b/dw/bullet.hh index 7703a64b..e50fa0eb 100644 --- a/dw/bullet.hh +++ b/dw/bullet.hh @@ -18,8 +18,7 @@ protected: void getExtremesImpl (core::Extremes *extremes); void containerSizeChangedForChildren (); void draw (core::View *view, core::Rectangle *area, - core::StackingIteratorStack *iteratorStack, - Widget **interruptedWidget); + core::DrawingContext *context); core::Iterator *iterator (core::Content::Type mask, bool atEnd); public: diff --git a/dw/fltkui.cc b/dw/fltkui.cc index 29008055..6099fd69 100644 --- a/dw/fltkui.cc +++ b/dw/fltkui.cc @@ -223,7 +223,8 @@ void FltkResource::sizeAllocate (core::Allocation *allocation) DBG_OBJ_LEAVE (); } -void FltkResource::draw (core::View *view, core::Rectangle *area) +void FltkResource::draw (core::View *view, core::Rectangle *area, + core::DrawingContext *context) { FltkView *fltkView = (FltkView*)view; if (fltkView->usesFltkWidgets () && this->view == fltkView) { @@ -324,9 +325,11 @@ template <class I> void FltkSpecificResource<I>::sizeAllocate (core::Allocation } template <class I> void FltkSpecificResource<I>::draw (core::View *view, - core::Rectangle *area) + core::Rectangle *area, + core::DrawingContext + *context) { - FltkResource::draw (view, area); + FltkResource::draw (view, area, context); } template <class I> void FltkSpecificResource<I>::setStyle (core::style::Style diff --git a/dw/fltkui.hh b/dw/fltkui.hh index a0d2d7b7..6ff024ca 100644 --- a/dw/fltkui.hh +++ b/dw/fltkui.hh @@ -211,7 +211,8 @@ public: virtual void detachView (FltkView *view); void sizeAllocate (core::Allocation *allocation); - void draw (core::View *view, core::Rectangle *area); + void draw (core::View *view, core::Rectangle *area, + core::DrawingContext *context); void setStyle (core::style::Style *style); @@ -227,7 +228,8 @@ public: ~FltkSpecificResource (); void sizeAllocate (core::Allocation *allocation); - void draw (core::View *view, core::Rectangle *area); + void draw (core::View *view, core::Rectangle *area, + core::DrawingContext *context); void setStyle (core::style::Style *style); bool isEnabled (); diff --git a/dw/image.cc b/dw/image.cc index 7fb6c5eb..030d4882 100644 --- a/dw/image.cc +++ b/dw/image.cc @@ -408,8 +408,7 @@ bool Image::buttonReleaseImpl (core::EventButton *event) } void Image::draw (core::View *view, core::Rectangle *area, - core::StackingIteratorStack *iteratorStack, - Widget **interruptedWidget) + core::DrawingContext *context) { int dx, dy; core::Rectangle content, intersection; diff --git a/dw/image.hh b/dw/image.hh index 9831c7b6..a46dd20a 100644 --- a/dw/image.hh +++ b/dw/image.hh @@ -136,8 +136,7 @@ protected: void containerSizeChangedForChildren (); void draw (core::View *view, core::Rectangle *area, - core::StackingIteratorStack *iteratorStack, - Widget **interruptedWidget); + core::DrawingContext *context); bool buttonPressImpl (core::EventButton *event); bool buttonReleaseImpl (core::EventButton *event); diff --git a/dw/layout.cc b/dw/layout.cc index c87606dd..ca2ceb98 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -704,7 +704,8 @@ void Layout::draw (View *view, Rectangle *area) widgetDrawArea.width = intersection.width; widgetDrawArea.height = intersection.height; - topLevel->drawToplevel (view, &widgetDrawArea); + DrawingContext context (&widgetArea); + topLevel->draw (view, &widgetDrawArea, &context); view->finishDrawing (&intersection); } diff --git a/dw/oofawarewidget.cc b/dw/oofawarewidget.cc index c6b75306..eac4580b 100644 --- a/dw/oofawarewidget.cc +++ b/dw/oofawarewidget.cc @@ -392,81 +392,26 @@ bool OOFAwareWidget::doesWidgetOOFInterruptDrawing (Widget *widget) return cl < gl; } -void OOFAwareWidget::draw (View *view, Rectangle *area, - StackingIteratorStack *iteratorStack, - Widget **interruptedWidget) +void OOFAwareWidget::draw (View *view, Rectangle *area, DrawingContext *context) { DBG_OBJ_ENTER ("draw", 0, "draw", "%d, %d, %d * %d", area->x, area->y, area->width, area->height); - while (*interruptedWidget == NULL && - ((OOFStackingIterator*)iteratorStack->getTop())->majorLevel - < OOFStackingIterator::END) { - drawLevel (view, area, iteratorStack, interruptedWidget, - ((OOFStackingIterator*)iteratorStack->getTop())->majorLevel); - - if (*interruptedWidget) { - DBG_OBJ_MSGF ("draw", 1, "interrupted at %p (parent = %p)", - *interruptedWidget, (*interruptedWidget)->getParent ()); - - if ((*interruptedWidget)->getParent () == this) { - DBG_OBJ_MSG ("draw", 1, "drawing seperately"); - DBG_OBJ_MSG_START (); - - DBG_IF_RTFL { - StringBuffer sb; - iteratorStack->intoStringBuffer (&sb); - DBG_OBJ_MSGF ("draw", 2, "iteratorStack: %s", sb.getChars ()); - } - - core::Rectangle interruptedWidgetArea; - if ((*interruptedWidget)->intersects (area, - &interruptedWidgetArea)) { - // Similar to Widget::drawToplevel. Nested interruptions are not - // allowed. - StackingIteratorStack iteratorStack2; - Widget *interruptedWidget2 = NULL; - (*interruptedWidget)->drawTotal (view, &interruptedWidgetArea, - &iteratorStack2, - &interruptedWidget2); - assert (interruptedWidget2 == NULL); - //if (interruptedWidget2 != NULL) - // DBG_OBJ_MSGF ("draw", 0, - // "===== Assertion failed: " - // "interruptedWidget2 = %p =====", - // interruptedWidget2); - } + for (int level = 0; level < OOFStackingIterator::END; level++) + drawLevel (view, area, level, context); - ((OOFStackingIterator*)iteratorStack->getTop()) - ->registerWidgetDrawnAfterInterruption (*interruptedWidget); - - // Continue with the current state of "iterator". - *interruptedWidget = NULL; - - DBG_OBJ_MSG_END (); - } - } else { - OOFStackingIterator* osi = - (OOFStackingIterator*)iteratorStack->getTop(); - osi->majorLevel++; - osi->minorLevel = osi->index = 0; - } - } - - DBG_OBJ_MSGF ("draw", 1, "=> %p", *interruptedWidget); DBG_OBJ_LEAVE (); } -void OOFAwareWidget::drawLevel (View *view, Rectangle *area, - StackingIteratorStack *iteratorStack, - Widget **interruptedWidget, int majorLevel) +void OOFAwareWidget::drawLevel (View *view, Rectangle *area, int level, + DrawingContext *context) { - DBG_OBJ_ENTER ("draw", 0, "OOFAwareWidget/drawLevel", + DBG_OBJ_ENTER ("draw", 0, "OOFAwareWidget::drawLevel", "(%d, %d, %d * %d), %s", area->x, area->y, area->width, area->height, - OOFStackingIterator::majorLevelText (majorLevel)); + OOFStackingIterator::majorLevelText (level)); - switch (majorLevel) { + switch (level) { case OOFStackingIterator::START: break; @@ -475,13 +420,8 @@ void OOFAwareWidget::drawLevel (View *view, Rectangle *area, break; case OOFStackingIterator::SC_BOTTOM: - if (stackingContextMgr) { - OOFStackingIterator *osi = - (OOFStackingIterator*)iteratorStack->getTop (); - stackingContextMgr->drawBottom (view, area, iteratorStack, - interruptedWidget, &osi->minorLevel, - &osi->index); - } + if (stackingContextMgr) + stackingContextMgr->drawBottom (view, area, context); break; case OOFStackingIterator::IN_FLOW: @@ -493,42 +433,27 @@ void OOFAwareWidget::drawLevel (View *view, Rectangle *area, break; case OOFStackingIterator::OOF_CONT: - drawOOF (view, area, iteratorStack, interruptedWidget); + drawOOF (view, area, context); break; case OOFStackingIterator::SC_TOP: - if (stackingContextMgr) { - OOFStackingIterator *osi = - (OOFStackingIterator*)iteratorStack->getTop (); - stackingContextMgr->drawTop (view, area, iteratorStack, - interruptedWidget, &osi->minorLevel, - &osi->index); - } + if (stackingContextMgr) + stackingContextMgr->drawTop (view, area, context); break; case OOFStackingIterator::END: break; } - DBG_OBJ_MSGF ("draw", 1, "=> %p", *interruptedWidget); DBG_OBJ_LEAVE (); } void OOFAwareWidget::drawOOF (View *view, Rectangle *area, - StackingIteratorStack *iteratorStack, - Widget **interruptedWidget) + DrawingContext *context) { - OOFStackingIterator *osi = (OOFStackingIterator*)iteratorStack->getTop (); - assert (osi->majorLevel == OOFStackingIterator::OOF_CONT); - - while (*interruptedWidget == NULL && osi->minorLevel < NUM_OOFM) { - if(outOfFlowMgr[osi->minorLevel]) - outOfFlowMgr[osi->minorLevel]->draw (view, area, iteratorStack, - interruptedWidget, &(osi->index)); - if (*interruptedWidget == NULL) { - osi->minorLevel++; - osi->index = 0; - } + for (int i = 0; i < NUM_OOFM; i++) { + if(outOfFlowMgr[i]) + outOfFlowMgr[i]->draw (view, area, context); } } @@ -623,7 +548,7 @@ Widget *OOFAwareWidget::getWidgetAtPointLevel (int x, int y, Widget **interruptedWidget, int majorLevel) { - DBG_OBJ_ENTER ("events", 0, "OOFAwareWidget/getWidgetAtPointLevel", + DBG_OBJ_ENTER ("events", 0, "OOFAwareWidget::getWidgetAtPointLevel", "%d, %d, %s", x, y, OOFStackingIterator::majorLevelText (majorLevel)); diff --git a/dw/oofawarewidget.hh b/dw/oofawarewidget.hh index 5c87b423..8573fd3f 100644 --- a/dw/oofawarewidget.hh +++ b/dw/oofawarewidget.hh @@ -157,12 +157,10 @@ protected: void sizeAllocateEnd (); void containerSizeChangedForChildrenOOF (); - virtual void drawLevel (core::View *view, core::Rectangle *area, - core::StackingIteratorStack *iteratorStack, - Widget **interruptedWidget, int majorLevel); + virtual void drawLevel (core::View *view, core::Rectangle *area, int level, + core::DrawingContext *context); void drawOOF (core::View *view, core::Rectangle *area, - core::StackingIteratorStack *iteratorStack, - Widget **interruptedWidget); + core::DrawingContext *context); Widget *getWidgetAtPoint (int x, int y, core::StackingIteratorStack *iteratorStack, @@ -256,8 +254,7 @@ public: bool doesWidgetOOFInterruptDrawing (Widget *widget); void draw (core::View *view, core::Rectangle *area, - core::StackingIteratorStack *iteratorStack, - Widget **interruptedWidget); + core::DrawingContext *context); lout::object::Object *stackingIterator (bool atEnd); virtual bool mustBeWidenedToAvailWidth (); diff --git a/dw/ooffloatsmgr.cc b/dw/ooffloatsmgr.cc index 8758c1a3..f9e7b0d0 100644 --- a/dw/ooffloatsmgr.cc +++ b/dw/ooffloatsmgr.cc @@ -279,7 +279,7 @@ int OOFFloatsMgr::Float::CompareGBAndExtIndex::compare (Object *o1, Object *o2) Float *f1 = (Float*)o1, *f2 = (Float*)o2; int r = -123; // Compiler happiness: GCC 4.7 does not handle this?; - DBG_OBJ_ENTER_O ("border", 1, oofm, "CompareGBAndExtIndex/compare", + DBG_OBJ_ENTER_O ("border", 1, oofm, "CompareGBAndExtIndex::compare", "#%d -> %p/%d, #%d -> %p/#%d", f1->getIndex (type), f1->generatingBlock, f1->externalIndex, f2->getIndex (type), f2->generatingBlock, @@ -1292,49 +1292,33 @@ int OOFFloatsMgr::calcFloatX (Float *vloat, Side side, int gbX, int gbWidth) return x; } -void OOFFloatsMgr::draw (View *view, Rectangle *area, - StackingIteratorStack *iteratorStack, - Widget **interruptedWidget, int *index) +void OOFFloatsMgr::draw (View *view, Rectangle *area, DrawingContext *context) { - DBG_OBJ_ENTER ("draw", 0, "draw", "(%d, %d, %d * %d), [%d]", - area->x, area->y, area->width, area->height, *index); + DBG_OBJ_ENTER ("draw", 0, "draw", "%d, %d, %d * %d", + area->x, area->y, area->width, area->height); - drawFloats (leftFloatsCB, view, area, iteratorStack, interruptedWidget, - index, 0); - if (*interruptedWidget == NULL) - drawFloats (rightFloatsCB, view, area, iteratorStack, interruptedWidget, - index, leftFloatsCB->size ()); + drawFloats (leftFloatsCB, view, area, context); + drawFloats (rightFloatsCB, view, area, context); - DBG_OBJ_MSGF ("draw", 1, "=> %p", *interruptedWidget); DBG_OBJ_LEAVE (); } void OOFFloatsMgr::drawFloats (SortedFloatsVector *list, View *view, - Rectangle *area, - StackingIteratorStack *iteratorStack, - Widget **interruptedWidget, int *index, - int startIndex) + Rectangle *area, DrawingContext *context) { // This could be improved, since the list is sorted: search the // first float fitting into the area, and iterate until one is // found below the area. - OOFAwareWidget::OOFStackingIterator *osi = - (OOFAwareWidget::OOFStackingIterator*)iteratorStack->getTop (); - - while (*interruptedWidget == NULL && *index - startIndex < list->size()) { - Float *vloat = list->get(*index - startIndex); + for (int i = 0; i < list->size(); i++) { + Float *vloat = list->get(i); Widget *childWidget = vloat->getWidget (); Rectangle childArea; - if (!osi->hasWidgetBeenDrawnAfterInterruption (childWidget) && + if (!context->hasWidgetBeenDrawnAsInterruption (childWidget) && !StackingContextMgr::handledByStackingContextMgr (childWidget) && - childWidget->intersects (area, &childArea)) - childWidget->drawTotal (view, &childArea, iteratorStack, - interruptedWidget); - - if (*interruptedWidget == NULL) - (*index)++; + childWidget->intersects (container, area, &childArea)) + childWidget->draw (view, &childArea, context); } } diff --git a/dw/ooffloatsmgr.hh b/dw/ooffloatsmgr.hh index 12f7d7da..1c0b5f03 100644 --- a/dw/ooffloatsmgr.hh +++ b/dw/ooffloatsmgr.hh @@ -285,10 +285,7 @@ private: bool haveExtremesChanged (Side side); void drawFloats (SortedFloatsVector *list, core::View *view, - core::Rectangle *area, - core::StackingIteratorStack *iteratorStack, - core::Widget **interruptedWidget, int *index, - int startIndex); + core::Rectangle *area, core::DrawingContext *context); core::Widget *getFloatWidgetAtPoint (SortedFloatsVector *list, int x, int y, core::StackingIteratorStack *iteratorStack, @@ -348,8 +345,7 @@ public: void sizeAllocateEnd (OOFAwareWidget *caller); void containerSizeChangedForChildren (); void draw (core::View *view, core::Rectangle *area, - core::StackingIteratorStack *iteratorStack, - core::Widget **interruptedWidget, int *index); + core::DrawingContext *context); void markSizeChange (int ref); void markExtremesChange (int ref); diff --git a/dw/oofpositionedmgr.cc b/dw/oofpositionedmgr.cc index 1e753bda..28d5aac7 100644 --- a/dw/oofpositionedmgr.cc +++ b/dw/oofpositionedmgr.cc @@ -216,30 +216,21 @@ bool OOFPositionedMgr::haveExtremesChanged () void OOFPositionedMgr::draw (View *view, Rectangle *area, - StackingIteratorStack *iteratorStack, - Widget **interruptedWidget, int *index) + DrawingContext *context) { - DBG_OBJ_ENTER ("draw", 0, "draw", "(%d, %d, %d * %d), [%d]", - area->x, area->y, area->width, area->height, *index); + DBG_OBJ_ENTER ("draw", 0, "draw", "%d, %d, %d * %d", + area->x, area->y, area->width, area->height); - OOFAwareWidget::OOFStackingIterator *osi = - (OOFAwareWidget::OOFStackingIterator*)iteratorStack->getTop (); - - while (*interruptedWidget == NULL && *index < children->size()) { - Child *child = children->get(*index); + for (int i = 0; i < children->size(); i++) { + Child *child = children->get(i); Rectangle childArea; - if (!osi->hasWidgetBeenDrawnAfterInterruption (child->widget) && + if (!context->hasWidgetBeenDrawnAsInterruption (child->widget) && !StackingContextMgr::handledByStackingContextMgr (child->widget) && - child->widget->intersects (area, &childArea)) - child->widget->drawTotal (view, &childArea, iteratorStack, - interruptedWidget); - - if (*interruptedWidget == NULL) - (*index)++; + child->widget->intersects (container, area, &childArea)) + child->widget->draw (view, &childArea, context); } - DBG_OBJ_MSGF ("draw", 1, "=> %p", *interruptedWidget); DBG_OBJ_LEAVE (); } diff --git a/dw/oofpositionedmgr.hh b/dw/oofpositionedmgr.hh index 713c2739..f33d7fe6 100644 --- a/dw/oofpositionedmgr.hh +++ b/dw/oofpositionedmgr.hh @@ -87,8 +87,7 @@ public: void sizeAllocateEnd (OOFAwareWidget *caller); void containerSizeChangedForChildren (); void draw (core::View *view, core::Rectangle *area, - core::StackingIteratorStack *iteratorStack, - core::Widget **interruptedWidget, int *index); + core::DrawingContext *context); void markSizeChange (int ref); void markExtremesChange (int ref); diff --git a/dw/outofflowmgr.hh b/dw/outofflowmgr.hh index 151c29f5..38ac78b9 100644 --- a/dw/outofflowmgr.hh +++ b/dw/outofflowmgr.hh @@ -26,8 +26,7 @@ public: virtual void sizeAllocateEnd (OOFAwareWidget *caller) = 0; virtual void containerSizeChangedForChildren () = 0; virtual void draw (core::View *view, core::Rectangle *area, - core::StackingIteratorStack *iteratorStack, - core::Widget **interruptedWidget, int *index) = 0; + core::DrawingContext *context) = 0; virtual void markSizeChange (int ref) = 0; virtual void markExtremesChange (int ref) = 0; diff --git a/dw/ruler.cc b/dw/ruler.cc index f29ac5dd..c34d8ecf 100644 --- a/dw/ruler.cc +++ b/dw/ruler.cc @@ -74,8 +74,7 @@ bool Ruler::usesAvailWidth () } void Ruler::draw (core::View *view, core::Rectangle *area, - core::StackingIteratorStack *iteratorStack, - Widget **interruptedWidget) + core::DrawingContext *context) { drawWidgetBox (view, area, false); } diff --git a/dw/ruler.hh b/dw/ruler.hh index 50789398..c90afccf 100644 --- a/dw/ruler.hh +++ b/dw/ruler.hh @@ -25,8 +25,7 @@ protected: void containerSizeChangedForChildren (); bool usesAvailWidth (); void draw (core::View *view, core::Rectangle *area, - core::StackingIteratorStack *iteratorStack, - Widget **interruptedWidget); + core::DrawingContext *context); public: static int CLASS_ID; diff --git a/dw/simpletablecell.cc b/dw/simpletablecell.cc index 0f1d31c9..f39d94b5 100644 --- a/dw/simpletablecell.cc +++ b/dw/simpletablecell.cc @@ -57,7 +57,7 @@ bool SimpleTableCell::mustBeWidenedToAvailWidth () int SimpleTableCell::getAvailWidthOfChild (Widget *child, bool forceValue) { - DBG_OBJ_ENTER ("resize", 0, "SimpleTableCell/getAvailWidthOfChild", + DBG_OBJ_ENTER ("resize", 0, "SimpleTableCell::getAvailWidthOfChild", "%p, %s", child, forceValue ? "true" : "false"); int width = tablecell::correctAvailWidthOfChild @@ -70,7 +70,7 @@ int SimpleTableCell::getAvailWidthOfChild (Widget *child, bool forceValue) int SimpleTableCell::getAvailHeightOfChild (Widget *child, bool forceValue) { - DBG_OBJ_ENTER ("resize", 0, "SimpleTableCell/getAvailHeightOfChild", + DBG_OBJ_ENTER ("resize", 0, "SimpleTableCell::getAvailHeightOfChild", "%p, %s", child, forceValue ? "true" : "false"); int height = tablecell::correctAvailHeightOfChild @@ -87,7 +87,7 @@ void SimpleTableCell::correctRequisitionOfChild (Widget *child, int*, int*)) { - DBG_OBJ_ENTER ("resize", 0, "SimpleTableCell/correctRequisitionOfChild", + DBG_OBJ_ENTER ("resize", 0, "SimpleTableCell::correctRequisitionOfChild", "%p, %d * (%d + %d), ...", child, requisition->width, requisition->ascent, requisition->descent); @@ -102,7 +102,7 @@ void SimpleTableCell::correctExtremesOfChild (Widget *child, core::Extremes *extremes, bool useAdjustmentWidth) { - DBG_OBJ_ENTER ("resize", 0, "SimpleTableCell/correctExtremesOfChild", + DBG_OBJ_ENTER ("resize", 0, "SimpleTableCell::correctExtremesOfChild", "%p, %d (%d) / %d (%d)", child, extremes->minWidth, extremes->minWidthIntrinsic, extremes->maxWidth, extremes->maxWidthIntrinsic); diff --git a/dw/stackingcontextmgr.cc b/dw/stackingcontextmgr.cc index 5dd49309..00a6d43b 100644 --- a/dw/stackingcontextmgr.cc +++ b/dw/stackingcontextmgr.cc @@ -120,91 +120,36 @@ int StackingContextMgr::findZIndex (int zIndex, bool mustExist) return result; } -void StackingContextMgr::drawBottom (View *view, Rectangle *area, - StackingIteratorStack *iteratorStack, - Widget **interruptedWidget, - int *zIndexIndex, int *index) +void StackingContextMgr::draw (View *view, Rectangle *area, int startZIndex, + int endZIndex, DrawingContext *context) { - DBG_OBJ_ENTER ("draw", 0, "drawBottom", "(%d, %d, %d * %d), [%d], [%d]", - area->x, area->y, area->width, area->height, *zIndexIndex, - *index); - draw (view, area, iteratorStack, interruptedWidget, index, INT_MIN, -1, - zIndexIndex); - DBG_OBJ_LEAVE (); -} - -void StackingContextMgr::drawTop (View *view, Rectangle *area, - StackingIteratorStack *iteratorStack, - Widget **interruptedWidget, - int *zIndexIndex, int *index) -{ - DBG_OBJ_ENTER ("draw", 0, "drawTop", "(%d, %d, %d * %d), [%d], [%d]", - area->x, area->y, area->width, area->height, *zIndexIndex, - *index); - draw (view, area, iteratorStack, interruptedWidget, index, 0, INT_MAX, - zIndexIndex); - DBG_OBJ_LEAVE (); -} - -void StackingContextMgr::draw (View *view, Rectangle *area, - StackingIteratorStack *iteratorStack, - Widget **interruptedWidget, int *zIndexIndex, - int startZIndex, int endZIndex, int *index) -{ - DBG_OBJ_ENTER ("draw", 0, "draw", "(%d, %d, %d * %d), [%d], %d, %d, [%d]", - area->x, area->y, area->width, area->height, - *zIndexIndex, startZIndex, endZIndex, *index); - - DBG_OBJ_MSGF ("draw", 1, "initially: index = %d (of %d)", - *index, childSCWidgets->size ()); + DBG_OBJ_ENTER ("draw", 0, "draw", "[%d, %d, %d * %d], %d, %d", + area->x, area->y, area->width, area->height, startZIndex, + endZIndex); - while (*interruptedWidget == NULL && - *zIndexIndex < numZIndices) { + for (int zIndexIndex = 0; zIndexIndex < numZIndices; zIndexIndex++) { // Wrong region of z-indices (top or bottom) is simply ignored // (as well as non-defined zIndices). - if (zIndices != NULL && zIndices[*zIndexIndex] >= startZIndex && - zIndices[*zIndexIndex] <= endZIndex) { - DBG_OBJ_MSGF ("draw", 1, "drawing zIndex = %d", - zIndices[*zIndexIndex]); + if (zIndices != NULL && zIndices[zIndexIndex] >= startZIndex && + zIndices[zIndexIndex] <= endZIndex) { + DBG_OBJ_MSGF ("draw", 1, "drawing zIndex = %d", zIndices[zIndexIndex]); DBG_OBJ_MSG_START (); - while (*interruptedWidget == NULL && - *index < childSCWidgets->size ()) { - Widget *child = childSCWidgets->get (*index); + for (int i = 0; i < childSCWidgets->size (); i++) { + Widget *child = childSCWidgets->get (i); DBG_OBJ_MSGF ("draw", 2, "widget %p has zIndex = %d", child, child->getStyle()->zIndex); - Rectangle parentArea, childArea; - - // This is a hack: since "area" is given in widget coordinates, - // but the calling widget is not necessary the parent, as - // Widget::interects assumes, "area" has to be corrected. - parentArea = *area; - area->x += widget->getAllocation()->x - - child->getParent()->getAllocation()->x; - area->y += widget->getAllocation()->y - - child->getParent()->getAllocation()->y; - - if (child->getStyle()->zIndex == zIndices[*zIndexIndex] && - child->intersects (&parentArea, &childArea)) - child->drawTotal (view, &childArea, iteratorStack, - interruptedWidget); - if (*interruptedWidget == NULL) - (*index)++; + Rectangle childArea; + if (child->getStyle()->zIndex == zIndices[zIndexIndex] && + child->intersects (widget, area, &childArea)) + child->draw (view, &childArea, context); } DBG_OBJ_MSG_END (); } - - if (*interruptedWidget == NULL) { - (*zIndexIndex)++; - *index = 0; - } } - DBG_OBJ_MSGF ("draw", 1, "finally: index = %d (of %d)", - *index, childSCWidgets->size ()); - DBG_OBJ_MSGF ("draw", 1, "=> %p", *interruptedWidget); DBG_OBJ_LEAVE (); } diff --git a/dw/stackingcontextmgr.hh b/dw/stackingcontextmgr.hh index 4fb0368d..3836d98d 100644 --- a/dw/stackingcontextmgr.hh +++ b/dw/stackingcontextmgr.hh @@ -24,9 +24,8 @@ private: int *zIndices, numZIndices; int findZIndex (int zIndex, bool mustExist); - void draw (View *view, Rectangle *area, - StackingIteratorStack *iteratorStack, Widget **interruptedWidget, - int *zIndexIndex, int startZIndex, int endZIndex, int *index); + void draw (View *view, Rectangle *area, int startZIndex, int endZIndex, + DrawingContext *context); Widget *getWidgetAtPoint (int x, int y, StackingIteratorStack *iteratorStack, Widget **interruptedWidget, int *zIndexIndex, int startZIndex, int endZIndex, int *index); @@ -53,12 +52,10 @@ public: inline int getNumZIndices () { return numZIndices; } inline int getNumChildSCWidgets () { return childSCWidgets->size (); } - void drawBottom (View *view, Rectangle *area, - StackingIteratorStack *iteratorStack, - Widget **interruptedWidget, int *zIndexIndex, int *index); - void drawTop (View *view, Rectangle *area, - StackingIteratorStack *iteratorStack, - Widget **interruptedWidget, int *zIndexIndex, int *index); + inline void drawBottom (View *view, Rectangle *area, DrawingContext *context) + { draw (view, area, INT_MIN, -1, context); } + void drawTop (View *view, Rectangle *area, DrawingContext *context) + { draw (view, area, 0, INT_MAX, context); } Widget *getTopWidgetAtPoint (int x, int y, core::StackingIteratorStack *iteratorStack, diff --git a/dw/table.cc b/dw/table.cc index dc112ef8..5570c853 100644 --- a/dw/table.cc +++ b/dw/table.cc @@ -368,13 +368,12 @@ bool Table::isBlockLevel () return true; } -void Table::drawLevel (core::View *view, core::Rectangle *area, - core::StackingIteratorStack *iteratorStack, - Widget **interruptedWidget, int majorLevel) + void Table::drawLevel (core::View *view, core::Rectangle *area, int level, + core::DrawingContext *context) { - DBG_OBJ_ENTER ("draw", 0, "Table/drawLevel", "(%d, %d, %d * %d), %s", + DBG_OBJ_ENTER ("draw", 0, "Table::drawLevel", "[%d, %d, %d * %d], %s", area->x, area->y, area->width, area->height, - OOFStackingIterator::majorLevelText (majorLevel)); + OOFStackingIterator::majorLevelText (level)); #if 0 // This old code belongs perhaps to the background. Check when reactivated. @@ -394,36 +393,24 @@ void Table::drawLevel (core::View *view, core::Rectangle *area, } #endif - switch (majorLevel) { + switch (level) { case OOFStackingIterator::IN_FLOW: - { - OOFStackingIterator *osi = - (OOFStackingIterator*)iteratorStack->getTop (); - - while (*interruptedWidget == NULL && osi->index < children->size ()) { - if (childDefined (osi->index)) { - Widget *child = children->get(osi->index)->cell.widget; - core::Rectangle childArea; - if (!core::StackingContextMgr::handledByStackingContextMgr - (child) - && child->intersects (area, &childArea)) - child->drawTotal (view, &childArea, iteratorStack, - interruptedWidget); - } - - if (*interruptedWidget == NULL) - osi->index++; + for (int i = 0; i < children->size (); i++) { + if (childDefined (i)) { + Widget *child = children->get(i)->cell.widget; + core::Rectangle childArea; + if (!core::StackingContextMgr::handledByStackingContextMgr (child) + && child->intersects (this, area, &childArea)) + child->draw (view, &childArea, context); } } break; default: - OOFAwareWidget::drawLevel (view, area, iteratorStack, interruptedWidget, - majorLevel); + OOFAwareWidget::drawLevel (view, area, level, context); break; } - DBG_OBJ_MSGF ("draw", 1, "=> %p", *interruptedWidget); DBG_OBJ_LEAVE (); } @@ -433,7 +420,7 @@ core::Widget *Table::getWidgetAtPointLevel (int x, int y, Widget **interruptedWidget, int majorLevel) { - DBG_OBJ_ENTER ("events", 0, "Table/getWidgetAtPointLevel", "%d, %d, %s", + DBG_OBJ_ENTER ("events", 0, "Table::getWidgetAtPointLevel", "%d, %d, %s", x, y, OOFStackingIterator::majorLevelText (majorLevel)); Widget *widgetAtPoint = NULL; diff --git a/dw/table.hh b/dw/table.hh index 1a12cb60..23298ac2 100644 --- a/dw/table.hh +++ b/dw/table.hh @@ -474,9 +474,8 @@ protected: bool isBlockLevel (); - void drawLevel (core::View *view, core::Rectangle *area, - core::StackingIteratorStack *iteratorStack, - Widget **interruptedWidget, int majorLevel); + void drawLevel (core::View *view, core::Rectangle *area, int level, + core::DrawingContext *context); Widget *getWidgetAtPointLevel (int x, int y, core::StackingIteratorStack *iteratorStack, diff --git a/dw/tablecell.cc b/dw/tablecell.cc index 3e143c96..a7b16776 100644 --- a/dw/tablecell.cc +++ b/dw/tablecell.cc @@ -45,7 +45,7 @@ bool isBlockLevel () int correctAvailWidthOfChild (core::Widget *widget, core::Widget *child, int width, bool forceValue) { - DBG_OBJ_ENTER_O ("resize", 0, widget, "tablecell/correctAvailWidthOfChild", + DBG_OBJ_ENTER_O ("resize", 0, widget, "tablecell::correctAvailWidthOfChild", "%p, %d, %s", child, width, forceValue ? "true" : "false"); // Make sure that this width does not exceed the width of the table @@ -80,7 +80,7 @@ void correctCorrectedRequisitionOfChild (core::Widget *widget, void (*splitHeightFun) (int, int*, int*)) { - DBG_OBJ_ENTER_O ("resize", 0, widget, "tablecell/correctRequisitionOfChild", + DBG_OBJ_ENTER_O ("resize", 0, widget, "tablecell::correctRequisitionOfChild", "%p, %d * (%d + %d), ...", child, requisition->width, requisition->ascent, requisition->descent); diff --git a/dw/textblock.cc b/dw/textblock.cc index 00968c61..754d278c 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -743,7 +743,7 @@ void Textblock::calcExtraSpaceImpl () int Textblock::getAvailWidthOfChild (Widget *child, bool forceValue) { - DBG_OBJ_ENTER ("resize", 0, "Textblock/getAvailWidthOfChild", "%p, %s", + DBG_OBJ_ENTER ("resize", 0, "Textblock::getAvailWidthOfChild", "%p, %s", child, forceValue ? "true" : "false"); int width; @@ -1462,14 +1462,11 @@ void Textblock::drawSpace(int wordIndex, core::View *view, * - event is only used when is_expose */ void Textblock::drawLine (Line *line, core::View *view, core::Rectangle *area, - core::StackingIteratorStack *iteratorStack, - Widget **interruptedWidget) + core::DrawingContext *context) { - DBG_OBJ_ENTER ("draw", 0, "drawLine", "..., %d, %d, %d * %d", + DBG_OBJ_ENTER ("draw", 0, "drawLine", "..., [%d, %d, %d * %d]", area->x, area->y, area->width, area->height); - OOFStackingIterator *osi = (OOFStackingIterator*)iteratorStack->getTop (); - int xWidget = line->textOffset; int yWidgetBase = lineYOffsetWidget (line) + line->borderAscent; @@ -1479,12 +1476,14 @@ void Textblock::drawLine (Line *line, core::View *view, core::Rectangle *area, DBG_MSG_WORD ("draw", 1, "<i>line starts with: </i>", line->firstWord, ""); DBG_MSG_WORD ("draw", 1, "<i>line ends with: </i>", line->lastWord, ""); - if (osi->index < line->firstWord) - osi->index = line->firstWord; + DBG_OBJ_MSG_START (); + + for (int wordIndex = line->firstWord; + wordIndex <= line->lastWord && xWidget < area->x + area->width; + wordIndex++) { + DBG_MSG_WORD ("draw", 2, "<i>drawing: </i>", wordIndex, ""); - while (*interruptedWidget == NULL && osi->index <= line->lastWord - && xWidget < area->x + area->width) { - Word *word = words->getRef (osi->index); + Word *word = words->getRef (wordIndex); int wordSize = word->size.width; if (xWidget + wordSize + word->hyphenWidth + word->effSpace >= area->x) { @@ -1497,49 +1496,46 @@ void Textblock::drawLine (Line *line, core::View *view, core::Rectangle *area, core::Rectangle childArea; if (!core::StackingContextMgr::handledByStackingContextMgr (child) && - child->intersects (area, &childArea)) - child->drawTotal (view, &childArea, iteratorStack, - interruptedWidget); + child->intersects (this, area, &childArea)) + child->draw (view, &childArea, context); } else { - int wordIndex2 = osi->index; + int wordIndex2 = wordIndex; while (wordIndex2 < line->lastWord && (words->getRef(wordIndex2)->flags & Word::DRAW_AS_ONE_TEXT) && word->style == words->getRef(wordIndex2 + 1)->style) wordIndex2++; - drawWord(line, osi->index, wordIndex2, view, area, + drawWord(line, wordIndex, wordIndex2, view, area, xWidget, yWidgetBase); wordSize = 0; - for (int i = osi->index; i <= wordIndex2; i++) + for (int i = wordIndex; i <= wordIndex2; i++) wordSize += words->getRef(i)->size.width; - osi->index = wordIndex2; - word = words->getRef (osi->index); + wordIndex = wordIndex2; + word = words->getRef(wordIndex); } } - if (word->effSpace > 0 && osi->index < line->lastWord && - words->getRef(osi->index + 1)->content.type != + if (word->effSpace > 0 && wordIndex < line->lastWord && + words->getRef(wordIndex + 1)->content.type != core::Content::BREAK) { if (word->spaceStyle->hasBackground ()) drawBox (view, word->spaceStyle, area, xWidget + wordSize, yWidgetBase - line->borderAscent, word->effSpace, line->borderAscent + line->borderDescent, false); - drawSpace (osi->index, view, area, xWidget + wordSize, + drawSpace (wordIndex, view, area, xWidget + wordSize, yWidgetBase); } } } xWidget += wordSize + word->effSpace; - - if (*interruptedWidget == NULL) - osi->index++; } - DBG_OBJ_MSGF ("draw", 1, "=> %p", *interruptedWidget); + DBG_OBJ_MSG_END (); + DBG_OBJ_LEAVE (); } @@ -1708,54 +1704,59 @@ Textblock::Word *Textblock::findWord (int x, int y, bool *inSpace) return NULL; } -void Textblock::drawLevel (core::View *view, core::Rectangle *area, - core::StackingIteratorStack *iteratorStack, - Widget **interruptedWidget, int majorLevel) +void Textblock::drawLevel (core::View *view, core::Rectangle *area, int level, + core::DrawingContext *context) { - DBG_OBJ_ENTER ("draw", 0, "Textblock/drawLevel", "(%d, %d, %d * %d), %s", + DBG_OBJ_ENTER ("draw", 0, "Textblock::drawLevel", "(%d, %d, %d * %d), %s", area->x, area->y, area->width, area->height, - OOFStackingIterator::majorLevelText (majorLevel)); + OOFStackingIterator::majorLevelText (level)); - switch (majorLevel) { + switch (level) { case OOFStackingIterator::IN_FLOW: - // Osi->index (word index) is regarded in drawLine. for (int lineIndex = findLineIndexWhenAllocated (area->y); - *interruptedWidget == NULL && lineIndex < lines->size (); - lineIndex++) { + lineIndex < lines->size (); lineIndex++) { Line *line = lines->getRef (lineIndex); if (lineYOffsetWidget (line) >= area->y + area->height) break; - + DBG_OBJ_MSGF ("draw", 0, "line %d (of %d)", lineIndex, lines->size ()); - drawLine (line, view, area, iteratorStack, interruptedWidget); + drawLine (line, view, area, context); } break; case OOFStackingIterator::OOF_REF: - handleOOFReferences (iteratorStack, interruptedWidget, false); + // TODO Inefficient. Perhaps store OOF references in seperate + // (much smaller!) list. + for (int oofmIndex = 0; oofmIndex < NUM_OOFM; oofmIndex++) { + for (int wordIndex = 0; wordIndex < words->size (); wordIndex++) { + Word *word = words->getRef (wordIndex); + if (word->content.type == core::Content::WIDGET_OOF_REF && + getOOFMIndex (word->content.widget) == oofmIndex && + doesWidgetOOFInterruptDrawing (word->content.widget)) + word->content.widget->drawInterruption (view, area, context); + } + } break; default: - OOFAwareWidget::drawLevel (view, area, iteratorStack, interruptedWidget, - majorLevel); + OOFAwareWidget::drawLevel (view, area, level, context); break; } - DBG_OBJ_MSGF ("draw", 1, "=> %p", *interruptedWidget); DBG_OBJ_LEAVE (); } /** - * \brief Used both for drawing and getting the widget at a point, - * since this method only interrupts, but does not do actual - * drawing or searching, respectively. + * \brief Used for getting the widget at a point, since this method + * only interrupts, but does not do actual drawing or searching, + * respectively. Will be changed soon. */ void Textblock::handleOOFReferences (core::StackingIteratorStack *iteratorStack, Widget **interruptedWidget, bool backwards) { // TODO Inefficient. Store Widgets OOF references in seperate list? - DBG_OBJ_ENTER ("common", 0, "Textblock/handleOOFReferences", "..., %s", + DBG_OBJ_ENTER ("common", 0, "Textblock::handleOOFReferences", "..., %s", backwards ? "true [backwards]" : "false [forwards]"); OOFStackingIterator *osi = (OOFStackingIterator*)iteratorStack->getTop (); @@ -2759,7 +2760,7 @@ core::Widget *Textblock::getWidgetAtPointLevel (int x, int y, Widget **interruptedWidget, int majorLevel) { - DBG_OBJ_ENTER ("events", 0, "Textblock/getWidgetAtPointLevel", "%d, %d, %s", + DBG_OBJ_ENTER ("events", 0, "Textblock::getWidgetAtPointLevel", "%d, %d, %s", x, y, OOFStackingIterator::majorLevelText (majorLevel)); Widget *widgetAtPoint = NULL; diff --git a/dw/textblock.hh b/dw/textblock.hh index 143cede3..cc18cdab 100644 --- a/dw/textblock.hh +++ b/dw/textblock.hh @@ -650,8 +650,7 @@ protected: void drawSpace (int wordIndex, core::View *view, core::Rectangle *area, int xWidget, int yWidgetBase); void drawLine (Line *line, core::View *view, core::Rectangle *area, - core::StackingIteratorStack *iteratorStack, - Widget **interruptedWidget); + core::DrawingContext *context); void handleOOFReferences (core::StackingIteratorStack *iteratorStack, Widget **interruptedWidget, bool backwards); @@ -810,9 +809,8 @@ protected: void alignLine (int lineIndex); void calcTextOffset (int lineIndex, int totalWidth); - void drawLevel (core::View *view, core::Rectangle *area, - core::StackingIteratorStack *iteratorStack, - Widget **interruptedWidget, int majorLevel); + void drawLevel (core::View *view, core::Rectangle *area, int level, + core::DrawingContext *context); Widget *getWidgetAtPointLevel (int x, int y, core::StackingIteratorStack *iteratorStack, diff --git a/dw/textblock_iterator.cc b/dw/textblock_iterator.cc index 95e2ce65..14631eba 100644 --- a/dw/textblock_iterator.cc +++ b/dw/textblock_iterator.cc @@ -59,7 +59,7 @@ object::Object *Textblock::TextblockIterator::clone() void Textblock::TextblockIterator::highlight (int start, int end, core::HighlightLayer layer) { - DBG_OBJ_ENTER_O ("iterator", 0, getWidget (), "TextblockIterator/highlight", + DBG_OBJ_ENTER_O ("iterator", 0, getWidget (), "TextblockIterator::highlight", "..., %d, %d, %d", start, end, layer); DBG_IF_RTFL { diff --git a/dw/types.hh b/dw/types.hh index 87f688aa..0b2d7a0e 100644 --- a/dw/types.hh +++ b/dw/types.hh @@ -237,6 +237,37 @@ struct Content static void printMask (Type mask); }; +class DrawingContext +{ +private: + Rectangle toplevelArea; + lout::container::typed::HashSet<lout::object::TypedPointer<Widget> > + *widgetsDrawnAsInterruption; + +public: + inline DrawingContext (Rectangle *toplevelArea) { + this->toplevelArea = *toplevelArea; + widgetsDrawnAsInterruption = + new lout::container::typed::HashSet<lout::object:: + TypedPointer<Widget> > (true); + } + + inline ~DrawingContext () { delete widgetsDrawnAsInterruption; } + + inline Rectangle *getToplevelArea () { return &toplevelArea; } + + inline bool hasWidgetBeenDrawnAsInterruption (Widget *widget) { + lout::object::TypedPointer<Widget> key (widget); + return widgetsDrawnAsInterruption->contains (&key); + } + + inline void addWidgetDrawnAsInterruption (Widget *widget) { + lout::object::TypedPointer<Widget> *key = + new lout::object::TypedPointer<Widget> (widget); + return widgetsDrawnAsInterruption->put (key); + } +}; + } // namespace core } // namespace dw @@ -131,12 +131,10 @@ void Embed::setEnabled (bool enabled) resource->setEnabled (enabled); } -void Embed::draw (View *view, Rectangle *area, - StackingIteratorStack *iteratorStack, - Widget **interruptedWidget) +void Embed::draw (View *view, Rectangle *area, DrawingContext *context) { drawWidgetBox (view, area, false); - resource->draw (view, area); + resource->draw (view, area, context); } Iterator *Embed::iterator (Content::Type mask, bool atEnd) @@ -268,7 +266,7 @@ void Resource::setDisplayed (bool displayed) { } -void Resource::draw (View *view, Rectangle *area) +void Resource::draw (View *view, Rectangle *area, DrawingContext *context) { } @@ -319,7 +317,7 @@ Iterator *LabelButtonResource::iterator (Content::Type mask, bool atEnd) void ComplexButtonResource::LayoutReceiver::resizeQueued (bool extremesChanged) { - DBG_OBJ_ENTER ("resize", 0, "LayoutReceiver/resizeQueued", "%s", + DBG_OBJ_ENTER ("resize", 0, "LayoutReceiver::resizeQueued", "%s", extremesChanged ? "true" : "false"); resource->queueResize (extremesChanged); DBG_OBJ_LEAVE (); @@ -254,8 +254,7 @@ public: void setDisplayed (bool displayed); void setEnabled (bool enabled); - void draw (View *view, Rectangle *area, StackingIteratorStack *iteratorStack, - Widget **interruptedWidget); + void draw (View *view, Rectangle *area, DrawingContext *context); Iterator *iterator (Content::Type mask, bool atEnd); void setStyle (style::Style *style); @@ -370,7 +369,7 @@ public: virtual void containerSizeChangedForChildren (); virtual void setDisplayed (bool displayed); - virtual void draw (View *view, Rectangle *area); + virtual void draw (View *view, Rectangle *area, DrawingContext *context); virtual Iterator *iterator (Content::Type mask, bool atEnd) = 0; virtual void setStyle (style::Style *style); diff --git a/dw/widget.cc b/dw/widget.cc index 8f93701d..2197e6d1 100644 --- a/dw/widget.cc +++ b/dw/widget.cc @@ -128,134 +128,72 @@ Widget::~Widget () * Typically used by containers when drawing their children. Returns whether * intersection is not empty. */ -bool Widget::intersects (Rectangle *area, Rectangle *intersection) +bool Widget::intersects (Widget *refWidget, Rectangle *area, + Rectangle *intersection) { - DBG_OBJ_ENTER ("draw", 0, "intersects", "%d, %d, %d * %d", - area->x, area->y, area->width, area->height); + DBG_OBJ_ENTER ("draw", 0, "intersects", "%p, [%d, %d, %d * %d]", + refWidget, area->x, area->y, area->width, area->height); bool r; if (wasAllocated ()) { - Rectangle parentArea, childArea; + *intersection = *area; + intersection->x += refWidget->allocation.x; + intersection->y += refWidget->allocation.y; - parentArea = *area; - parentArea.x += parent->allocation.x; - parentArea.y += parent->allocation.y; - - DBG_OBJ_MSGF ("draw", 2, "parentArea: %d, %d, %d * %d", - parentArea.x, parentArea.y, parentArea.width, - parentArea.height); - - childArea.x = allocation.x; - childArea.y = allocation.y; - childArea.width = allocation.width; - childArea.height = getHeight (); - - DBG_OBJ_MSGF ("draw", 2, "childArea: %d, %d, %d * %d", - childArea.x, childArea.y, childArea.width, - childArea.height); - - if (parentArea.intersectsWith (&childArea, intersection)) { - DBG_OBJ_MSGF ("draw", 2, "intersection: %d, %d, %d * %d", - intersection->x, intersection->y, intersection->width, - intersection->height); + r = true; + for (Widget *widget = this; r && widget != refWidget->parent; + widget = widget->parent) { + assert (widget != NULL); // refWidget must be ancestor. + + Rectangle widgetArea, newIntersection; + widgetArea.x = widget->allocation.x; + widgetArea.y = widget->allocation.y; + widgetArea.width = widget->allocation.width; + widgetArea.height = widget->getHeight (); + + if (intersection->intersectsWith (&widgetArea, &newIntersection)) { + DBG_OBJ_MSGF ("draw", 1, "new intersection: %d, %d, %d * %d", + newIntersection.x, newIntersection.y, + newIntersection.width, newIntersection.height); + *intersection = newIntersection; + } else { + DBG_OBJ_MSG ("draw", 1, "no new intersection"); + r = false; + } + } + if (r) { intersection->x -= allocation.x; intersection->y -= allocation.y; - r = true; - DBG_OBJ_MSGF ("draw", 1, "=> %d, %d, %d * %d", - intersection->x, intersection->y, intersection->width, - intersection->height); - } else { - r = false; - DBG_OBJ_MSG ("draw", 1, "=> no intersection"); + DBG_OBJ_MSGF ("draw", 1, "final intersection: %d, %d, %d * %d", + intersection->x, intersection->y, + intersection->width, intersection->height); } } else { r = false; - DBG_OBJ_MSG ("draw", 1, "=> not allocated"); - } - - DBG_OBJ_LEAVE (); - return r; -} - -void Widget::drawTotal (View *view, Rectangle *area, - StackingIteratorStack *iteratorStack, - Widget **interruptedWidget) -{ - DBG_OBJ_ENTER ("draw", 0, "drawTotal", "%d, %d, %d * %d", - area->x, area->y, area->width, area->height); - - DBG_IF_RTFL { - misc::StringBuffer sb; - iteratorStack->intoStringBuffer (&sb); - DBG_OBJ_MSGF ("draw", 2, "initial iteratorStack: %s", sb.getChars ()); - } - - Object *si = NULL; - - if (iteratorStack->atRealTop ()) { - si = stackingIterator (false); - if (si) { - iteratorStack->push (si); - } - } else - iteratorStack->forward (); - - DBG_IF_RTFL { - misc::StringBuffer sb; - iteratorStack->intoStringBuffer (&sb); - DBG_OBJ_MSGF ("draw", 2, "iteratorStack before: %s", - sb.getChars ()); + DBG_OBJ_MSG ("draw", 1, "not allocated"); } - draw (view, area, iteratorStack, interruptedWidget); - DBG_OBJ_MSGF ("draw", 1, "=> %p", *interruptedWidget); - - DBG_IF_RTFL { - misc::StringBuffer sb; - iteratorStack->intoStringBuffer (&sb); - DBG_OBJ_MSGF ("draw", 2, "iteratorStack after: %s", - sb.getChars ()); - } - - // A value for *interruptedWidget other than NULL indicates a - // widget with a complex drawing process, for which - // stackingIterator() must return something non-NULL, so that the - // interrupted drawing process can be continued. (TODO: Not quite - // correct when forward() was called instead of push().) - - // assert (*interruptedWidget == NULL || si != NULL); - - if (*interruptedWidget == NULL) { - if (si) - iteratorStack->pop (); - } else - iteratorStack->backward (); - - DBG_IF_RTFL { - misc::StringBuffer sb; - iteratorStack->intoStringBuffer (&sb); - DBG_OBJ_MSGF ("draw", 2, "final iteratorStack: %s", sb.getChars ()); - } + if (r) + DBG_OBJ_MSGF ("draw", 1, "=> true: %d, %d, %d * %d", + intersection->x, intersection->y, + intersection->width, intersection->height); + else + DBG_OBJ_MSG ("draw", 1, "=> false"); DBG_OBJ_LEAVE (); + return r; } -void Widget::drawToplevel (View *view, Rectangle *area) +void Widget::drawInterruption (View *view, Rectangle *area, + DrawingContext *context) { - assert (parent == NULL); + Rectangle thisArea; + if (intersects (layout->topLevel, context->getToplevelArea (), &thisArea)) + draw (view, &thisArea, context); - StackingIteratorStack iteratorStack; - Widget *interruptedWidget = NULL; - drawTotal (view, area, &iteratorStack, &interruptedWidget); - - // Everything should be finished at this point. - assert (interruptedWidget == NULL); - //if (interruptedWidget != NULL) - // DBG_OBJ_MSGF ("draw", 0, - // "===== Assertion failed: interruptedWidget = %p =====", - // interruptedWidget); + context->addWidgetDrawnAsInterruption (this); } Widget *Widget::getWidgetAtPoint (int x, int y, @@ -738,7 +676,7 @@ int Widget::getMinWidth (Extremes *extremes, bool forceValue) { DBG_IF_RTFL { if (extremes) - DBG_OBJ_ENTER ("resize", 0, "getMinWidth", "[%d (%d) / %d (%d), %s", + DBG_OBJ_ENTER ("resize", 0, "getMinWidth", "[%d (%d) / %d (%d)], %s", extremes->minWidth, extremes->minWidthIntrinsic, extremes->maxWidth, extremes->maxWidthIntrinsic, forceValue ? "true" : "false"); diff --git a/dw/widget.hh b/dw/widget.hh index b1b51201..c8a57250 100644 --- a/dw/widget.hh +++ b/dw/widget.hh @@ -467,16 +467,12 @@ public: void containerSizeChanged (); - bool intersects (Rectangle *area, Rectangle *intersection); + bool intersects (Widget *refWidget, Rectangle *area, + Rectangle *intersection); /** Area is given in widget coordinates. */ - virtual void draw (View *view, Rectangle *area, - StackingIteratorStack *iteratorStack, - Widget **interruptedWidget) = 0; - void drawTotal (View *view, Rectangle *area, - StackingIteratorStack *iteratorStack, - Widget **interruptedWidget); - void drawToplevel (View *view, Rectangle *area); + virtual void draw (View *view, Rectangle *area, DrawingContext *context) = 0; + void drawInterruption (View *view, Rectangle *area, DrawingContext *context); virtual Widget *getWidgetAtPoint (int x, int y, StackingIteratorStack *iteratorStack, |