Revision: 2963
          http://vexi.svn.sourceforge.net/vexi/?rev=2963&view=rev
Author:   clrg
Date:     2008-07-10 01:58:16 -0700 (Thu, 10 Jul 2008)

Log Message:
-----------
Fully fixed grids \o/

Modified Paths:
--------------
    trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/grid.t

Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/grid.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/grid.t       
2008-07-10 02:39:19 UTC (rev 2962)
+++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/grid.t       
2008-07-10 08:58:16 UTC (rev 2963)
@@ -345,6 +345,7 @@
         /** pack by column first, expanding rows as required */
         var packByCol = function() {
             var frontier = .vector(vexi.box);
+            var fullpass = true;
             var nextcol = 0;  // the next available col
             var nextrow = 0;  // the next available row
             var minrows = 0;  // the minimum row past a frontier box
@@ -359,7 +360,8 @@
                 else c.display = true;
                 // if we don't fit on the row, jump to the next
                 if (nextcol!=0 and nextcol+c0.colspan > numcols) { nextcol=0; 
nextrow++; }
-                
+                // check to see if we are making a full pass at the row
+                fullpass = nextcol==0;
                 // work through frontier boxes until a suitable position is 
found
                 PACKME: while (frontier.length>0) {
                     f = frontier.first;
@@ -378,8 +380,15 @@
                             nextcol = f0.v_col+f0.colspan;
                             // establish next available row
                             minrows = (minrows == 0) ? f0.v_row+f0.rowspan : 
min(minrows, f0.v_row+f0.rowspan);
-                            // c will not fit on nextrow, try c on next 
available row
-                            if (nextcol+c0.colspan > numcols) { nextcol=0; 
nextrow=minrows; minrows=0; continue PACKME; }
+                            // c will not fit on nextrow
+                            if (nextcol+c0.colspan > numcols) {
+                                // if not a full pass, try next immediate row
+                                if (!fullpass) { nextrow++; nextcol=0; 
minrows=0; }
+                                // try c on next available row
+                                else { nextcol=0; nextrow=minrows; minrows=0; }
+                                // try frontier again
+                                continue PACKME;
+                            }
                         // fit between previous frontier and this frontier
                         } else if (f0.v_col >= nextcol+c0.colspan) break 
PACKME;
                         // next frontier
@@ -411,6 +420,7 @@
         /** pack by row first - for comments see packByCol **/
         var packByRow = function() {
             var frontier = .vector(vexi.box);
+            var fullpass = true;
             var nextrow = 0;  // the next available row
             var nextcol = 0;  // the next available col
             var mincols = 0;  // the minimum col past a frontier box
@@ -425,6 +435,8 @@
                 else c.display = true;
                 // if we don't fit on the col, jump to the next
                 if (nextrow!=0 and nextrow+c0.rowspan > numrows) { nextrow=0; 
nextcol++; }
+                // check to see if we are making a full pass at the col
+                fullpass = nextrow==0;
                 
                 // work through frontier boxes until a suitable position is 
found
                 PACKME: while (frontier.length>0) {
@@ -444,8 +456,15 @@
                             nextrow = f0.v_row+f0.rowspan;
                             // establish next available col
                             mincols = (mincols == 0) ? f0.v_col+f0.colspan : 
min(mincols, f0.v_col+f0.colspan);
-                            // c will not fit on nextcol, try c on next 
available col
-                            if (nextrow+c0.rowspan > numrows) { nextrow=0; 
nextcol=mincols; mincols=0; continue PACKME; }
+                            // c will not fit on nextcol
+                            if (nextrow+c0.rowspan > numrows) {
+                                // if not a full pass, try next immediate col
+                                if (!fullpass) { nextrow++; nextcol=0; 
minrows=0; }
+                                // try c on next available col
+                                else { nextrow=0; nextcol=mincols; mincols=0; }
+                                // try frontier again
+                                continue PACKME;
+                            }
                         // fit between previous frontier and this frontier
                         } else if (f0.v_row >= nextrow+c0.rowspan) break 
PACKME;
                         // next frontier


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

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to