Revision: 2131
http://vexi.svn.sourceforge.net/vexi/?rev=2131&view=rev
Author: clrg
Date: 2007-09-06 09:05:26 -0700 (Thu, 06 Sep 2007)
Log Message:
-----------
Embrace polarizable for reduced code duplication
Modified Paths:
--------------
trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/splitpane.t
Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/splitpane.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/splitpane.t
2007-09-06 15:55:52 UTC (rev 2130)
+++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/splitpane.t
2007-09-06 16:05:26 UTC (rev 2131)
@@ -16,130 +16,68 @@
thisbox.th_marker = null; // marker used when liveresize is false
var cur_d;
- var cur_l;
- var cur_r;
- var dim_l;
- var dim_r;
- var tmp_l;
- var tmp_r;
- var mx;
- var my;
+ var cur_a;
+ var cur_b;
+ var dim_a;
+ var dim_b;
+ var tmp_a;
+ var tmp_b;
+ var m_pos;
var newdiv = vexi..vexi.theme.divider;
/** reusable surface.Move dragging function */
- var xMoveFunc = function(v)
+ var moveFunc = function(v)
{
- var xshift = surface.mouse.x - mx;
- if (cur_l[0] and cur_l[0].minwidth > dim_l + xshift)
- xshift = cur_l[0].minwidth - dim_l;
- else if (0 > dim_l + xshift) xshift = -dim_l;
- if (cur_r[0] and xshift > dim_r - cur_r[0].minwidth)
- xshift = dim_r - cur_r[0].minwidth;
- else if (0 > dim_r - xshift) xshift = dim_r;
+ var shift = surface.mouse[pos] - m_pos;
+ if (0 > dim_a + shift) shift = - dim_a;
+ if (0 > dim_b - shift) shift = dim_b;
if (liveresize)
{
- if (cur_l != master) cur_l.width = dim_l + xshift;
- if (cur_r != master) cur_r.width = dim_r - xshift;
+ if (cur_a != master) cur_a[dim] = dim_a + shift;
+ if (cur_b != master) cur_b[dim] = dim_b - shift;
}
else
{
- tmp_l = dim_l + xshift;
- tmp_r = dim_r - xshift;
- th_marker.x = cur_l.x + tmp_l - markeroffset;
+ tmp_a = dim_a + shift;
+ tmp_b = dim_b - shift;
+ th_marker[pos] = cur_a[pos] + tmp_a - markeroffset;
}
cascade = v;
}
- /** reusable surface.Move dragging function */
- var yMoveFunc = function(v)
- {
- var yshift = surface.mouse.y - my;
- if (cur_l[0] and cur_l[0].minheight > dim_l + yshift)
- yshift = cur_l[0].minheight - dim_l;
- else if (0 > dim_l + yshift) yshift = -dim_l;
- if (cur_r[0] and yshift > dim_r - cur_r[0].minheight)
- yshift = dim_r - cur_r[0].minheight;
- else if (0 > dim_r - yshift) yshift = dim_r;
- if (liveresize)
- {
- if (cur_l != master) cur_l.height = dim_l + yshift;
- if (cur_r != master) cur_r.height = dim_r - yshift;
- }
- else
- {
- tmp_l = dim_l + yshift;
- tmp_r = dim_r - yshift;
- th_marker.y = cur_l.y + tmp_l - markeroffset;
- }
- cascade = v;
- }
-
/** drops moveFunc on Release */
- var xReleaseFunc = function(v)
+ var releaseFunc = function(v)
{
cur_d.active = false;
th_marker.display = false;
if (!liveresize)
{
- if (cur_l != master) cur_l.width = tmp_l;
- if (cur_r != master) cur_r.width = tmp_r;
+ if (cur_a != master) cur_a[dim] = tmp_a;
+ if (cur_b != master) cur_b[dim] = tmp_b;
}
- if (surface) surface.delMoveTrap(xMoveFunc);
- surface.Release1 --= xReleaseFunc;
+ if (surface) surface.delMoveTrap(moveFunc);
+ surface._Release1 --= releaseFunc;
cascade = v;
}
- /** drops moveFunc on Release */
- var yReleaseFunc = function(v)
- {
- cur_d.active = false;
- th_marker.display = false;
- if (!liveresize)
- {
- if (cur_l != master) cur_l.height = tmp_l;
- if (cur_r != master) cur_r.height = tmp_r;
- }
- if (surface) surface.delMoveTrap(yMoveFunc);
- surface.Release1 --= yReleaseFunc;
- cascade = v;
- }
-
/** initiate x dragging on Press */
- var xPressFunc = function(v)
+ var pressFunc = function(v)
{
var cur = th_holding.indexof(trapee);
cur_d = trapee;
cur_d.active = true;
- cur_l = th_holding[cur-1];
- cur_r = th_holding[cur+1];
- dim_l = cur_l.width;
- dim_r = cur_r.width;
- mx = surface.mouse.x;
+ cur_a = th_holding[cur-1];
+ cur_b = th_holding[cur+1];
+ dim_a = cur_a.width;
+ dim_b = cur_b.width;
+ m_pos = surface.mouse[pos];
th_marker.display = !liveresize;
- th_marker.x = cur_l.x + cur_l.width - markeroffset;
- surface.addMoveTrap(xMoveFunc);
- surface.Release1 ++= xReleaseFunc;
+ th_marker[pos] = cur_a[pos] + cur_a[dim] - markeroffset;
+ surface.addMoveTrap(moveFunc);
+ surface._Release1 ++= releaseFunc;
cascade = v;
}
- /** initiate y dragging on Press */
- var yPressFunc = function(v)
- {
- var cur = th_holding.indexof(trapee);
- cur_d = trapee;
- cur_d.active = true;
- cur_l = th_holding[cur-1];
- cur_r = th_holding[cur+1];
- dim_l = cur_l.height;
- dim_r = cur_r.height;
- my = surface.mouse.y;
- th_marker.display = !liveresize;
- th_marker.y = cur_l.y + cur_l.height - markeroffset;
- surface.addMoveTrap(yMoveFunc);
- surface.Release1 ++= yReleaseFunc;
- cascade = v;
- }
-
/** set up master section */
master ++= function(v)
{
@@ -156,15 +94,9 @@
/** update dividers when orient changes */
orient ++= function(v)
{
- var addFunc = v == "horizontal" ? xPressFunc : yPressFunc;
- var remFunc = v == "horizontal" ? yPressFunc : xPressFunc;
th_holding.orient = v;
for (var i=1; th_holding.numchildren > i; i+=2)
- {
th_holding[i].orient = flip(v);
- th_holding[i].Press1 ++= addFunc;
- th_holding[i].Press1 --= remFunc;
- }
cascade = v;
}
@@ -188,7 +120,7 @@
{
d = newdiv(vexi.box);
d.orient = flip(orient);
- d.Press1 ++= (orient == "horizontal" ? xPressFunc :
yPressFunc);
+ d.Press1 ++= pressFunc;
}
// assign new child and divider to holding
if (d and i != 0) th_holding[i*2-1] = d;
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: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn