Make sure that #transformContent can only be set to true on items that actually support it.

This commit is contained in:
Jürg Lehni 2014-03-01 23:24:33 +01:00
parent 1a836a168f
commit 4ba17127aa
4 changed files with 9 additions and 6 deletions

View file

@ -54,6 +54,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
// All items apply their matrix by default. // All items apply their matrix by default.
// Exceptions are Raster, PlacedSymbol, Clip and Shape. // Exceptions are Raster, PlacedSymbol, Clip and Shape.
_transformContent: true, _transformContent: true,
_canTransformContent: true,
_boundsSelected: false, _boundsSelected: false,
_selectChildren: false, _selectChildren: false,
// Provide information about fields to be serialized, with their defaults // Provide information about fields to be serialized, with their defaults
@ -1173,8 +1174,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
}, },
setTransformContent: function(transform) { setTransformContent: function(transform) {
this._transformContent = !!transform; if (this._transformContent = this._canTransformContent && !!transform)
if (transform)
this.applyMatrix(); this.applyMatrix();
}, },
@ -1987,7 +1987,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
// and the child has not its onw setting already. // and the child has not its onw setting already.
if (item._transformContent ^ transformContent if (item._transformContent ^ transformContent
&& !item.hasOwnProperty('_transformContent')) && !item.hasOwnProperty('_transformContent'))
item.setTransformContent(transformContent) item.setTransformContent(transformContent);
// Setting the name again makes sure all name lookup structures // Setting the name again makes sure all name lookup structures
// are kept in sync. // are kept in sync.
if (item._name) if (item._name)
@ -2841,9 +2841,9 @@ var Item = Base.extend(Callback, /** @lends Item# */{
// Reset the internal matrix to the identity transformation if it // Reset the internal matrix to the identity transformation if it
// was possible to apply it. // was possible to apply it.
matrix.reset(true); matrix.reset(true);
}
if (!_dontNotify) if (!_dontNotify)
this._changed(/*#=*/ Change.GEOMETRY); this._changed(/*#=*/ Change.GEOMETRY);
}
return this; return this;
}, },

View file

@ -21,6 +21,7 @@
var PlacedSymbol = Item.extend(/** @lends PlacedSymbol# */{ var PlacedSymbol = Item.extend(/** @lends PlacedSymbol# */{
_class: 'PlacedSymbol', _class: 'PlacedSymbol',
_transformContent: false, _transformContent: false,
_canTransformContent: false,
// PlacedSymbol uses strokeBounds for bounds // PlacedSymbol uses strokeBounds for bounds
_boundsGetter: { getBounds: 'getStrokeBounds' }, _boundsGetter: { getBounds: 'getStrokeBounds' },
_boundsSelected: true, _boundsSelected: true,

View file

@ -20,6 +20,7 @@
var Raster = Item.extend(/** @lends Raster# */{ var Raster = Item.extend(/** @lends Raster# */{
_class: 'Raster', _class: 'Raster',
_transformContent: false, _transformContent: false,
_canTransformContent: false,
// Raster doesn't make the distinction between the different bounds, // Raster doesn't make the distinction between the different bounds,
// so use the same name for all of them // so use the same name for all of them
_boundsGetter: 'getBounds', _boundsGetter: 'getBounds',

View file

@ -20,6 +20,7 @@
var Shape = Item.extend(/** @lends Shape# */{ var Shape = Item.extend(/** @lends Shape# */{
_class: 'Shape', _class: 'Shape',
_transformContent: false, _transformContent: false,
_canTransformContent: false,
_boundsSelected: true, _boundsSelected: true,
_serializeFields: { _serializeFields: {
shape: null, shape: null,