diff options
-rw-r--r-- | dw/outofflowmgr.cc | 21 | ||||
-rw-r--r-- | dw/outofflowmgr.hh | 3 | ||||
-rw-r--r-- | dw/textblock.cc | 12 | ||||
-rw-r--r-- | dw/widget.cc | 10 |
4 files changed, 40 insertions, 6 deletions
diff --git a/dw/outofflowmgr.cc b/dw/outofflowmgr.cc index 731c3905..3168cab6 100644 --- a/dw/outofflowmgr.cc +++ b/dw/outofflowmgr.cc @@ -207,6 +207,27 @@ void OutOfFlowMgr::markExtremesChange (int ref) { } +Widget *OutOfFlowMgr::getWidgetAtPoint (int x, int y, int level) +{ + Widget *childAtPoint = getWidgetAtPoint (leftFloats, x, y, level); + if (childAtPoint == NULL) + childAtPoint = getWidgetAtPoint (rightFloats, x, y, level); + return childAtPoint; +} + +Widget *OutOfFlowMgr::getWidgetAtPoint (Vector<Float> *list, + int x, int y, int level) +{ + for (int i = 0; i < list->size(); i++) { + Float *vloat = list->get(i); + Widget *childAtPoint = vloat->widget->getWidgetAtPoint (x, y, level + 1); + if (childAtPoint) + return childAtPoint; + } + + return NULL; +} + void OutOfFlowMgr::tellNoPosition (Widget *widget) { diff --git a/dw/outofflowmgr.hh b/dw/outofflowmgr.hh index bce2d651..98750d57 100644 --- a/dw/outofflowmgr.hh +++ b/dw/outofflowmgr.hh @@ -45,6 +45,8 @@ private: void draw (lout::container::typed::Vector<Float> *list, core::View *view, core::Rectangle *area); + core::Widget *getWidgetAtPoint (lout::container::typed::Vector<Float> *list, + int x, int y, int level); inline static bool isRefFloat (int ref) { return ref != -1 && (ref & 1) == 1; } @@ -71,6 +73,7 @@ public: void markSizeChange (int ref); void markExtremesChange (int ref); + core::Widget *getWidgetAtPoint (int x, int y, int level); static bool isWidgetOutOfFlow (core::Widget *widget); void addWidget (core::Widget *widget, core::Widget *generatingBlock); diff --git a/dw/textblock.cc b/dw/textblock.cc index 2ed05b1d..fd743c21 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -2128,6 +2128,10 @@ void Textblock::addLinebreak (core::style::Style *style) */ core::Widget *Textblock::getWidgetAtPoint(int x, int y, int level) { + //printf ("%*s-> examining the %s %p (%d, %d, %d x (%d + %d))\n", + // 3 * level, "", getClassName (), this, allocation.x, allocation.y, + // allocation.width, allocation.ascent, allocation.descent); + int lineIndex, wordIndex; Line *line; @@ -2138,6 +2142,14 @@ core::Widget *Textblock::getWidgetAtPoint(int x, int y, int level) return NULL; } + // First, search for widgets out of flow, notably floats, since + // there are cases where they overlap child textblocks. Should + // later be refined using z-index. + Widget *oofWidget = + outOfFlowMgr ? outOfFlowMgr->getWidgetAtPoint (x, y, level) : NULL; + if (oofWidget) + return oofWidget; + lineIndex = findLineIndex (y - allocation.y); if (lineIndex < 0 || lineIndex >= lines->size ()) { diff --git a/dw/widget.cc b/dw/widget.cc index 7d9f0bbc..4018c069 100644 --- a/dw/widget.cc +++ b/dw/widget.cc @@ -108,7 +108,7 @@ void Widget::setParent (Widget *parent) if (!buttonSensitiveSet) buttonSensitive = parent->buttonSensitive; - notifySetParent(); + notifySetParent(); //DBG_OBJ_ASSOC (widget, parent); //printf ("The %s %p becomes a child of the %s %p\n", @@ -513,11 +513,9 @@ Widget *Widget::getWidgetAtPoint (int x, int y, int level) Iterator *it; Widget *childAtPoint; - //_MSG ("%*s-> examining the %s %p (%d, %d, %d x (%d + %d))\n", - // 3 * level, "", gtk_type_name (GTK_OBJECT_TYPE (widget)), widget, - // allocation.x, allocation.y, - // allocation.width, allocation.ascent, - // allocation.descent); + //printf ("%*s-> examining the %s %p (%d, %d, %d x (%d + %d))\n", + // 3 * level, "", getClassName (), this, allocation.x, allocation.y, + // allocation.width, allocation.ascent, allocation.descent); if (x >= allocation.x && y >= allocation.y && |