# HG changeset patch # User Diggory Hardy # Date 1234094136 0 # Node ID 29a524e7c8581fef1d4346b6a23da3b362c17c0e # Parent 3468e9bfded14eb5975e08e894ee212738113838 Fixed a resizing issue and added a popup menu for all content. diff -r 3468e9bfded1 -r 29a524e7c858 codeDoc/jobs.txt --- 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): diff -r 3468e9bfded1 -r 29a524e7c858 data/L10n/en-GB.mtt --- 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 @@ {} + diff -r 3468e9bfded1 -r 29a524e7c858 data/conf/guiDemo.mtt --- 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} - + + + + @@ -27,7 +30,7 @@ - + = x && cx < x + w && cy >= y && cy < y + h, "getWidget: not on widget (code error)"); foreach_reverse (j,i; sWOrder) with (sWData[i]) { diff -r 3468e9bfded1 -r 29a524e7c858 mde/gui/widget/Ifaces.d --- 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 diff -r 3468e9bfded1 -r 29a524e7c858 mde/gui/widget/layout.d --- 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)