Revision: 4731 http://sourceforge.net/p/vexi/code/4731 Author: clrg Date: 2014-09-11 23:50:27 +0000 (Thu, 11 Sep 2014) Log Message: ----------- Fix vexi.layout.ratio / add poke
Modified Paths: -------------- branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/lib/layout/ratio.t Added Paths: ----------- branches/vexi3/org.vexi-vexi.widgets/src_poke/poke/layout/ratio.t Modified: branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/lib/layout/ratio.t =================================================================== --- branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/lib/layout/ratio.t 2014-09-10 22:57:29 UTC (rev 4730) +++ branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/lib/layout/ratio.t 2014-09-11 23:50:27 UTC (rev 4731) @@ -1,11 +1,34 @@ -<!-- Copyright 2013 - see COPYING for details [LGPL] --> +<!-- Copyright 2014 - see COPYING for details [LGPL] --> -<vexi xmlns:ui="vexi://ui" xmlns:role="org.vexi.lib.role"> +<vexi xmlns:ui="vexi://ui" + xmlns:role="org.vexi.lib.role"> + <role:polarizable /> - <ui:box> + <ui:Box> var totalRatio = 0; + + const resizeChildren = function() { + var factor = thisbox[dim] / totalRatio; + var remainder = 0; + var totalSize = 0; + for (var i,child in thisbox) { + if (child.display) { + var rawSize = (child.ratio * factor) + remainder; + var actSize = vexi.math.round(rawSize); + remainder = rawSize - actSize; + child[dim] = actSize; + totalSize += actSize; + } + } + if (totalSize != thisbox[dim]) { + thisbox[numchildren-1][dim] += (thisbox[dim] - totalSize); + } + } + const updateTotal = function(v) { + if (typeof v != "number") + throw "ratio must be a number"; var oldRatio = trapee.ratio; cascade = v==null?1:v; totalRatio = totalRatio - oldRatio + trapee.ratio; @@ -23,25 +46,24 @@ totalRatio -= v.ratio; } cascade = v; + // resize if necessary + if (trapee[dim]>0) resizeChildren(); } - thisbox.Resize ++= function(v) { - var factor = thisbox[dim] / totalRatio; - var remainder = 0; - var totalSize = 0; - for (var i,child in thisbox) { - if (child.display) { - var rawSize = (child.ratio * factor) + remainder; - var actSize = vexi.math.round(rawSize); - remainder = rawSize - actSize; - child[dim] = actSize; - totalSize += actSize; - } - } - if (totalSize != thisbox[dim]) { - thisbox[numchildren-1][dim] += (thisbox[dim] - totalSize); - } + const invokeResize = function(v) { + cascade = v; + resizeChildren(); } - </ui:box> + thisbox[dim] ++= invokeResize; + + thisbox.orient ++= function(v) { + trapee[dim] --= invokeResize; + casacde = v; + trapee[dim] ++= invokeResize; + // resize if necessary + if (trapee[dim]>0) resizeChildren(); + } + + </ui:Box> </vexi> Added: branches/vexi3/org.vexi-vexi.widgets/src_poke/poke/layout/ratio.t =================================================================== --- branches/vexi3/org.vexi-vexi.widgets/src_poke/poke/layout/ratio.t (rev 0) +++ branches/vexi3/org.vexi-vexi.widgets/src_poke/poke/layout/ratio.t 2014-09-11 23:50:27 UTC (rev 4731) @@ -0,0 +1,28 @@ +<!-- public domain --> + +<vexi xmlns:ui="vexi://ui" xmlns="vexi.layout"> + <ui:box orient="vertical" fill="white"> + <ui:box height="20" /> + <ratio> + <ui:Box text="ratio=1" fill="red" /> + <ui:Box text="ratio=2" ratio="2" fill="blue" /> + <ui:Box text="ratio=1" fill="green" /> + </ratio> + <ui:box height="20" /> + <ratio> + <ui:Box text="ratio=50" ratio="50" fill="red" /> + <ui:Box text="ratio=25" ratio="25" fill="blue" /> + <ui:Box text="ratio=25" ratio="25" fill="green" /> + </ratio> + <ui:box height="20" /> + <ratio> + <ui:Box text="ratio=30" ratio="30" fill="red" /> + <ui:Box text="ratio=60" ratio="60" fill="blue" /> + <ui:Box text="ratio=90" ratio="90" fill="green" /> + </ratio> + <ui:box height="20" /> + + 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. ------------------------------------------------------------------------------ Want excitement? Manually upgrade your production database. When you want reliability, choose Perforce Perforce version control. Predictably reliable. http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn