changeset 168:da8d3091fdaf

More work on the context menu: now roughly usable like an ordinary context menu.
author Diggory Hardy <diggory.hardy@gmail.com>
date Mon, 29 Jun 2009 18:45:58 +0200
parents 620d4ea30228
children bc1cf73dc835
files codeDoc/ideas.txt codeDoc/jobs.txt data/conf/guiDemo.mtt mde/content/Content.d mde/gui/WidgetManager.d mde/gui/widget/ParentContent.d mde/gui/widget/layout.d
diffstat 7 files changed, 18 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/codeDoc/ideas.txt	Sat Jun 27 11:57:26 2009 +0200
+++ b/codeDoc/ideas.txt	Mon Jun 29 18:45:58 2009 +0200
@@ -82,6 +82,7 @@
   > Context menus:
     > Context menu serves (editable?) content most directly under mouse cursor
     > plus content higher up widget tree?
+    > "Drag" option to drag from, instead of widget itself?
 > Non-static content manager
   > Separate managers for options, GUI symbols, data fields, passwords(?)
     > Optional saving/loading
--- a/codeDoc/jobs.txt	Sat Jun 27 11:57:26 2009 +0200
+++ b/codeDoc/jobs.txt	Mon Jun 29 18:45:58 2009 +0200
@@ -3,11 +3,12 @@
 
 
 In progress:
-
+Adding context menu. Why doesn't clicking button close?
 
 
 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.
+4   Should only have one instance of context menu widgets. Service menu callbacks don't get removed!
 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
--- a/data/conf/guiDemo.mtt	Sat Jun 27 11:57:26 2009 +0200
+++ b/data/conf/guiDemo.mtt	Mon Jun 29 18:45:58 2009 +0200
@@ -44,7 +44,9 @@
 <WidgetData|slider={0:[0x2031],1:["MiscOptions.pollInterval","sliderW"]}>
 <WidgetData|sliderW={0:[0x4044]}>
 
-<WidgetData|context={0:[0x4204, 1],1:["contextDesc"]}>
-<WidgetData|contextDesc={0:[0x4040, 0,2]}>
+<WidgetData|context={0:[0x4204, 1],1:["contextLayout"]}>
+<WidgetData|contextLayout={0:[0x4100,4,2,1],1:["optDBox","contextServices"]}>
+<WidgetData|contextServices={0:[0x2031],1:["menus.services","contextMenu"]}>
+<WidgetData|contextMenu={0:[0x6030,0,1],1:["contextMenu"]}>
 {Basic}
 <WidgetData|root={0:[0x21,0x90D970],1:["A string!"]}>
--- a/mde/content/Content.d	Sat Jun 27 11:57:26 2009 +0200
+++ b/mde/content/Content.d	Mon Jun 29 18:45:58 2009 +0200
@@ -1,6 +1,6 @@
 /* LICENSE BLOCK
 Part of mde: a Modular D game-oriented Engine
-Copyright © 2007-2008 Diggory Hardy
+Copyright © 2007-2009 Diggory Hardy
 
 This program is free software: you can redistribute it and/or modify it under the terms
 of the GNU General Public License as published by the Free Software Foundation, either
--- a/mde/gui/WidgetManager.d	Sat Jun 27 11:57:26 2009 +0200
+++ b/mde/gui/WidgetManager.d	Mon Jun 29 18:45:58 2009 +0200
@@ -31,6 +31,7 @@
 import mde.content.Content;
 import mde.content.ServiceContent;
 debug import mde.content.miscContent;	// Debug menu
+debug import mde.content.Debug;
 
 // Widgets to create:
 import mde.gui.widget.layout;
@@ -157,7 +158,7 @@
     override IChildWidget getPopupWidget (wdabs cx, wdabs cy, bool closePopup) {
         if (popupContext) {
             if (popupContext.onSelf (cx, cy))
-            	return popupContext;
+            	return popupContext.getWidget (cx, cy);
             if (closePopup) {
             	if (childIPPW is null)
 		    menuActive = MenuPosition.INACTIVE;
@@ -334,6 +335,7 @@
 	    popupContext = makeWidget (this, "context", contextContent);
 	    popupContext.setup (0, 3);
 	    positionPopup (underMouse, popupContext);
+	    menuActive = MenuPosition.ACTIVE;
 	    requestRedraw;
 	} else {	// post other button presses to clickEvent
 	    int ret = underMouse.clickEvent (cast(wdabs)cx,cast(wdabs)cy,b,state);
@@ -384,6 +386,8 @@
             child.setWidth  (w, -1);
             child.setHeight (h, -1);
             child.setPosition (0,0);
+	    popupContext.setup (setupN, 2);
+	    //NOTE: does popupContext need to be re-scaled?
             requestRedraw;
         }
     }
@@ -399,6 +403,8 @@
             debug assert (oUM && underMouse, "no widget under mouse: error");
             oUM.underMouse (false);
             underMouse.underMouse (true);
+	    debug if (Debug.logUnderMouse())
+		logger.trace ("Widget under mouse: {}", underMouse);
         }
     }
     
--- a/mde/gui/widget/ParentContent.d	Sat Jun 27 11:57:26 2009 +0200
+++ b/mde/gui/widget/ParentContent.d	Mon Jun 29 18:45:58 2009 +0200
@@ -423,7 +423,7 @@
         debug assert (cx >= x && cx < x + w && cy >= y && cy < y + h, "getWidget: not on widget (code error)");
         
         if (subWidgets[0].onSelf (cx, cy))
-            return subWidgets[0];
+            return subWidgets[0].getWidget (cx, cy);
         else
             return this;
     }
--- a/mde/gui/widget/layout.d	Sat Jun 27 11:57:26 2009 +0200
+++ b/mde/gui/widget/layout.d	Mon Jun 29 18:45:58 2009 +0200
@@ -156,8 +156,8 @@
  * 
  * Several flags are tested against ints[1]:
  * $(TABLE
- * $(TR $(TD 1) $(TD Column alignment is shared against other instances of thes widget id))
- * $(TR $(TD 2) $(TD Row alignment is shared against other instances of thes widget id))
+ * $(TR $(TD 1) $(TD Column alignment is shared against other instances of this widget id))
+ * $(TR $(TD 2) $(TD Row alignment is shared against other instances of this widget id))
  * $(TR $(TD 4) $(TD Spacing is inserted between elements; the renderer may draw this))
  * $(TR $(TD 8) $(TD For ContentListWidget only, list is horizontal instead of vertical))
  * )