X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FGUI%2Fdialog.cxx;h=6d3c7c7cb2c5c7354faa75f456bb8d67bf1fa0ec;hb=09d4176e963be04dec40943083e369081b8f7a18;hp=3750d8b86cde49f1eb068b79e3d4dc54a87c2585;hpb=2aaa1803d3d4d01ef6036561fb1338a0402751f2;p=flightgear.git diff --git a/src/GUI/dialog.cxx b/src/GUI/dialog.cxx index 3750d8b86..6d3c7c7cb 100644 --- a/src/GUI/dialog.cxx +++ b/src/GUI/dialog.cxx @@ -8,6 +8,42 @@ #include "puList.hxx" #include "AirportList.hxx" +int fgPopup::checkHit(int button, int updown, int x, int y) +{ + int result = puPopup::checkHit(button, updown, x, y); + + // This is annoying. We would really want a true result from the + // superclass to indicate "handled by child object", but all it + // tells us is that the pointer is inside the dialog. So do the + // intersection test (again) to make sure we don't start a drag + // when inside controls. A further weirdness: plib inserts a + // "ghost" child which covers the whole control. (?) Skip it. + if(!result) return result; + puObject* child = getFirstChild(); + if(child) child = child->getNextObject(); + while(child) { + int cx, cy, cw, ch; + child->getAbsolutePosition(&cx, &cy); + child->getSize(&cw, &ch); + if(x >= cx && x < cx + cw && y >= cy && y < cy + ch) + return result; + child = child->getNextObject(); + } + + // Finally, handle the mouse event + if(updown == PU_DOWN) { + int px, py; + getPosition(&px, &py); + _dragging = true; + _dX = px - x; + _dY = py - y; + } else if(updown == PU_DRAG && _dragging) { + setPosition(x + _dX, y + _dY); + } else { + _dragging = false; + } + return 1; +} //////////////////////////////////////////////////////////////////////// @@ -230,7 +266,7 @@ FGDialog::makeObject (SGPropertyNode * props, int parentWidth, int parentHeight) if (props->getBoolValue("modal", false)) dialog = new puDialogBox(x, y); else - dialog = new puPopup(x, y); + dialog = new fgPopup(x, y); setupGroup(dialog, props, width, height, true); return dialog; } else if (type == "group") {