Mercurial > projects > mde
diff mde/gui/widget/WidgetManager.d @ 179:1f9d00f392bd default tip
Fixed a bug where (non-resizible) widgets wouldn't get shrunk when minimal size decreases, meaning optional context menus are hiden properly now.
Optimised when ServiceContentList.opCall is called, I think without breaking anything.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Tue, 15 Sep 2009 20:09:59 +0200 |
parents | af40e9679436 |
children |
line wrap: on
line diff
--- a/mde/gui/widget/WidgetManager.d Tue Sep 15 10:36:37 2009 +0200 +++ b/mde/gui/widget/WidgetManager.d Tue Sep 15 20:09:59 2009 +0200 @@ -145,10 +145,11 @@ return; } mw = nmw; - if (w < nmw) { - childRoot.setWidth (nmw, -1); - w = nmw; - } + matchMinimalSize (); + nmw = w; // reuse to see if width is changed + w = mw > sW ? mw : sW; + if (w != nmw) + childRoot.setWidth (w, -1); childRoot.setPosition (0,0); requestRedraw; } @@ -159,10 +160,11 @@ return; } mh = nmh; - if (h < nmh) { - childRoot.setHeight (nmh, -1); - h = nmh; - } + matchMinimalSize (); + nmh = h; + h = mh > sH ? mh : sH; + if (h != nmh) + childRoot.setHeight (nmh, -1); childRoot.setPosition (0,0); requestRedraw; } @@ -372,7 +374,9 @@ matchMinimalSize (); debug (mdeWidgets) logger.trace ("Setting size and position of root widget..."); - childRoot.setWidth (w, -1); + w = mw > sW ? mw : sW; + h = mh > sH ? mh : sH; + childRoot.setWidth (w, -1); childRoot.setHeight (h, -1); childRoot.setPosition (0,0); debug (mdeWidgets) logger.trace ("Done creating root widget."); @@ -385,13 +389,19 @@ } final void wmSizeEvent (int nw, int nh) { - w = cast(wdim) nw; - h = cast(wdim) nh; + sW = cast(wdim) nw; + sH = cast(wdim) nh; matchMinimalSize; if (!childRoot) return; // if not created yet. - childRoot.setWidth (w, -1); - childRoot.setHeight (h, -1); + if (sW != w && w != mw) { + w = mw > sW ? mw : sW; + childRoot.setWidth (w, -1); + } + if (sH != h && h != mh) { + h = mh > sH ? mh : sH; + childRoot.setHeight (h, -1); + } childRoot.setPosition (0,0); debug logWidgetSize (null); } @@ -475,7 +485,10 @@ auto oUM = underMouse; underMouse = getPopupWidget (cx, cy, closePopup); if (underMouse is null) { - debug assert (childRoot.onSelf (cx, cy), "WidgetManager: childRoot doesn't cover whole area"); + // Note: I'm surprised this never fails, since clicks outside the + // window are reported. If it does, better allow underMouse to be + // null. + debug assert (childRoot.onSelf (cx, cy), "WidgetManager: click not on childRoot"); underMouse = childRoot.getWidget (cx, cy); } debug assert (oUM && underMouse, "no widget under mouse: error"); @@ -488,20 +501,15 @@ } /** If possible, the screen-interaction derived class should override to - * make sure the window is at least (mw,mh) in size. In any case, this - * method MUST make sure w >= mw and h >= mh even if the window isn't this - * big. + * make sure the window is at least (mw,mh) in size (use sW, sH to store + * the actual size). * - * A resize may not be required when this is called, however. */ + * A resize won't always be required when this is called. */ void matchMinimalSize () { - if (w < mw) { - logger.warn ("Min width for gui, {}, not met: {}", mw, w); - w = mw; - } - if (h < mh) { - logger.warn ("Min height for gui, {}, not met: {}", mh, h); - h = mh; - } + if (sW < mw) + logger.warn ("Min width for gui, {}, not met: {}", mw, sW); + if (sH < mh) + logger.warn ("Min height for gui, {}, not met: {}", mh, sH); } /// This should be overloaded to set a callback receiving keyboard input. @@ -621,6 +629,7 @@ // Dimensions and child set-up data (fit to childRoot): wdim w,h; // current widget size; should be at least (mw,mh) even if not displayable wdim mw,mh; // minimal area required by widgets + wdim sW,sH; // actual screen size; ideally equal to w,h uint setupN; // n to pass to IChildWidget.setup // IPopupParentWidget stuff for childRoot: