Revision: 2222
          http://vexi.svn.sourceforge.net/vexi/?rev=2222&view=rev
Author:   clrg
Date:     2007-09-15 19:54:14 -0700 (Sat, 15 Sep 2007)

Log Message:
-----------
grid works now (at least according to the vunit test)

Modified Paths:
--------------
    trunk/widgets/org.vexi.widgets/src/vexi/layout/grid.t
    trunk/widgets/org.vexi.widgets/src_vunit/test/layout/grid_simple.t

Modified: trunk/widgets/org.vexi.widgets/src/vexi/layout/grid.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src/vexi/layout/grid.t       2007-09-16 
02:03:11 UTC (rev 2221)
+++ trunk/widgets/org.vexi.widgets/src/vexi/layout/grid.t       2007-09-16 
02:54:14 UTC (rev 2222)
@@ -284,7 +284,7 @@
                         r2 = regions[r];
                         // honor maxwidths then minwidths
                         diff = max(minsizes[r], min(maxsizes[r], 
targetColumnSize * (r2-r1)));
-                        sizes[r] = diff + (r == 0 ? 0 : sizes[r-1]);
+                        sizes[r] = diff + sizes[r-1];
                         vexi.log.info(sizes[r]);
                         // account for cols that can be further affected
                         if (diff > minsizes[r]) mincols += (r2-r1);
@@ -311,15 +311,17 @@
                 
                 // place our boxes
                 c = colregions.mark();
+                c0 = c[0];
                 for (var r=1; regmark>r; r++) {
-                    c0 = c[0];
                     sizes[r] = vexi.math.round(sizes[r]);
-                    do {
+                    while (c and regions[r] == c0.col+c0.colspan) {
                         r1 = sizes[rindmap[c0.col]];
                         r2 = sizes[r];
-                        c.width = c0.hshrink ? c0.contentwidth : 
max(c0.maxwidth, r2-r1);
+                        c.width = c0.hshrink ? c0.contentwidth : 
min(c0.maxwidth, r2-r1);
                         c.x = (c.width == r2-r1) ? r1 : fromHAlign(c0.align, 
r1, r2-r1-c.width);
-                    } while (colregions.next());
+                        c = colregions.next();
+                        if (c) c0 = c[0];
+                    }
                 }
                 
                 // hand out any slack
@@ -419,15 +421,17 @@
                 
                 // place our boxes
                 c = rowregions.mark();
+                c0 = c[0];
                 for (var r=1; regmark>r; r++) {
-                    c0 = c[0];
                     sizes[r] = vexi.math.round(sizes[r]);
-                    do {
+                    while (c and regions[r] == c0.row+c0.rowspan) {
                         r1 = sizes[rindmap[c0.row]];
                         r2 = sizes[r];
-                        c.height = c0.vshrink ? c0.contentheight : 
max(c0.maxheight, r2-r1);
-                        c.x = (c.height == r2-r1) ? r1 : fromHAlign(c0.align, 
r1, r2-r1-c.height);
-                    } while (rowregions.next());
+                        c.height = c0.vshrink ? c0.contentheight : 
min(c0.maxheight, r2-r1);
+                        c.y = (c.height == r2-r1) ? r1 : fromVAlign(c0.align, 
r1, r2-r1-c.height);
+                        c = rowregions.next();
+                        if (c) c0 = c[0];
+                    }
                 }
                 
                 // hand out any slack

Modified: trunk/widgets/org.vexi.widgets/src_vunit/test/layout/grid_simple.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src_vunit/test/layout/grid_simple.t  
2007-09-16 02:03:11 UTC (rev 2221)
+++ trunk/widgets/org.vexi.widgets/src_vunit/test/layout/grid_simple.t  
2007-09-16 02:54:14 UTC (rev 2222)
@@ -5,7 +5,7 @@
     
        var vunit = vexi..vexi.test.vunit;
        
-       var newBox = function(n, c, r) {
+       var newBox = function(n, c, r, f) {
                var b = vexi.box;
                b.name = n;
                b.colspan = c;
@@ -42,27 +42,33 @@
                b.visible ++= function(v) { return; };
                .grid(b);
                b.cols=5;
-               b[0] = newBox("A",2,2);
-               b[1] = newBox("B",3,2);
-               b[2] = newBox("C",2,1);
-               b[3] = newBox("D",3,1);
+               b[0] = newBox("A",2,2,"red");
+               b[1] = newBox("B",3,2,"blue");
+               b[2] = newBox("C",2,1,"green");
+               b[3] = newBox("D",3,1,"yellow");
                b.width = 100;
                b.height = 60;
-            b.visible = true;
-            b.forcereflow();
-            
-            assertSlot(0,0,b[0]);
-            assertSlot(2,0,b[1]);
-            assertSlot(0,2,b[2]);
-            assertSlot(2,2,b[3]);
-            assertWidth(40, b[0]);
-            assertWidth(60, b[1]);
-            assertWidth(40, b[2]);
-            assertWidth(60, b[3]);
-            assertHeight(40, b[0]);
-            assertHeight(40, b[1]);
-            assertHeight(20, b[2]);
-            assertHeight(20, b[3]);
+               b.fill = "white";
+               var f = vexi.box;
+               f.layout="place";
+               f[0] = b;
+               b.align = "center";
+               vexi.ui.frame = f;
+            f.Press1 ++= function(v) {
+                cascade = v;
+                   assertSlot(0,0,b[0]);
+                   assertSlot(2,0,b[1]);
+                   assertSlot(0,2,b[2]);
+                   assertSlot(2,2,b[3]);
+                   assertWidth(40, b[0]);
+                   assertWidth(60, b[1]);
+                   assertWidth(40, b[2]);
+                   assertWidth(60, b[3]);
+                   assertHeight(40, b[0]);
+                   assertHeight(40, b[1]);
+                   assertHeight(20, b[2]);
+                   assertHeight(20, b[3]);
+               }
            };
         return vunit..newQuickSuite("vexi.layout.grid Packing", suite);
     };


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to