Revision: 2961 http://vexi.svn.sourceforge.net/vexi/?rev=2961&view=rev Author: clrg Date: 2008-07-09 11:48:23 -0700 (Wed, 09 Jul 2008)
Log Message: ----------- Fix several packing bugs Modified Paths: -------------- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/grid.t trunk/widgets/org.vexi.widgets/src_dev/test/grid/ex1.t Added Paths: ----------- trunk/widgets/org.vexi.widgets/src_dev/test/grid/ex2.t trunk/widgets/org.vexi.widgets/src_dev/test/grid/ex3.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-09 02:06:45 UTC (rev 2960) +++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/grid.t 2008-07-09 18:48:23 UTC (rev 2961) @@ -6,6 +6,9 @@ <todo> * hand out slack like the core does when packing * use static functions to make grids lightweight + * potential optimization: do not restart frontier + checking if next child to pack has colspan gte + previous child (i.e. as big or bigger). </todo> </meta:doc> <ui:box layout="layer"> @@ -370,26 +373,28 @@ continue; } // frontier not accomdating current child, look further - if (nextcol+c0.colspan > f0.v_col and f0.v_col+f0.colspan > nextcol) { + if (f0.v_col+f0.colspan > nextcol and nextcol+c0.colspan > f0.v_col) { // establish next available col nextcol = f0.v_col+f0.colspan; // establish next available row - if (minrows == 0) minrows = f0.v_row+f0.rowspan; - else minrows = min(minrows, f0.v_row+f0.rowspan); + 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; break; } + if (nextcol+c0.colspan > numcols) { nextcol=0; nextrow=minrows; minrows=0; continue PACKME; } // fit between previous frontier and this frontier - } else if (f0.v_col > nextcol+c0.colspan) break PACKME; + } else if (f0.v_col >= nextcol+c0.colspan) break PACKME; // next frontier f = frontier.after(f); } + // fits in the col after frontier if (numcols >= nextcol+c0.colspan) break; } // add to frontier if we affect the frontier if (c0.rowspan>1) { - f = frontier.before(f); - if (f) frontier.insert(c, f); - else frontier.unshift(c); + if (f) { + f = frontier.before(f); + if (f) frontier.insert(c, f); + else frontier.unshift(c); + } else frontier.push(c); } // place packed child assignSlot(c, nextcol, nextrow); @@ -438,22 +443,24 @@ // establish next available row nextrow = f0.v_row+f0.rowspan; // establish next available col - if (mincols == 0) mincols = f0.v_col+f0.colspan; - else mincols = min(mincols, f0.v_col+f0.colspan); + 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; break; } + if (nextrow+c0.rowspan > numrows) { nextrow=0; nextcol=mincols; mincols=0; continue PACKME; } // fit between previous frontier and this frontier - } else if (f0.v_row > nextrow+c0.rowspan) break PACKME; + } else if (f0.v_row >= nextrow+c0.rowspan) break PACKME; // next frontier f = frontier.after(f); } + // fits on this row after frontier if (numrows >= nextrow+c0.rowspan) break; } // add to frontier if we affect the frontier if (c0.colspan>1) { - f = frontier.before(f); - if (f) frontier.insert(c, f); - else frontier.unshift(c); + if (f) { + f = frontier.before(f); + if (f) frontier.insert(c, f); + else frontier.unshift(c); + } else frontier.push(c); } // place packed child assignSlot(c, nextcol, nextrow); Modified: trunk/widgets/org.vexi.widgets/src_dev/test/grid/ex1.t =================================================================== --- trunk/widgets/org.vexi.widgets/src_dev/test/grid/ex1.t 2008-07-09 02:06:45 UTC (rev 2960) +++ trunk/widgets/org.vexi.widgets/src_dev/test/grid/ex1.t 2008-07-09 18:48:23 UTC (rev 2961) @@ -8,10 +8,10 @@ <block fill="yellow" /> <block fill="blue" /> <block fill="red" /> - <block fill="green" rowspan="4" /> - <block fill="yellow" rowspan="4" /> - <block fill="blue" rowspan="4" /> - <block fill="red" rowspan="4" /> + <block fill="green" rowspan="4" minheight="250" /> + <block fill="yellow" rowspan="4" minheight="250" /> + <block fill="blue" rowspan="4" minheight="250" /> + <block fill="red" rowspan="4" minheight="250" /> <block fill="green" /> <block fill="yellow" /> <block fill="blue" /> Added: trunk/widgets/org.vexi.widgets/src_dev/test/grid/ex2.t =================================================================== --- trunk/widgets/org.vexi.widgets/src_dev/test/grid/ex2.t (rev 0) +++ trunk/widgets/org.vexi.widgets/src_dev/test/grid/ex2.t 2008-07-09 18:48:23 UTC (rev 2961) @@ -0,0 +1,18 @@ +<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" + xmlns:lay="vexi.layout" xmlns="test.grid"> + <ui:box> + <lay:grid cols="2"> + <block fill="blue" /> + <block fill="red" /> + <block fill="green" rowspan="4" /> + <block fill="yellow" rowspan="4" /> + <block fill="blue" rowspan="4" /> + <block fill="red" rowspan="4" /> + <block fill="green" /> + <block fill="yellow" /> + <block fill="blue" /> + <block fill="red" /> + </lay:grid> + vexi.ui.frame = thisbox; + </ui:box> +</vexi> \ No newline at end of file Added: trunk/widgets/org.vexi.widgets/src_dev/test/grid/ex3.t =================================================================== --- trunk/widgets/org.vexi.widgets/src_dev/test/grid/ex3.t (rev 0) +++ trunk/widgets/org.vexi.widgets/src_dev/test/grid/ex3.t 2008-07-09 18:48:23 UTC (rev 2961) @@ -0,0 +1,18 @@ +<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" + xmlns:lay="vexi.layout" xmlns="test.grid"> + <ui:box> + <lay:grid cols="4"> + <block fill="blue" /> + <block fill="red" /> + <block fill="green" rowspan="4" /> + <block fill="yellow" rowspan="4" /> + <block fill="blue" /> + <block fill="red" /> + <block fill="green" /> + <block fill="yellow" /> + <block fill="blue" /> + <block fill="red" /> + </lay:grid> + vexi.ui.frame = thisbox; + </ui:box> +</vexi> \ No newline at end of file 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