Mercurial > projects > mde
changeset 139:29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Sun, 08 Feb 2009 11:55:36 +0000 |
parents | 3468e9bfded1 |
children | c94ec5594449 |
files | codeDoc/jobs.txt data/L10n/en-GB.mtt data/conf/guiDemo.mtt mde/gui/widget/Floating.d mde/gui/widget/Ifaces.d mde/gui/widget/layout.d |
diffstat | 6 files changed, 50 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/codeDoc/jobs.txt Sat Feb 07 13:28:52 2009 +0000 +++ b/codeDoc/jobs.txt Sun Feb 08 11:55:36 2009 +0000 @@ -4,6 +4,7 @@ In progress: Still a resizing issue (needs SIZABILITY = SIZABILITY_ENUM.ANY_SUBWIDGETS to make options window resizable): enlarge options box, change tab, shrink and change back. +Changing content from menu. To do (importance 0-5: 0 pointless, 1 no obvious impact now, 2 todo sometime, 3 useful, 4 important, 5 urgent):
--- a/data/L10n/en-GB.mtt Sat Feb 07 13:28:52 2009 +0000 +++ b/data/L10n/en-GB.mtt Sun Feb 08 11:55:36 2009 +0000 @@ -46,6 +46,7 @@ <entry|windowW={0:"Window width",1:"Horizontal size (windowed mode)."}> <entry|windowH={0:"Window height",1:"Vertical size (windowed mode)."}> {} +<entry|={0:"All content"}> <entry|Font={0:"Font options"}> <entry|MiscOptions={0:"Miscellaneous options"}> <entry|Screen={0:"Video options"}>
--- a/data/conf/guiDemo.mtt Sat Feb 07 13:28:52 2009 +0000 +++ b/data/conf/guiDemo.mtt Sun Feb 08 11:55:36 2009 +0000 @@ -4,13 +4,16 @@ {Working} <WidgetData|root={0:[0x4100,0,2,1],1:["bar","float"]}> <WidgetData|float={0:[0x4200,14],1:["options"]}> -<WidgetData|bar={0:[0x4100,14,1,2],1:["menuContent","blank"]}> +<WidgetData|bar={0:[0x4100,14,1,3],1:["menuContent","blank","allContent"]}> <WidgetData|blank={0:[0x2]}> <WidgetData|menuContent={0:[0x2031],1:["menus","menus"]}> <WidgetData|menus={0:[0x4110,12] ,1:["menuPopup"]}> <WidgetData|menuPopup={0:[0x6033,0,1],1:["menuPopup"]}> +<WidgetData|allContent={0:[0x2031],1:["","allPU"]}> +<WidgetData|allPU={0:[0x6033,0,1],1:["allPU"]}> + <EnumContent|gui.switch=["misc","video","font"]> <WidgetData|options={0:[0x2031],1:["gui.switch","switchL"]}> <WidgetData|switchL={0:[0x4100,4,2,1],1:["switchVal","switchT"]}> @@ -27,7 +30,7 @@ <WidgetData|optBox={0:[0x4100,1,1,3],1:["optName","optSep","optVal"]}> <WidgetData|optName={0:[0x4040, 0,1]}> <WidgetData|optDesc={0:[0x4040, 0,2]}> -<WidgetData|optVal={0:[0x6030,12,0],1:["optEnum"]}> +<WidgetData|optVal={0:[0x6030,4,0],1:["optEnum"]}> <WidgetData|optEnum={0:[0x4100,0,1,2],1:["optVal","optName"]}> <WidgetData|optSep={0:[0x21, 0xff],1:[" = "]}> {Basic}
--- a/mde/gui/widget/Floating.d Sat Feb 07 13:28:52 2009 +0000 +++ b/mde/gui/widget/Floating.d Sun Feb 08 11:55:36 2009 +0000 @@ -167,7 +167,7 @@ override IChildWidget getWidget (wdim cx, wdim cy) { debug scope (failure) - logger.warn ("getWidget: failure; values: click, pos, width - {}, {}, {} - {}, {}, {}", cx, x, w, cy, y, h); + logger.warn ("getWidget: failure; values: click; pos; width: {},{}; {},{}; {},{}", cx, cy, x, y, w, h); debug assert (cx >= x && cx < x + w && cy >= y && cy < y + h, "getWidget: not on widget (code error)"); foreach_reverse (j,i; sWOrder) with (sWData[i]) {
--- a/mde/gui/widget/Ifaces.d Sat Feb 07 13:28:52 2009 +0000 +++ b/mde/gui/widget/Ifaces.d Sun Feb 08 11:55:36 2009 +0000 @@ -52,11 +52,13 @@ /** IPPWs return self, other widgets recurse call on parent. */ IPopupParentWidget getParentIPPW (); - /** Child widgets should call this on their parent if their minimal size changes, since they - * cannot resize themselves. + /** Child widgets should call this on their parent if their minimal size + * changes, since they cannot properly resize themselves. * - * Children may depend on their parent resizing them if necessary to keep width valid. - * Widgets may also depend on setPosition being called afterwards. + * Children may depend on their parent resizing them if necessary to keep + * width valid. To ease adjustments with layouts, widgets $(I may) enlarge + * themselves, but shouldn't shrink themselves. Widgets may also depend on + * setPosition being called afterwards. * * Params: * widget = The child widget calling the function
--- a/mde/gui/widget/layout.d Sat Feb 07 13:28:52 2009 +0000 +++ b/mde/gui/widget/layout.d Sun Feb 08 11:55:36 2009 +0000 @@ -627,12 +627,14 @@ /** Adjust total size with direction dir. * - * nw should be at least the minimal width. */ + * nw should be at least the minimal width. + * + * Returns: the final width */ wdim resizeWidth (wdim nw, int dir) { debug assert (width, "AlignColumns not initialized when resizeWidth called (code error)"); - if (nw < mw) { - debug logger.warn ("Widget dimension set below minimal"); - nw = mw; + debug if (nw < mw) { + logger.warn ("Widget dimension set below minimal (code error)"); + return w; } if (nw == w) return w; @@ -706,16 +708,18 @@ if (minWidth[col] < nmw) { // increase minimal minWidth[col] = nmw; nd = width[col] - nmw; // negative diff + if (nd > 0) + nd = 0; // don't decrease our width! } else if (minWidth[col] > nmw) { // potentially decrease minimal - nmw = 0; + nmw = 0; // set nmw to max of all cell min widths for (size_t r = 0; r < rows; ++r) { wdim mcw = minCellWidths[col+r*cols]; if (nmw < mcw) nmw = mcw; } minWidth[col] = nmw; - if (!sizable[col]) - nd = width[col] - nmw; + if (!sizable[col] && lastSizable >= 0) + nd = width[col] - nmw; // Not resizable but another column is } else return false; @@ -727,8 +731,10 @@ width[col] = nmw; foreach (cb; cbs) cb.setWidth (col, nmw, -1); - if (lastSizable >= 0) - adjustCellSizes (nd, lastSizable, -1); // doesn't necessarily resize exactly + if (lastSizable >= 0) { + if (nd != adjustCellSizes (nd, lastSizable, -1)) + logger.error ("New minimal size not applied correctly (code error): minWidth: {}, nmw: {}, col: {}, nd: {}", minWidth, nmw, col, nd); + } genPositions; } @@ -759,11 +765,12 @@ * Returns: * The amount adjusted. This may be larger than diff, since cellD is clamped by cellDMin. * - * Doesn't touch non-sizable columns (except start which is only assumed sizable). + * Will shrink non-sizable columns if they're over minimal size. + * Will increase column start, since it's assumed sizable. * - * Note: Check variable used for start is valid before calling! If a non-sizable column's - * index is passed, this should get increased (if diff > 0) but not decreased. - */ + * Note: Check variable used for start is valid before calling! If a non- + * sizable column's index is passed, this should get increased (if diff > 0) + * but not decreased. */ private wdim adjustCellSizes (wdim diff, ptrdiff_t start, int incr) in { assert (width.length == cols, "CellAlign.adjustCellSizes: width is invalid (code error)"); @@ -780,30 +787,26 @@ } else if (diff < 0) { // decrease wdim rd = diff; // running diff - aCSwhile: - while (true) { - width[i] += rd; // decrease this cell's size (but may be too much) - rd = width[i] - minWidth[i]; - if (rd >= 0) { // OK; we're done + while (i >= 0 && i < cols) { + if (width[i] > minWidth[i]) { + width[i] += rd; // decrease this cell's size (but may be too much) + rd = width[i] - minWidth[i]; + if (rd >= 0) { // OK; we're done + foreach (cb; cbs) + cb.setWidth (i, width[i], incr); + break; // we hit the mark exactly: diff is correct + } + + // else we decreased it too much! + width[i] = minWidth[i]; foreach (cb; cbs) - cb.setWidth (i, width[i], incr); - break; // we hit the mark exactly: diff is correct + cb.setWidth (i, width[i], incr); + // rd is remainder to decrease by } - // else we decreased it too much! - width[i] = minWidth[i]; - foreach (cb; cbs) - cb.setWidth (i, width[i], incr); - // rd is remainder to decrease by - - do { - i += incr; - if (i < 0 || i >= cols) { // run out of next cells - diff -= rd; // still had rd left to decrease - break aCSwhile; // exception: Array index out of bounds - } - } while (!sizable[i]) // iterate again if row/col isn't resizable + i += incr; } + diff -= rd; // still had rd left to decrease (may be 0) } // else no adjustment needed (diff == 0)