# HG changeset patch # User Diggory Hardy # Date 1240590953 -3600 # Node ID f132e599043fe3646579fcada7b75c32193418fe # Parent a86f8445ccc8004cdf806f34a1dcb6999accaf10 Re-enabled raising floating widgets, by clicking frame; disabled attempt at immediate language reloading for popup-button widgets. Enabling window raise on hover is simple now (make an option?), clicking on a sub-widget won't raise (bug). diff -r a86f8445ccc8 -r f132e599043f mde/gui/widget/Floating.d --- a/mde/gui/widget/Floating.d Wed Apr 22 10:35:15 2009 +0200 +++ b/mde/gui/widget/Floating.d Fri Apr 24 17:35:53 2009 +0100 @@ -38,6 +38,10 @@ * each sub-widget. */ class FloatingAreaWidget : AParentWidget { + static this () { + raiseOnHover = ; + } + this (IWidgetManager mgr, IParentWidget parent, widgetID id, WidgetData data, IContent content) { if (data.ints.length != 1 + data.strings.length) throw new WidgetDataException (this); @@ -168,31 +172,24 @@ override IChildWidget getWidget (wdim cx, wdim cy) { debug scope (failure) logger.warn ("getWidget: failure; values: click; pos; width: {},{}; {},{}; {},{}", cx, cy, x, y, w, h); - debug assert (cx >= x && cx < x + w && cy >= y && cy < y + h, "getWidget: not on widget (code error)"); - foreach_reverse (j,i; sWOrder) with (sWData[i]) { + size_t event = getFloatingWidget (cx,cy, raiseOnHover); + if (event > sWData.length) + return this; // no match + + with (sWData[event]) { wdim lx = cx - (this.x + x); wdim ly = cy - (this.y + y); - if (lx >= 0 && lx < w && - ly >= 0 && ly < h) - { - /+ code to raise widget - sWOrder[j..$-1] = sWOrder[j+1..$].dup; - sWOrder[$-1] = i; - mgr.requestRedraw; +/ - if (lx >= border.x1 && lx < w-border.x2 && - ly >= border.y1 && ly < h-border.y2) - return subWidgets[i].getWidget (cx,cy); - event = i; - return this; - } + if (lx >= border.x1 && lx < w-border.x2 && + ly >= border.y1 && ly < h-border.y2) + return subWidgets[event].getWidget (cx,cy); + return this; } - event = size_t.max; - return this; // no match } override int clickEvent (wdabs cx, wdabs cy, ubyte b, bool state) { - if (event > subWidgets.length) return 0; + size_t event = getFloatingWidget (cx,cy, true); + if (event > subWidgets.length) return 0; if (b == 1 && state == true) { active = event; with (sWData[active]) { @@ -226,6 +223,30 @@ } protected: + /** Return the index of the floating object under (cx,cy). If no widget is, + * return size_t.max. + * + * Params: + * raiseWidget = if true, the widget returned is raised to be the top- + * most floating widget. */ + size_t getFloatingWidget (wdim cx, wdim cy, bool raiseWidget = false) { + debug assert (cx >= x && cx < x + w && cy >= y && cy < y + h, "getWidget: not on widget (code error)"); + + foreach_reverse (j,i; sWOrder) with (sWData[i]) { + wdim lx = cx - (this.x + x); + wdim ly = cy - (this.y + y); + if (lx >= 0 && lx < w && ly >= 0 && ly < h) { + if (raiseWidget) { + sWOrder[j..$-1] = sWOrder[j+1..$].dup; + sWOrder[$-1] = i; + mgr.requestRedraw; + } + return i; + } + } + return size_t.max; // no match + } + void moveCallback (wdabs cx, wdabs cy) { with (sWData[active]) { x = cx-xDrag; @@ -309,8 +330,9 @@ // Click/drag information: alias IRenderer.Border.BTYPE BTYPE; alias IRenderer.Border.RESIZE RESIZE; - size_t event = size_t.max; // Border with last click/release: size_t.max: main area (no subwidget), i: subwidget[i] - size_t active = size_t.max; // Like event, but refers to widget being moved/resized + size_t active = size_t.max; // refers to widget being moved/resized wdim xDrag, yDrag; // where a drag starts relative to x and y RESIZE resizeType; // Type of current resize + + static BoolContent raiseOnHover; } diff -r a86f8445ccc8 -r f132e599043f mde/gui/widget/ParentContent.d --- a/mde/gui/widget/ParentContent.d Wed Apr 22 10:35:15 2009 +0200 +++ b/mde/gui/widget/ParentContent.d Fri Apr 24 17:35:53 2009 +0100 @@ -61,7 +61,19 @@ w = mw; h = mh; } - + /+ + override bool setup (uint n, uint flags) { + if (!(flags & 3)) return false; // string or renderer (and possibly font) changed + wdim omw = mw, omh = mh; + adapter.getDimensions (mw, mh); + if (omw != mw || omh != mh) { + w = mw; + h = mh; + return true; + } + return false; + } + +/ override IContent content () { return content_; } @@ -113,6 +125,7 @@ if (omh != mh) parent.minHChange (this, mh); } + bool pushed = false; IRenderer.TextAdapter adapter; Content content_;