Mercurial > projects > mde
diff mde/gui/WidgetManager.d @ 166:55667d048c31
Made content displayable while being dragged.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Sun, 21 Jun 2009 12:19:18 +0200 |
parents | bb2f1a76346d |
children | 620d4ea30228 |
line wrap: on
line diff
--- a/mde/gui/WidgetManager.d Sun Jun 07 16:20:16 2009 +0200 +++ b/mde/gui/WidgetManager.d Sun Jun 21 12:19:18 2009 +0200 @@ -85,7 +85,9 @@ final void recursionCheck (widgetID, IContent) {} override void minWChange (IChildWidget widget, wdim nmw) { - debug assert (widget is child, "WM.mSC (code error)"); + if (widget !is child) // Usually because widget is a floating widget + // This may get called from a CTOR, hence we can't check widget is one of popupContext, etc. + return; mw = nmw; if (w < nmw) { child.setWidth (nmw, -1); @@ -95,7 +97,8 @@ requestRedraw; } override void minHChange (IChildWidget widget, wdim nmh) { - debug assert (widget is child, "WM.mSC (code error)"); + if (widget !is child) + return; mh = nmh; if (h < nmh) { child.setHeight (nmh, -1); @@ -171,6 +174,8 @@ override void drawPopup () { if (popupContext) popupContext.draw(); + if (dragContentDisplay) + dragContentDisplay.draw(); } debug protected override bool isChild (IPopupParentWidget ippw) { @@ -205,7 +210,7 @@ logger.error ("Error creating widget: {}; creating a debug widget instead.", e.msg); } - return new DebugWidget (this, this, id, data, content); + return new DebugWidget (this, parent, id, data, content); } override WidgetData widgetData (widgetID id) { @@ -299,11 +304,12 @@ // end of a drag? if (dragStart !is null && b == dragButton && state == false) { - if (dragStart.dragRelease (cx, cy, underMouse)) { - dragStart = null; + IChildWidget dS = dragStart; + dragStart = null; + dragContentDisplay = null; + requestRedraw; + if (dS.dragRelease (cx, cy, underMouse)) return; - } - dragStart = null; } // Disable keyboard input if on another widget: @@ -331,6 +337,16 @@ if (ret & 2 && dragStart is null) { // drag events requested dragStart = underMouse; dragButton = b; // currently we allow any button to be used for a drag, but.. ? + if (ret & 4) { + IContent c = underMouse.content(); + if (c) { // NOTE: creates a new widget, not optimal + dragContentDisplay = new DisplayContentWidget (this, this, "dragContentDisplay", WidgetData ([0], []), c); + dragContentDisplay.setup (0, 3); + dragX = underMouse.xPos - cx; + dragY = underMouse.yPos - cy; + dragContentDisplay.setPosition (cx + dragX, cy + dragY); + } + } } } } @@ -341,8 +357,13 @@ void wmMouseMotion (wdabs cx, wdabs cy) { updateUnderMouse (cx, cy, false); - if (dragStart !is null) + if (dragStart !is null) { dragStart.dragMotion (cx, cy, underMouse); + if (dragContentDisplay !is null) { + dragContentDisplay.setPosition (cx + dragX, cy + dragY); + requestRedraw; + } + } } @@ -503,9 +524,12 @@ // Popup(s) handled directly by AWidgetManager: IChildWidget popupContext; // context menu (active if not null) + IChildWidget dragContentDisplay; // displays dragged content; no interaction IChildWidget dragStart; // if non-null, this widget should receive motion and click-release events int dragButton; // index of button in use for drag + wdrel dragX, dragY; // coordinates of dragged content relative to mouse + IChildWidget keyFocus; // widget receiving keyboard input IChildWidget underMouse; // widget under the mouse pointer