Revision: 2708 http://vexi.svn.sourceforge.net/vexi/?rev=2708&view=rev Author: clrg Date: 2008-01-02 04:50:38 -0800 (Wed, 02 Jan 2008)
Log Message: ----------- Fix pad/margin writes to fire relevant top/bottom/left/right traps Modified Paths: -------------- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/margin.t trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/pad.t Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/margin.t =================================================================== --- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/margin.t 2008-01-02 12:49:35 UTC (rev 2707) +++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/margin.t 2008-01-02 12:50:38 UTC (rev 2708) @@ -29,16 +29,47 @@ // initialize meta properties to 0 thisbox.margin = 0; - // if we are used as a margin - thisbox.margin ++= pad..paddingFunc; - thisbox.margintop ++= pad..topWriteFunc; - thisbox.margintop ++= pad..topReadFunc; - thisbox.marginright ++= pad..rightWriteFunc; - thisbox.marginright ++= pad..rightReadFunc; - thisbox.marginbottom ++= pad..bottomWriteFunc; - thisbox.marginbottom ++= pad..bottomReadFunc; - thisbox.marginleft ++= pad..leftWriteFunc; - thisbox.marginleft ++= pad..leftReadFunc; + // apply static trap functions + thisbox.margin ++= static.marginWrite; + thisbox.margintop ++= pad..topWrite; + thisbox.margintop ++= pad..topRead; + thisbox.marginright ++= pad..rightWrite; + thisbox.marginright ++= pad..rightRead; + thisbox.marginbottom ++= pad..bottomWrite; + thisbox.marginbottom ++= pad..bottomRead; + thisbox.marginleft ++= pad..leftWrite; + thisbox.marginleft ++= pad..leftRead; - </ui:box> + </ui:box> + + /** padding trap function - accepts arg v in form "TRBL", "TB RL", "T R B L" */ + static.marginWrite = function(v) { + cascade = v; + var p = v.split(' '); + + // single arg + if (p.length == 1) { + trapee.margintop = v; + trapee.marginleft = v; + trapee.marginright = v; + trapee.marginbottom = v; + + // two args (vpad,hpad) + } else if (p.length == 2) { + trapee.margintop = p[0]; + trapee.marginleft = p[1]; + trapee.marginright = p[1]; + trapee.marginbottom = p[0]; + + // four args (t,r,b,l) + } else if (p.length == 4) { + trapee.margintop = p[0]; + trapee.marginleft = p[3]; + trapee.marginright = p[1]; + trapee.marginbottom = p[2]; + + // invalid args + } else vexi.log.warn("Invalid number of values for margin: "+p.length+" from '"+v+"'"); + } + </vexi> Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/pad.t =================================================================== --- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/pad.t 2008-01-02 12:49:35 UTC (rev 2707) +++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/pad.t 2008-01-02 12:50:38 UTC (rev 2708) @@ -6,9 +6,7 @@ <author>Charles Goodwin</author> <notes> * differentiate between pt and px - * trapping margins will not work - * changing individual pads (top/left etc) does not update catch-all 'padding' property - * trapping on padding properties in general is broken + * changing individual pads (top/left etc) does not update 'padding' property </notes> </meta:doc> @@ -30,61 +28,60 @@ // initialize meta properties to 0 thisbox.padding = 0; - thisbox.margin = 0; - // by default we are used as padding - thisbox.padding ++= static.paddingFunc; - thisbox.paddingtop ++= static.topWriteFunc; - thisbox.paddingtop ++= static.topReadFunc; - thisbox.paddingright ++= static.rightWriteFunc; - thisbox.paddingright ++= static.rightReadFunc; - thisbox.paddingbottom ++= static.bottomWriteFunc; - thisbox.paddingbottom ++= static.bottomReadFunc; - thisbox.paddingleft ++= static.leftWriteFunc; - thisbox.paddingleft ++= static.leftReadFunc; + // apply static trap functions + thisbox.padding ++= static.paddingWrite; + thisbox.paddingtop ++= static.topWrite; + thisbox.paddingtop ++= static.topRead; + thisbox.paddingright ++= static.rightWrite; + thisbox.paddingright ++= static.rightRead; + thisbox.paddingbottom ++= static.bottomWrite; + thisbox.paddingbottom ++= static.bottomRead; + thisbox.paddingleft ++= static.leftWrite; + thisbox.paddingleft ++= static.leftRead; </ui:box> /** padding trap function - accepts arg v in form "TRBL", "TB RL", "T R B L" */ - static.paddingFunc = function(v) { + static.paddingWrite = function(v) { cascade = v; var p = v.split(' '); // single arg if (p.length == 1) { - trapee.v_tpad.height = v; - trapee.v_rpad.width = v; - trapee.v_bpad.height = v; - trapee.v_lpad.width = v; + trapee.paddingtop = v; + trapee.paddingleft = v; + trapee.paddingright = v; + trapee.paddingbottom = v; // two args (vpad,hpad) } else if (p.length == 2) { - trapee.v_tpad.height = p[0]; - trapee.v_rpad.width = p[1]; - trapee.v_bpad.height = p[0]; - trapee.v_lpad.width = p[1]; + trapee.paddingtop = p[0]; + trapee.paddingleft = p[1]; + trapee.paddingright = p[1]; + trapee.paddingbottom = p[0]; // four args (t,r,b,l) } else if (p.length == 4) { - trapee.v_tpad.height = p[0]; - trapee.v_rpad.width = p[1]; - trapee.v_bpad.height = p[2]; - trapee.v_lpad.width = p[3]; + trapee.paddingtop = p[0]; + trapee.paddingleft = p[3]; + trapee.paddingright = p[1]; + trapee.paddingbottom = p[2]; // invalid args - } else vexi.log.warn("Invalid number of values for padding: " + p.length); + } else vexi.log.warn("Invalid number of values for padding: "+p.length+" from '"+v+"'"); } // direct write redirect functions for padding* properties - static.topWriteFunc = function(v) { cascade = null; trapee.v_tpad.height = v; } - static.rightWriteFunc = function(v) { cascade = null; trapee.v_rpad.width = v; } - static.bottomWriteFunc = function(v) { cascade = null; trapee.v_bpad.height = v; } - static.leftWriteFunc = function(v) { cascade = null; trapee.v_lpad.width = v; } + static.topWrite = function(v) { cascade = null; trapee.v_tpad.height = v; } + static.rightWrite = function(v) { cascade = null; trapee.v_rpad.width = v; } + static.bottomWrite = function(v) { cascade = null; trapee.v_bpad.height = v; } + static.leftWrite = function(v) { cascade = null; trapee.v_lpad.width = v; } // direct read redirect functions for padding* properties - static.topReadFunc = function() { return trapee.v_tpad.height; } - static.rightReadFunc = function() { return trapee.v_rpad.width; } - static.bottomReadFunc = function() { return trapee.v_bpad.height; } - static.leftReadFunc = function() { return trapee.v_lpad.width; } + static.topRead = function() { return trapee.v_tpad.height; } + static.rightRead = function() { return trapee.v_rpad.width; } + static.bottomRead = function() { return trapee.v_bpad.height; } + static.leftRead = function() { return trapee.v_lpad.width; } </vexi> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn