Rename Item#transformContent to the more correct Item#applyMatrix

This commit is contained in:
Jürg Lehni 2014-03-02 16:04:17 +01:00
parent fb1420eee0
commit 80a725d08a
11 changed files with 47 additions and 36 deletions

View file

@ -29,7 +29,7 @@
path.smooth();
layer.insertChild(0, new Group({
children: [path],
transformContent: false
applyMatrix: false
}));
}

View file

@ -42,7 +42,7 @@
this.item = new Group({
children: [ball],
transformContent: false,
applyMatrix: false,
position: this.point
});
}

View file

@ -11,11 +11,11 @@
var yesGroup = words.children.yes;
var noGroup = words.children.no;
// Imported SVG Groups have their transformContent flag turned off by
// Imported SVG Groups have their applyMatrix flag turned off by
// default. This is required for SVG importing to work correctly. Turn
// it on now, so we don't have to deal with nested coordinate spaces.
yesGroup.transformContent = true;
noGroup.transformContent = true;
yesGroup.applyMatrix = true;
noGroup.applyMatrix = true;
// Resize the words to fit snugly inside the view:
project.activeLayer.fitBounds(view.bounds);

View file

@ -27,7 +27,7 @@
var group = new Group({
children: [leftPath, rightPath],
transformContent: false,
applyMatrix: false,
strokeWidth: 30,
strokeJoin: 'round',
strokeCap: 'butt',

View file

@ -53,8 +53,8 @@ var Item = Base.extend(Callback, /** @lends Item# */{
_class: 'Item',
// All items apply their matrix by default.
// Exceptions are Raster, PlacedSymbol, Clip and Shape.
_transformContent: true,
_canTransformContent: true,
_applyMatrix: true,
_canApplyMatrix: true,
_boundsSelected: false,
_selectChildren: false,
// Provide information about fields to be serialized, with their defaults
@ -70,7 +70,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
guide: false,
selected: false,
clipMask: false,
transformContent: null,
applyMatrix: null,
data: {}
},
@ -1134,7 +1134,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
setMatrix: function(matrix) {
// Use Matrix#initialize to easily copy over values.
this._matrix.initialize(matrix);
if (this._transformContent) {
if (this._applyMatrix) {
// Directly apply the internal matrix. This will also call
// _changed() for us.
this.transform(null, true);
@ -1173,17 +1173,24 @@ var Item = Base.extend(Callback, /** @lends Item# */{
* @default true
* @bean
*/
getTransformContent: function() {
return this._transformContent;
getApplyMatrix: function() {
return this._applyMatrix;
},
setTransformContent: function(transform) {
// Tell #transform() to apply the internal matrix if _transformContent
setApplyMatrix: function(transform) {
// Tell #transform() to apply the internal matrix if _applyMatrix
// can be set to true.
if (this._transformContent = this._canTransformContent && !!transform)
if (this._applyMatrix = this._canApplyMatrix && !!transform)
this.transform(null, true);
},
/**
* @bean
* @deprecated use {@link #getApplyMatrix()} instead.
*/
getTransformContent: '#getApplyMatrix',
setTransformContent: '#setApplyMatrix',
/**
* {@grouptitle Project Hierarchy}
* The project that this item belongs to.
@ -1492,7 +1499,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
// meaning the default value has been overwritten (default is on
// prototype).
var keys = ['_locked', '_visible', '_blendMode', '_opacity',
'_clipMask', '_guide', '_transformContent'];
'_clipMask', '_guide', '_applyMatrix'];
for (var i = 0, l = keys.length; i < l; i++) {
var key = keys[i];
if (this.hasOwnProperty(key))
@ -1984,16 +1991,16 @@ var Item = Base.extend(Callback, /** @lends Item# */{
}
}
Base.splice(children, items, index, 0);
var transformContent = this._transformContent;
var applyMatrix = this._applyMatrix;
for (var i = 0, l = items.length; i < l; i++) {
var item = items[i];
item._parent = this;
item._setProject(this._project, true);
// Only pass on the transformContent setting if it's different
// Only pass on the applyMatrix setting if it's different
// and the child has not its onw setting already.
if (item._transformContent ^ transformContent
&& !item.hasOwnProperty('_transformContent'))
item.setTransformContent(transformContent);
if (item._applyMatrix ^ applyMatrix
&& !item.hasOwnProperty('_applyMatrix'))
item.setApplyMatrix(applyMatrix);
// Setting the name again makes sure all name lookup structures
// are kept in sync.
if (item._name)
@ -2059,6 +2066,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
* the list of children and moving it above all other children. You can
* use this function for groups, compound paths and layers.
*
* @function
* @param {Item} item The item to be appended as a child
* @deprecated use {@link #addChild(item)} instead.
*/
@ -2079,6 +2087,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
/**
* Moves this item above the specified item.
*
* @function
* @param {Item} item The item above which it should be moved
* @return {Boolean} {@true if it was moved}
* @deprecated use {@link #insertAbove(item)} instead.
@ -2088,6 +2097,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
/**
* Moves the item below the specified item.
*
* @function
* @param {Item} item the item below which it should be moved
* @return {Boolean} {@true if it was moved}
* @deprecated use {@link #insertBelow(item)} instead.
@ -2767,11 +2777,11 @@ var Item = Base.extend(Callback, /** @lends Item# */{
// 'lines'. Default: ['objects', 'children']
transform: function(matrix, _applyMatrix) {
// If no matrix is provided, or the matrix is the identity, we might
// still have some work to do in case _transformContent is true
// still have some work to do in case _applyMatrix is true
if (matrix && matrix.isIdentity())
matrix = null;
var _matrix = this._matrix,
applyMatrix = (_applyMatrix || this._transformContent)
applyMatrix = (_applyMatrix || this._applyMatrix)
// Don't apply _matrix if the result of concatenating with
// matrix would be identity.
&& (!_matrix.isIdentity() || matrix);
@ -2781,11 +2791,11 @@ var Item = Base.extend(Callback, /** @lends Item# */{
// Simply preconcatenate the internal matrix with the passed one:
if (matrix)
_matrix.preConcatenate(matrix);
// Call #_applyMatrix() now, if we need to directly apply the internal
// _matrix transformations to the item's content.
// Call #_transformContent() now, if we need to directly apply the
// internal _matrix transformations to the item's content.
// Application is not possible on Raster, PointText, PlacedSymbol, since
// the matrix is where the actual transformation state is stored.
if (applyMatrix = applyMatrix && this._applyMatrix(_matrix)) {
if (applyMatrix = applyMatrix && this._transformContent(_matrix)) {
// When the _matrix could be applied, we also need to transform
// color styles (only gradients so far) and pivot point:
var pivot = this._pivot,
@ -2841,7 +2851,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
return this;
},
_applyMatrix: function(matrix) {
_transformContent: function(matrix) {
var children = this._children;
if (children) {
for (var i = 0, l = children.length; i < l; i++)

View file

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

View file

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

View file

@ -19,8 +19,8 @@
*/
var Shape = Item.extend(/** @lends Shape# */{
_class: 'Shape',
_transformContent: false,
_canTransformContent: false,
_applyMatrix: false,
_canApplyMatrix: false,
_boundsSelected: true,
_serializeFields: {
shape: null,

View file

@ -347,7 +347,7 @@ var Path = PathItem.extend(/** @lends Path# */{
return true;
},
_applyMatrix: function(matrix) {
_transformContent: function(matrix) {
var coords = new Array(6);
for (var i = 0, l = this._segments.length; i < l; i++)
this._segments[i]._transformCoordinates(matrix, coords, true);

View file

@ -81,7 +81,7 @@ new function() {
if (!isClip) {
// Have the group not pass on all transformations to its children,
// as this is how SVG works too.
item._transformContent = false;
item._applyMatrix = false;
item = applyAttributes(item, node, isRoot);
// Style on items needs to be handled differently than all other
// items: We first apply the style to the item, then use it as the

View file

@ -24,7 +24,8 @@
var TextItem = Item.extend(/** @lends TextItem# */{
_class: 'TextItem',
_boundsSelected: true,
_transformContent: false,
_applyMatrix: false,
_canApplyMatrix: false,
_serializeFields: {
content: null
},