changeset 66:f54ae4fc2b2f

Replaced IWidget.getMinimalSize(out w,out h) with minWidth() and minHeight().
author Diggory Hardy <diggory.hardy@gmail.com>
date Wed, 02 Jul 2008 17:10:07 +0100
parents 891211f034f2
children ead4afc6d0b8
files codeDoc/todo.txt mde/gui/widget/Ifaces.d mde/gui/widget/Widget.d mde/gui/widget/Window.d mde/gui/widget/layout.d
diffstat 5 files changed, 29 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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);
--- 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) {
--- 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;
--- 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;
         }