Revision: 4759
http://sourceforge.net/p/vexi/code/4759
Author: mkpg2
Date: 2015-01-25 22:38:44 +0000 (Sun, 25 Jan 2015)
Log Message:
-----------
Flow layout.
Modified Paths:
--------------
branches/vexi3/org.vexi-vexi.widgets/src_main/vexi/layout/flow.t
Added Paths:
-----------
branches/vexi3/org.vexi-vexi.widgets/src_poke/poke/layout/PokeFlow.t
Modified: branches/vexi3/org.vexi-vexi.widgets/src_main/vexi/layout/flow.t
===================================================================
--- branches/vexi3/org.vexi-vexi.widgets/src_main/vexi/layout/flow.t
2015-01-13 07:08:18 UTC (rev 4758)
+++ branches/vexi3/org.vexi-vexi.widgets/src_main/vexi/layout/flow.t
2015-01-25 22:38:44 UTC (rev 4759)
@@ -1,27 +1,103 @@
<!-- Copyright 2009 - see COPYING for details [LGPL] -->
-<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" xmlns:lay="vexi.layout">
+<vexi xmlns:ui="vexi://ui"
+ xmlns:role="org.vexi.lib.role"
+ xmlns:meta="vexi://meta"
+ xmlns:lay="vexi.layout">
<meta:doc>
<author>Charles Goodwin</author>
+ <author>Mike Goodwin</author>
<name>Flow Layout</name>
- <desc>A very hacky implementation of flow layout</desc>
+ <desc>
+ Lays out children filling first row/column (horizontal/vertical)
before flowing onto the next row.
+ Essentially in the manner that wrapped text is layed out.
+ </desc>
</meta:doc>
- <ui:box redirect=":$content" align="topleft">
- <lay:grid id="content" shrink="true" />
+ <ui:box layout="place" align="topleft">
+ var _x;
+ var _y;
+ var _width;
+ var _height;
- /** match content cols to width so grid handles line breaking */
- thisbox.width ++= function(v) { $content.cols = v; return; }
+
+
+ var dirty;
+ const max = vexi.math.max;
+ const doReflow = function(){
+ if(!visible){
+ dirty = true;
+ return;
+ }else{
+ dirty = false;
+ }
+
+ var rankSize = 0;
+ var offsetRank = 0;
+ var offset = 0;
+ for(var i, b in thisbox){
+ var offset0 = offset;
+ var offsetRank1 = offsetRank;
+ var offset1 = offset+b[_width];
+ if(offset1>thisbox[_width] and i!=0){
+ offsetRank1 += rankSize;
+ offset0 = 0;
+ offset1 = b[_width];
+ rankSize = 0;
+ }
+
+ rankSize = max(rankSize, b[_height]);
+
+ b[_x] = offset0;
+ b[_y] = offsetRank1;
+
+ offset = offset1;
+ offsetRank = offsetRank1;
+ }
+ thisbox[_height] = offsetRank + rankSize;
+ };
- /** So content doesn't shrink */
- $content.height ++= function(v) { minheight = v; return; }
- /** initialize colspan and assign width->colspan update trap */
- $content.ChildAdded ++= function(v) { v.colspan = v.width; v.width ++=
static.childWrite; return; }
+ const reflowTrap = function(v) {
+ cascade = v;
+ doReflow();
+ };
+ thisbox.orient ++= function(v){
+ cascade = v;
+ if("horizontal"==v){
+ _x = "x";
+ _y = "y";
+ _width = "width";
+ _height = "height";
+
+
+ }else{
+ _x = "y";
+ _y = "x";
+ _height = "width";
+ _width = "height";
+ }
+
+ thisbox[_width] ++= reflowTrap;
+ thisbox[_height] --= reflowTrap;
+
+ };
+ orient = "horizontal";
+
+
+ thisbox.visible ++= function(v) {
+ cascade = v;
+ if(v and dirty){
+ doReflow();
+ }
+ };
+
+ thisbox.Children ++= function(v){
+ cascade = v;
+ doReflow();
+ };
+
</ui:box>
- /** match content width to colspans so they flow in the grid */
- static.childWrite = function(v) { trapee.colspan = v; }
-
</vexi>
Added: branches/vexi3/org.vexi-vexi.widgets/src_poke/poke/layout/PokeFlow.t
===================================================================
--- branches/vexi3/org.vexi-vexi.widgets/src_poke/poke/layout/PokeFlow.t
(rev 0)
+++ branches/vexi3/org.vexi-vexi.widgets/src_poke/poke/layout/PokeFlow.t
2015-01-25 22:38:44 UTC (rev 4759)
@@ -0,0 +1,32 @@
+<!-- public domain -->
+
+<vexi xmlns:ui="vexi://ui"
+ xmlns:wi="vexi.widget"
+ xmlns:lay="vexi.layout"
+ xmlns:lang="vexi://lang">
+ <ui:box fill="white">
+ <lang:subtemplate property="Item">
+ <wi:border width="200" height="30" border="black" depth="1"/>
+ </lang:subtemplate>
+
+ <ui:Box align="topleft">
+ <lay:flow id="flow1" fill="red"/>
+ </ui:Box>
+ <ui:Box align="topleft">
+ <lay:flow id="flow2" fill="blue" orient="vertical"/>
+ </ui:Box>
+
+ const addItem = function(flow, i){
+ const item = new Item();
+ item.text = "Item "+i;
+ flow.add(item);
+ }
+
+ for(var i=0; 12>i; i++){
+ addItem($flow1, i);
+ addItem($flow2, i);
+ }
+
+ vexi.ui.frame = thisbox;
+ </ui:box>
+</vexi>
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn