Add an update() function to SVGEditTransformList
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@882 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
54e5ff8c09
commit
3d5fa78f67
|
@ -577,22 +577,43 @@ function BatchCommand(text) {
|
||||||
// of SVGTransformList that we need to get the job done.
|
// of SVGTransformList that we need to get the job done.
|
||||||
//
|
//
|
||||||
// interface SVGEditTransformList {
|
// interface SVGEditTransformList {
|
||||||
// attribute unsigned long numberOfItems;
|
// attribute unsigned long numberOfItems;
|
||||||
// void clear ( )
|
// void clear ( )
|
||||||
// SVGTransform initialize ( in SVGTransform newItem )
|
// SVGTransform initialize ( in SVGTransform newItem )
|
||||||
// SVGTransform getItem ( in unsigned long index )
|
// SVGTransform getItem ( in unsigned long index )
|
||||||
// SVGTransform insertItemBefore ( in SVGTransform newItem, in unsigned long index )
|
// SVGTransform insertItemBefore ( in SVGTransform newItem, in unsigned long index )
|
||||||
// SVGTransform replaceItem ( in SVGTransform newItem, in unsigned long index )
|
// SVGTransform replaceItem ( in SVGTransform newItem, in unsigned long index )
|
||||||
// SVGTransform removeItem ( in unsigned long index )
|
// SVGTransform removeItem ( in unsigned long index )
|
||||||
// SVGTransform appendItem ( in SVGTransform newItem )
|
// SVGTransform appendItem ( in SVGTransform newItem )
|
||||||
// SVGTransform createSVGTransformFromMatrix ( in SVGMatrix matrix );
|
// SVGTransform createSVGTransformFromMatrix ( in SVGMatrix matrix );
|
||||||
// SVGTransform consolidate ( );
|
// SVGTransform consolidate ( );
|
||||||
// }
|
// }
|
||||||
// **************************************************************************************
|
// **************************************************************************************
|
||||||
var svgTransformLists = {};
|
var svgTransformLists = {};
|
||||||
var SVGEditTransformList = function(elem) {
|
var SVGEditTransformList = function(elem) {
|
||||||
this._elem = elem || null;
|
this._elem = elem || null;
|
||||||
this._xforms = [];
|
this._xforms = [];
|
||||||
|
this._update = function() {
|
||||||
|
var tstr = "";
|
||||||
|
for (var i = 0; i < _this.numberOfItems; ++i) {
|
||||||
|
var xform = _this.getItem(i);
|
||||||
|
var m = xform.matrix;
|
||||||
|
switch (xform.type) {
|
||||||
|
case 2: // translate
|
||||||
|
tstr += "translate(" + m.e + "," + m.f + ") ";
|
||||||
|
break;
|
||||||
|
case 3: // scale
|
||||||
|
if (m.a == m.d) tstr += "scale(" + m.a + ") ";
|
||||||
|
else tstr += "scale(" + m.a + "," + m.d + ") ";
|
||||||
|
break;
|
||||||
|
case 4: // rotate (with a translate?)
|
||||||
|
// TODO: can i get the center right here and now from bbox?
|
||||||
|
tstr += "rotate(" + xform.angle + ") ";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_this._elem.setAttribute("transform", tstr);
|
||||||
|
};
|
||||||
_this = this;
|
_this = this;
|
||||||
|
|
||||||
this.numberOfItems = 0;
|
this.numberOfItems = 0;
|
||||||
|
@ -613,8 +634,6 @@ function BatchCommand(text) {
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: update all functions that modify the transform list to update
|
|
||||||
// the actual element
|
|
||||||
this.insertItemBefore = function(newItem, index) {
|
this.insertItemBefore = function(newItem, index) {
|
||||||
var retValue = null;
|
var retValue = null;
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
|
@ -631,7 +650,7 @@ function BatchCommand(text) {
|
||||||
_this.numberOfItems++;
|
_this.numberOfItems++;
|
||||||
_this._xforms = newxforms;
|
_this._xforms = newxforms;
|
||||||
retValue = newItem;
|
retValue = newItem;
|
||||||
// TODO: modify the element's transform
|
_this._update();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
retValue = _this.appendItem(newItem);
|
retValue = _this.appendItem(newItem);
|
||||||
|
@ -645,7 +664,7 @@ function BatchCommand(text) {
|
||||||
if (index < _this.numberOfItems && index >= 0) {
|
if (index < _this.numberOfItems && index >= 0) {
|
||||||
_this._xforms[index] = newItem;
|
_this._xforms[index] = newItem;
|
||||||
retValue = newItem;
|
retValue = newItem;
|
||||||
// TODO: modify the element's transform
|
_this._update();
|
||||||
}
|
}
|
||||||
return retValue;
|
return retValue;
|
||||||
};
|
};
|
||||||
|
@ -663,7 +682,7 @@ function BatchCommand(text) {
|
||||||
}
|
}
|
||||||
_this.numberOfItems--;
|
_this.numberOfItems--;
|
||||||
_this._xforms = newxforms;
|
_this._xforms = newxforms;
|
||||||
// TODO: modify the element's transform
|
_this._update();
|
||||||
}
|
}
|
||||||
return retValue;
|
return retValue;
|
||||||
};
|
};
|
||||||
|
@ -671,7 +690,7 @@ function BatchCommand(text) {
|
||||||
this.appendItem = function(newItem) {
|
this.appendItem = function(newItem) {
|
||||||
_this._xforms.push(newItem);
|
_this._xforms.push(newItem);
|
||||||
_this.numberOfItems++;
|
_this.numberOfItems++;
|
||||||
// TODO: modify the element's transform
|
_this._update();
|
||||||
return newItem;
|
return newItem;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue