Mercurial > projects > mde
diff mde/gui/WidgetManager.d @ 133:9fd705793568
Fixed menu popup bug, improved recursion detection.
Menu popups can now determine whether or not they are sub-menus.
Recursion detection can now also check content (if not the same, there's not a risk of infinite recursion).
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Fri, 23 Jan 2009 16:05:05 +0000 |
parents | 264028f4115a |
children | 7ababdf97748 |
line wrap: on
line diff
--- a/mde/gui/WidgetManager.d Fri Jan 23 14:59:05 2009 +0000 +++ b/mde/gui/WidgetManager.d Fri Jan 23 16:05:05 2009 +0000 @@ -268,7 +268,7 @@ //BEGIN IParentWidget methods // If call reaches the widget manager there isn't any recursion. //NOTE: should be override - final void recursionCheck (widgetID) {} + final void recursionCheck (widgetID, IContent) {} override void minWChange (IChildWidget widget, wdim nmw) { debug assert (widget is child, "WM.mSC (code error)"); @@ -320,6 +320,9 @@ override bool menuActive () { return mAIPPW; } + override bool parentMenuActive () { + return false; + } // Don't do anything. E.g. can get called by non-popup buttons. override void menuDone () {} @@ -473,7 +476,6 @@ enum WIDGET_TYPE : int { FUNCTION = 0x2000, // Function called instead of widget created (no "Widget" appended to fct name) TAKES_CONTENT = 0x4000, // Flag indicates widget's this should be passed an IContent reference. - SAFE_RECURSION = 0x8000, // Safe to instantiate recursively without infinite looping. // Use widget names rather than usual capitals convention Unnamed = 0x0, // Only for use by widgets not created with createWidget @@ -491,7 +493,7 @@ TextLabel = 0x21, // content functions: 0x30 - editContent = FUNCTION | TAKES_CONTENT | SAFE_RECURSION | 0x30, + editContent = FUNCTION | TAKES_CONTENT | 0x30, addContent = FUNCTION | 0x31, popupListContent = FUNCTION | TAKES_CONTENT | 0x33, @@ -502,7 +504,7 @@ ButtonContent = TAKES_CONTENT | 0x43, GridLayout = TAKES_CONTENT | 0x100, - ContentList = TAKES_CONTENT | SAFE_RECURSION | 0x110, + ContentList = TAKES_CONTENT | 0x110, FloatingArea = TAKES_CONTENT | 0x200, Switch = TAKES_CONTENT | 0x210, @@ -522,11 +524,11 @@ "AStringContent", "ButtonContent", "GridLayout", + "ContentList", "FloatingArea", "Switch", - "popupListContent", - "ContentList", - "editContent"]; + "editContent", + "popupListContent"]; /* Generates a binary search algorithm for makeWidget. */ char[] binarySearch (char[] var, char[][] consts) { @@ -541,8 +543,7 @@ foreach (c; consts) { ret ~= `if (` ~ var ~ ` == WIDGET_TYPE.` ~ c ~ `) { debug (mdeWidgets) logger.trace ("Creating new `~c~`."); - if (!(WIDGET_TYPE.`~c~` & WIDGET_TYPE.SAFE_RECURSION)) - parent.recursionCheck (id); + parent.recursionCheck (id, content); static if (WIDGET_TYPE.`~c~` & WIDGET_TYPE.FUNCTION) return `~c~` (this, parent, id, data, content); else static if (WIDGET_TYPE.`~c~` & WIDGET_TYPE.TAKES_CONTENT)