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

View file

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

View file

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

View file

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