# HG changeset patch # User Diggory Hardy # Date 1215015007 -3600 # Node ID f54ae4fc2b2fdca9444dad5db6981f3f604e7171 # Parent 891211f034f2e71ed5ac29bbf1a8ef212f1de612 Replaced IWidget.getMinimalSize(out w,out h) with minWidth() and minHeight(). diff -r 891211f034f2 -r f54ae4fc2b2f codeDoc/todo.txt --- a/codeDoc/todo.txt Sun Jun 29 15:40:37 2008 +0100 +++ b/codeDoc/todo.txt Wed Jul 02 17:10:07 2008 +0100 @@ -5,16 +5,12 @@ * means done GUI: --> Basic OpenGL code to: - ->* create orthographic projection - ->* draw boxes - -> maybe more (text, textures, ...) -->* Windows with size & position -> Widgets: + -> rethink how widgets are created and receive creation data, so that they don't have to be created by the Window ->* minimum size but expandable, auto-set - -> no ability to resize yet except from config files ->* grid "layout" widgets -> scripted widgets -> decent rendering/theme system --> Text rendering - -> text library? + -> lists from content lists +-> Content: + -> lists diff -r 891211f034f2 -r f54ae4fc2b2f mde/gui/widget/Ifaces.d --- a/mde/gui/widget/Ifaces.d Sun Jun 29 15:40:37 2008 +0100 +++ b/mde/gui/widget/Ifaces.d Wed Jul 02 17:10:07 2008 +0100 @@ -129,9 +129,11 @@ bool isWSizable (); bool isHSizable (); /// ditto - /** Calculate the minimal size the widget could be shrunk to (or its fixed size), taking into - * account child-widgets or other contents. */ - void getMinimalSize (out wdim w, out wdim h); + /** The minimal size the widget could be shrunk to (or its fixed size). + * + * Takes into account child-widgets and any other contents. */ + wdim minWidth (); + wdim minHeight (); /// ditto /** Get the current size of the widget. */ void getCurrentSize (out wdim w, out wdim h); diff -r 891211f034f2 -r f54ae4fc2b2f mde/gui/widget/Widget.d --- a/mde/gui/widget/Widget.d Sun Jun 29 15:40:37 2008 +0100 +++ b/mde/gui/widget/Widget.d Wed Jul 02 17:10:07 2008 +0100 @@ -62,9 +62,11 @@ bool isHSizable () { return false; } /* Return minimal/fixed size. */ - void getMinimalSize (out wdim a, out wdim b) { - a = mw; - b = mh; + wdim minWidth () { + return mw; + } + wdim minHeight () { + return mh; } void getCurrentSize (out wdim cw, out wdim ch) { diff -r 891211f034f2 -r f54ae4fc2b2f mde/gui/widget/Window.d --- a/mde/gui/widget/Window.d Sun Jun 29 15:40:37 2008 +0100 +++ b/mde/gui/widget/Window.d Wed Jul 02 17:10:07 2008 +0100 @@ -91,9 +91,8 @@ widget.setPosition (widgetX, widgetY); // Calculate mw/mh and xw/yh (cached data): - widget.getMinimalSize (mw, mh); - mw += border.l + border.r; - mh += border.t + border.b; + mw = widget.minWidth + border.l + border.r; + mh = widget.minHeight + border.t + border.b; xw = x+w; yh = y+h; @@ -254,10 +253,11 @@ return widget.isHSizable; } - void getMinimalSize (out wdim wM, out wdim hM) { - // mw/mh are calculated by finalise(); - wM = mw; - hM = mh; + wdim minWidth () { + return mw; + } + wdim minHeight () { + return mh; } void getCurrentSize (out wdim cw, out wdim ch) { cw = w; diff -r 891211f034f2 -r f54ae4fc2b2f mde/gui/widget/layout.d --- a/mde/gui/widget/layout.d Sun Jun 29 15:40:37 2008 +0100 +++ b/mde/gui/widget/layout.d Wed Jul 02 17:10:07 2008 +0100 @@ -35,6 +35,10 @@ * Since a grid with either dimension zero is not useful, there must be at least one sub-widget. * * The grid has no border but has spacing between widgets. */ +/* TODO: + separate positioning & sub-widget handling from creation/saving + other types of layouts (e.g. lists from content) +*/ class GridLayoutWidget : Widget { //BEGIN Creation & saving @@ -137,12 +141,6 @@ return row.firstSizable >= 0; } - /* Calculates the minimal size from all rows and columns of widgets. */ - void getMinimalSize (out wdim mw, out wdim mh) { - mw = this.mw; - mh = this.mh; - } - void setWidth (wdim nw, int dir) { if (nw == w) return; @@ -223,15 +221,14 @@ // set length, making sure the arrays are initialised to zero: col.minWidth = new wdim[cols]; row.minWidth = new wdim[rows]; - wdim ww, wh; // sub-widget minimal sizes foreach (i,widget; subWidgets) { - widget.getMinimalSize (ww, wh); - // Increase dimensions if current minimal size is larger: myIt n = i % cols; // column - if (col.minWidth[n] < ww) col.minWidth[n] = ww; + wdim md = widget.minWidth; + if (col.minWidth[n] < md) col.minWidth[n] = md; n = i / cols; // row - if (row.minWidth[n] < wh) row.minWidth[n] = wh; + md = widget.minHeight; + if (row.minWidth[n] < md) row.minWidth[n] = md; }