Mercurial > projects > mde
diff mde/gui/WidgetManager.d @ 173:a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Sat, 08 Aug 2009 15:53:10 +0200 |
parents | 7f7b2011b759 |
children |
line wrap: on
line diff
--- a/mde/gui/WidgetManager.d Wed Jul 29 20:28:22 2009 +0200 +++ b/mde/gui/WidgetManager.d Sat Aug 08 15:53:10 2009 +0200 @@ -46,6 +46,7 @@ public import tango.core.sync.Mutex; import tango.util.log.Log : Log, Logger; +import tango.io.Console; // to print exception stack-trace import tango.util.container.SortedMap; private Logger logger; @@ -93,9 +94,12 @@ final void recursionCheck (widgetID, IContent) {} override void minWChange (IChildWidget widget, wdim nmw) { - if (widget !is childRoot) // Probably because widget is a popup widget + if (widget !is childRoot) { // Probably because widget is a popup widget // This may get called from a CTOR, hence we can't check widget is one of childContext, etc. + if (widget.width < nmw) + widget.setWidth (nmw, -1); return; + } mw = nmw; if (w < nmw) { childRoot.setWidth (nmw, -1); @@ -105,8 +109,11 @@ requestRedraw; } override void minHChange (IChildWidget widget, wdim nmh) { - if (widget !is childRoot) + if (widget !is childRoot) { + if (widget.height < nmh) + widget.setHeight (nmh, -1); return; + } mh = nmh; if (h < nmh) { childRoot.setHeight (nmh, -1); @@ -118,7 +125,7 @@ //END IParentWidget methods //BEGIN IWidget methods - override bool saveChanges () { + public override bool saveChanges () { bool ret = childRoot.saveChanges; ret |= childContext.saveChanges; if (childDragged !is null) @@ -147,12 +154,17 @@ childIPPW = ippw; } override bool removeChildIPPW (IPopupParentWidget ippw) { + if (ippw is childContext && contextActive) { + childContext.removedIPPW; + contextActive = false; + return true; + } if (childIPPW !is ippw) return false; childIPPW.removedIPPW; childIPPW = null; mAIPPW = MenuPosition.INACTIVE; requestRedraw; - return false; + return true; } override void menuActive (MenuPosition mA) { @@ -180,6 +192,7 @@ if (ret) return ret; if (closePopup) { childContext.removedIPPW; + contextActive = false; requestRedraw; } } @@ -194,8 +207,10 @@ } override void drawPopup () { + if (childIPPW) + childIPPW.drawPopup; if (contextActive) - childContext.draw(); + childContext.drawPopup(); if (childDragged) childDragged.draw(); } @@ -231,7 +246,9 @@ // Not returned a new widget: logger.error ("Bad widget type: {}; creating a debug widget instead",type); } catch (Exception e) { - logger.error ("Error creating widget: {}; creating a debug widget instead.", e.msg); + logger.error ("Error creating widget; creating a debug widget instead. Exception printed to stderr."); + //TODO: find a standard way to output exceptions, and implement everywhere: + e.writeOut(delegate void(char[]s){ Cerr(s); }); } return new DebugWidget (this, parent, id, data, content); @@ -294,7 +311,7 @@ if (y < 0) y = 0; popup.setPosition (x, y); debug if (Debug.logPopupPositioning()) - logger.trace ("Placed popup {}; output position: {}", popup, position); + logger.trace ("Placed popup {} of size ({},{}) at ({},{}); output position: {}", popup, w,h, x,y, position); return position; } @@ -352,8 +369,6 @@ final void wmDrawWidgets() { if (childRoot) childRoot.draw; - if (childIPPW) - childIPPW.drawPopup; drawPopup; }