# HG changeset patch # User Diggory Hardy # Date 1245579558 -7200 # Node ID 55667d048c31554e804adb4c3e282234e5d6fa70 # Parent bb2f1a76346d5082b792c82d3023eb70922fb0a2 Made content displayable while being dragged. diff -r bb2f1a76346d -r 55667d048c31 codeDoc/ideas.txt --- a/codeDoc/ideas.txt Sun Jun 07 16:20:16 2009 +0200 +++ b/codeDoc/ideas.txt Sun Jun 21 12:19:18 2009 +0200 @@ -41,8 +41,10 @@ -> Use the same renderer & manager: -> Make all widgets draw a back? -> bad for transparancy and performance - -> Force first widget to draw a back + -> Make only first widget draw a back -> extra parameter to pass in special cases + ?> Transparency? + +> Simple to implement > Use a sub-renderer -> extra parameter to pass -> or some kind of lookup by mgr diff -r bb2f1a76346d -r 55667d048c31 codeDoc/jobs.txt --- a/codeDoc/jobs.txt Sun Jun 07 16:20:16 2009 +0200 +++ b/codeDoc/jobs.txt Sun Jun 21 12:19:18 2009 +0200 @@ -8,13 +8,16 @@ To do (importance 0-5: 0 pointless, 1 no obvious impact now, 2 todo sometime, 3 useful, 4 important, 5 urgent): Also search for FIXME/NOTE/BUG/WARNING comment marks. +3 Dragging and dropping of editable data: should content immediately appear as being dragged? +3 Dragging from anything other than AStringContentWidget. 3 Single-line edit: pressing return should lose keyboard focus and change value 3 Enable dragging from more widgets: bool content, enum 3 Content: setContent specialisations, opAssign should reject more values (particularly for BoolContent). 3 GUI: up-clicks get passed as events and activate objects 3 Widget saving: how to deal with modifier functions, esp. when they discard parameters? Remove feature except for dimdata and handle gui editing separately? 3 Windows compatibility - no registry support (useful to find path). -2 Visual feedback for dragging +2 Optimise: memory/reuse of popupContext and dragContentDisplay (in WidgetManager). +2 Check for unnecessary redraws (associated with mouse movement, not clicking). 2 First glyph drawn incorrectly in release mode - ?? 2 glBindTexture not working with non-0 index - perhaps use a higher level graphics library at some point. 2 Popup help boxes on hover/right click to display content description. @@ -49,6 +52,3 @@ +/ 1 Remove ability to scan, then load, mergetag sections. Not so necessary with section creator callback and allows "sliding window" type partial buffering. Also remove dataset and force use of section creator callback? 1 File loading from compressed archives and/or binary archives. - - -Done (since last commit): diff -r bb2f1a76346d -r 55667d048c31 mde/gui/WidgetManager.d --- 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 diff -r bb2f1a76346d -r 55667d048c31 mde/gui/renderer/SimpleRenderer.d --- a/mde/gui/renderer/SimpleRenderer.d Sun Jun 07 16:20:16 2009 +0200 +++ b/mde/gui/renderer/SimpleRenderer.d Sun Jun 21 12:19:18 2009 +0200 @@ -113,12 +113,7 @@ glEnd (); } - override void drawWidgetBack (wdim x, wdim y, wdim w, wdim h) { - debug { - glColor3f (0f, .2f, .2f); - glRecti (x,y+h, x+w,y); - } - } + override void drawWidgetBack (wdim x, wdim y, wdim w, wdim h) {} override void drawBlank (wdim x, wdim y, wdim w, wdim h) { glColor3f (.4f, .4f, .4f); diff -r bb2f1a76346d -r 55667d048c31 mde/gui/types.d --- a/mde/gui/types.d Sun Jun 07 16:20:16 2009 +0200 +++ b/mde/gui/types.d Sun Jun 21 12:19:18 2009 +0200 @@ -60,6 +60,13 @@ int[] ints; /// Integer data char[][] strings; /// char[] data + static WidgetData opCall (int[] i = [], char[][] s = []) { + WidgetData ret; + ret.ints = i; + ret.strings = s; + return ret; + } + /** For creating a DebugWidget. */ static WidgetData dbg = { ints : [0xF] }; // 0xf is current code for debug widget } diff -r bb2f1a76346d -r 55667d048c31 mde/gui/widget/Ifaces.d --- a/mde/gui/widget/Ifaces.d Sun Jun 07 16:20:16 2009 +0200 +++ b/mde/gui/widget/Ifaces.d Sun Jun 21 12:19:18 2009 +0200 @@ -131,6 +131,13 @@ * * The widget manager is an IPPW, but unlike most IPPWs its popup(s), if * existing, probably have nothing to do with its child IPPWs. + * + * ---- + * // No popups: + * WM + * // (IPPW) Widget X clicked on, which opens a menu: + * WM -> X (manages menu widget) + * ---- *****************************************************************************/ interface IPopupParentWidget : IParentWidget { @@ -410,12 +417,13 @@ * $(TABLE * $(TR $(TD 1) $(TD Request keyboard input)) * $(TR $(TD 2) $(TD Request the functions dragMotion and dragRelease are called)) + * $(TR $(TD 4) $(TD Display the widget's content while dragging (requires 2))) * ) */ int clickEvent (wdabs cx, wdabs cy, ubyte b, bool state); /** Called when dragging motion occurs, originating from this widget. * - * Params: target = The widget under the mouse when the click was released + * Params: target = The widget under the mouse * * Only called if requested by clickEvent. */ void dragMotion (wdabs cx, wdabs cy, IChildWidget target); diff -r bb2f1a76346d -r 55667d048c31 mde/gui/widget/TextWidget.d --- a/mde/gui/widget/TextWidget.d Sun Jun 07 16:20:16 2009 +0200 +++ b/mde/gui/widget/TextWidget.d Sun Jun 21 12:19:18 2009 +0200 @@ -151,7 +151,7 @@ /** On click, request keyboard input. */ override int clickEvent (wdabs cx, wdabs, ubyte, bool state) { if (state) - return 2; + return 6; else { content_.editIndex = adapter.setIndex (cx - x); mgr.requestRedraw; diff -r bb2f1a76346d -r 55667d048c31 mde/gui/widget/miscContent.d --- a/mde/gui/widget/miscContent.d Sun Jun 07 16:20:16 2009 +0200 +++ b/mde/gui/widget/miscContent.d Sun Jun 21 12:19:18 2009 +0200 @@ -93,6 +93,19 @@ return content_; } + override int clickEvent (wdabs cx, wdabs cy, ubyte b, bool state) { + // Also display if dragging + return super.clickEvent (cx,cy, b, state) | 4; + } + + override bool dragRelease (wdabs cx, wdabs cy, IChildWidget widg) { + super.dragRelease (cx, cy, widg); + if (widg !is this) { // don't copy content to self + widg.dropContent (content_); + } + return true; + } + override void draw () { super.draw(); adapter.draw (x,y);