Revision: 4456 http://vexi.svn.sourceforge.net/vexi/?rev=4456&view=rev Author: clrg Date: 2012-11-21 14:48:06 +0000 (Wed, 21 Nov 2012) Log Message: ----------- Table column resizing done properly - fixes foot resizes - only assigns fixed sizes if done by user - unresized/!hshrink columns take up slack
Modified Paths: -------------- trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/head.t trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/table.t trunk/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/column.t trunk/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/head.t trunk/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/row.t trunk/org.vexi-vexi.widgets/src_poke/visualtest/table.t Modified: trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/head.t =================================================================== --- trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/head.t 2012-11-12 14:43:42 UTC (rev 4455) +++ trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/head.t 2012-11-21 14:48:06 UTC (rev 4456) @@ -1,13 +1,14 @@ <!-- Copyright 2012 - see COPYING for details [LGPL] --> -<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" xmlns="org.vexi.lib.widget"> - <meta:doc> - <author>Charles Goodwin</author> - </meta:doc> +<vexi xmlns:ui="vexi://ui" + xmlns="org.vexi.lib.widget"> <ui:box> - var syncResizeTabs = function() { + thisbox.fixedsize = false; + thisbox.headwidth; + + const syncResizeTabs = function() { var resizePrev = false; for (var i,col in thisbox) { col.resizeLeft = resizePrev; @@ -20,59 +21,46 @@ syncResizeTabs(); } + const checkFixedSize = function() { + var slack = true; + for (var i,c in thisbox) { + if (c.minwidth == c.maxwidth or c.hshrink) + continue; + slack = false; + break; + } + fixedsize = slack; + } + thisbox.Children ++= function(c) { if (c) { c.dragStart ++= function(v) { - var colL, colR; - var widthL, widthR; + var col, colwidth; var i = indexof(c); var m = c.mouse; if (c.th_resizeLeft.mouse.inside) { - colL = thisbox[i-1]; - colR = c; + col = thisbox[i-1]; } if (c.th_resizeRight.mouse.inside) { - colL = c; - colR = thisbox[i+1]; + col = c; } - colL.width = colL.width; - colR.width = colR.width; - widthL = colL.width; - widthR = colR.width; + col.width = col.width; + colwidth = col.width; c.dragUpdate ++= function(d) { - colL.width = vexi.math.min(widthL+widthR-8, vexi.math.max(8, widthL + d.x)); - colR.width = widthL+widthR-colL.width; + cascade = v; + checkFixedSize(); + trapee[trapname] --= callee; } + c.dragUpdate ++= function(d) { + cascade = v; + col.width = vexi.math.max(8, colwidth + d.x); + } } } cascade = c; + checkFixedSize(); syncResizeTabs(); } - thisbox.width ++= function(v) { - cascade = v; - var colwidth = 0; - var expcount = 0; - var maxcount = 0; - for (var i,col in thisbox) { - colwidth += col.width; - if (col.hshrink) continue; - if (col.minwidth == col.maxwidth) { - maxcount ++; - continue; - } - expcount ++; - } - if (expcount > 0) return; - for (var i,col in thisbox) { - if (col.hshrink) continue; - var slack = (width - colwidth) / maxcount; - col.width += slack; - maxcount --; - colwidth += slack; - } - } - </ui:box> - </vexi> Modified: trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/table.t =================================================================== --- trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/table.t 2012-11-12 14:43:42 UTC (rev 4455) +++ trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/table.t 2012-11-21 14:48:06 UTC (rev 4456) @@ -1,11 +1,9 @@ -<!-- Copyright 2009 - see COPYING for details [LGPL] --> +<!-- Copyright 2012 - see COPYING for details [LGPL] --> -<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" xmlns="vexi.theme" - xmlns:lib="org.vexi.lib" xmlns:util="vexi.util"> - <meta:doc> - <author>Charles Goodwin</author> - <author>Mike Goodwin</author> - </meta:doc> +<vexi xmlns:ui="vexi://ui" + xmlns:lib="org.vexi.lib" + xmlns:util="vexi.util" + xmlns="vexi.theme"> static.new_fakeviewport = function() { var fvp = {}; @@ -445,36 +443,20 @@ }; } - /** match column minwidths with column header contentwidth */ - var col_minwidthWrite = function(v) { - cascade = v; - var ind = th_head.indexof(trapee); - if (th_foot and th_foot[ind]) { - th_foot[ind].minwidth = v; - } - var n = th_body.numchildren; - for (var i=0; n>i; i++) { - var c = th_body[i][ind]; - if (c) { - c.minwidth = v; - } - } - } - /** match column properties to column header properties */ var col_propWrite = function(v) { cascade = v; var ind = th_head.indexof(trapee); - if (th_foot and th_foot[ind]) { - th_foot[ind][trapname] = v; + if (th_foot) { + for (var i,r in th_foot) + if (r[ind]) + r[ind][trapname] = v; } - var n = th_body.numchildren; - for (var i=0; n>i; i++) { - th_body[i][ind][trapname] = v; - } + for (var i,r in th_body) + r[ind][trapname] = v; } - var setupRowContainer = function(c){ + var setupRowContainer = function(c) { /** assign v_head automatically */ c.Children ++= function(r) { if (r) { @@ -512,7 +494,7 @@ for (var i=0; c.numchildren > i; i++) { var h = c[i]; h.action ++= actionWrite; - h.contentwidth ++= col_minwidthWrite; + h.width ++= col_propWrite; h.display ++= col_propWrite; h.hshrink ++= col_propWrite; h.maxwidth ++= col_propWrite; @@ -522,7 +504,7 @@ c.Children ++= function(h) { if (h) { h.action ++= actionWrite; - h.contentwidth ++= col_minwidthWrite; + h.width ++= col_propWrite; h.display ++= col_propWrite; h.hshrink ++= col_propWrite; h.maxwidth ++= col_propWrite; @@ -530,7 +512,7 @@ var _h = c[trapname]; if (_h) { _h.action --= actionWrite; - _h.contentwidth --= col_minwidthWrite; + _h.width --= col_propWrite; _h.display --= col_propWrite; _h.hshrink --= col_propWrite; _h.maxwidth --= col_propWrite; @@ -538,6 +520,15 @@ } cascade = h; }; + + c.headwidth ++= function(v) { + cascade = v; + var n = th_body.numchildren; + for (var i,r in th_body) + r.rowwidth = v; + for (var i,r in th_foot) + r.rowwidth = v; + } return; } Modified: trunk/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/column.t =================================================================== --- trunk/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/column.t 2012-11-12 14:43:42 UTC (rev 4455) +++ trunk/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/column.t 2012-11-21 14:48:06 UTC (rev 4456) @@ -8,12 +8,15 @@ <ui:box redirect=":$content" hshrink="false" margin="0" padding="2 1"> <ui:box align="left" layout="layer" minwidth="8"> <bevel id="bevel" form="up"> - <ui:box id="wrap"> - <ui:box id="sp_left" align="right" minwidth="8" display="false"> - <ui:box id="sort" shrink="true" /> + <ui:box layout="place" vshrink="true"> + <ui:box id="wrap" vshrink="true"> + <ui:box id="sp_left" align="right" minwidth="8" display="false"> + <ui:box id="sort" shrink="true" /> + </ui:box> + <ui:box id="content" /> + <ui:box id="sp_right" minwidth="8" display="false" /> </ui:box> - <ui:box id="content" /> - <ui:box id="sp_right" minwidth="8" display="false" /> + $wrap.height ++= function(v) { cascade = v; minheight = v; } </ui:box> </bevel> <ui:box> Modified: trunk/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/head.t =================================================================== --- trunk/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/head.t 2012-11-12 14:43:42 UTC (rev 4455) +++ trunk/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/head.t 2012-11-21 14:48:06 UTC (rev 4456) @@ -1,9 +1,25 @@ -<!-- Copyright 2011 - see COPYING for details [LGPL] --> +<!-- Copyright 2012 - see COPYING for details [LGPL] --> -<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" xmlns="org.vexi.lib.widget"> - <meta:doc> - <author>Charles Goodwin</author> - </meta:doc> +<vexi xmlns:ui="vexi://ui" + xmlns:lib="org.vexi.lib.widget" + xmlns="vexi.theme"> - <head /> + <lib:head redirect=":$content"> + <ui:box id="content" /> + <bevel id="bookend" form="up" display="false" /> + + const widthUpdate = function(v) { + cascade = v; + thisbox.headwidth = v; + } + + thisbox.fixedsize ++= function(v) { + cascade = v; + $bookend.display = v; + $content.hshrink = v; + if (v) $content.width ++= widthUpdate; + else $content.width --= widthUpdate; + } + + </lib:head> </vexi> Modified: trunk/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/row.t =================================================================== --- trunk/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/row.t 2012-11-12 14:43:42 UTC (rev 4455) +++ trunk/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/row.t 2012-11-21 14:48:06 UTC (rev 4456) @@ -4,9 +4,16 @@ xmlns:lib="org.vexi.lib.widget" xmlns="vexi.theme"> - <lib:row vshrink="true"> + <lib:row redirect=":$content" vshrink="true"> + <ui:box id="content" /> + <ui:box id="bookend" display="false" /> thisbox.focused ++= static.focusWrite; + thisbox.rowwidth ++= function(v) { + cascade = v; + $bookend.display = true; + $content.width = v; + } minheight = static.rowheight; Modified: trunk/org.vexi-vexi.widgets/src_poke/visualtest/table.t =================================================================== --- trunk/org.vexi-vexi.widgets/src_poke/visualtest/table.t 2012-11-12 14:43:42 UTC (rev 4455) +++ trunk/org.vexi-vexi.widgets/src_poke/visualtest/table.t 2012-11-21 14:48:06 UTC (rev 4456) @@ -6,4 +6,4 @@ vexi.ui.frame = thisbox; </ui:box> -</vexi> \ No newline at end of file +</vexi> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Monitor your physical, virtual and cloud infrastructure from a single web console. Get in-depth insight into apps, servers, databases, vmware, SAP, cloud infrastructure, etc. Download 30-day Free Trial. Pricing starts from $795 for 25 servers or applications! http://p.sf.net/sfu/zoho_dev2dev_nov _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn