From e497d315b87a42184dce3f9b90e495b3a3806b14 Mon Sep 17 00:00:00 2001 From: Sebastian Geerken Date: Fri, 23 Jan 2015 21:28:59 +0100 Subject: StackingProcessingContext, GettingWidgetAtPointContext. --- dw/ooffloatsmgr.cc | 2 +- dw/oofpositionedmgr.cc | 2 +- dw/types.hh | 55 +++++++++++++++++++++++++++++++++++++------------- dw/widget.cc | 2 +- 4 files changed, 44 insertions(+), 17 deletions(-) diff --git a/dw/ooffloatsmgr.cc b/dw/ooffloatsmgr.cc index f9e7b0d0..5f0d9eff 100644 --- a/dw/ooffloatsmgr.cc +++ b/dw/ooffloatsmgr.cc @@ -1315,7 +1315,7 @@ void OOFFloatsMgr::drawFloats (SortedFloatsVector *list, View *view, Widget *childWidget = vloat->getWidget (); Rectangle childArea; - if (!context->hasWidgetBeenDrawnAsInterruption (childWidget) && + if (!context->hasWidgetBeenProcessedAsInterruption (childWidget) && !StackingContextMgr::handledByStackingContextMgr (childWidget) && childWidget->intersects (container, area, &childArea)) childWidget->draw (view, &childArea, context); diff --git a/dw/oofpositionedmgr.cc b/dw/oofpositionedmgr.cc index 28d5aac7..10c48b1e 100644 --- a/dw/oofpositionedmgr.cc +++ b/dw/oofpositionedmgr.cc @@ -225,7 +225,7 @@ void OOFPositionedMgr::draw (View *view, Rectangle *area, Child *child = children->get(i); Rectangle childArea; - if (!context->hasWidgetBeenDrawnAsInterruption (child->widget) && + if (!context->hasWidgetBeenProcessedAsInterruption (child->widget) && !StackingContextMgr::handledByStackingContextMgr (child->widget) && child->widget->intersects (container, area, &childArea)) child->widget->draw (view, &childArea, context); diff --git a/dw/types.hh b/dw/types.hh index c68ad781..481f4804 100644 --- a/dw/types.hh +++ b/dw/types.hh @@ -238,37 +238,64 @@ struct Content }; /** - * Set at the top when drawing. See \ref dw-interrupted-drawing for details. + * \brief Base class for dw::core::DrawingContext and + * dw::core::GettingWidgetAtPointContext. + * + * Not to be confused with the *stacking context* as defined by CSS. */ -class DrawingContext +class StackingProcessingContext { private: - Rectangle toplevelArea; lout::container::typed::HashSet > - *widgetsDrawnAsInterruption; + *widgetsProcessedAsInterruption; public: - inline DrawingContext (Rectangle *toplevelArea) { - this->toplevelArea = *toplevelArea; - widgetsDrawnAsInterruption = + inline StackingProcessingContext () { + widgetsProcessedAsInterruption = new lout::container::typed::HashSet > (true); } - inline ~DrawingContext () { delete widgetsDrawnAsInterruption; } + inline ~StackingProcessingContext () + { delete widgetsProcessedAsInterruption; } - inline Rectangle *getToplevelArea () { return &toplevelArea; } - - inline bool hasWidgetBeenDrawnAsInterruption (Widget *widget) { + inline bool hasWidgetBeenProcessedAsInterruption (Widget *widget) { lout::object::TypedPointer key (widget); - return widgetsDrawnAsInterruption->contains (&key); + return widgetsProcessedAsInterruption->contains (&key); } - inline void addWidgetDrawnAsInterruption (Widget *widget) { + inline void addWidgetProcessedAsInterruption (Widget *widget) { lout::object::TypedPointer *key = new lout::object::TypedPointer (widget); - return widgetsDrawnAsInterruption->put (key); + return widgetsProcessedAsInterruption->put (key); + } +}; + +/** + * \brief Set at the top when drawing. + * + * See \ref dw-interrupted-drawing for details. + */ +class DrawingContext: public StackingProcessingContext +{ +private: + Rectangle toplevelArea; + +public: + inline DrawingContext (Rectangle *toplevelArea) { + this->toplevelArea = *toplevelArea; } + + inline Rectangle *getToplevelArea () { return &toplevelArea; } +}; + +/** + * \brief Set at the top when getting the widget at the point. + * + * Similar to dw::core::DrawingContext. + */ +class GettingWidgetAtPointContext: public StackingProcessingContext +{ }; } // namespace core diff --git a/dw/widget.cc b/dw/widget.cc index 9188f997..00ce8d97 100644 --- a/dw/widget.cc +++ b/dw/widget.cc @@ -200,7 +200,7 @@ void Widget::drawInterruption (View *view, Rectangle *area, if (intersects (layout->topLevel, context->getToplevelArea (), &thisArea)) draw (view, &thisArea, context); - context->addWidgetDrawnAsInterruption (this); + context->addWidgetProcessedAsInterruption (this); } Widget *Widget::getWidgetAtPoint (int x, int y, -- cgit v1.2.3