diff --git a/src/item/Item.js b/src/item/Item.js index 93d1fec3..1728d662 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -854,7 +854,7 @@ var Item = this.Item = Base.extend(Callback, { _getBounds: function(getter, matrix, cacheItem) { // Note: We cannot cache these results here, since we do not get // _changed() notifications here for changing geometry in children. - // But cacheName is used in sub-classes such as PlacedItem. + // But cacheName is used in sub-classes such as PlacedSymbol and Raster. var children = this._children; // TODO: What to return if nothing is defined, e.g. empty Groups? // Scriptographer behaves weirdly then too. diff --git a/src/item/PlacedItem.js b/src/item/PlacedItem.js deleted file mode 100644 index c047971e..00000000 --- a/src/item/PlacedItem.js +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. - * http://paperjs.org/ - * - * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey - * http://lehni.org/ & http://jonathanpuckey.com/ - * - * Distributed under the MIT license. See LICENSE file for details. - * - * All rights reserved. - */ - -/** - * @name PlacedItem - * - * @class The PlacedItem class is the base for any items that have a matrix - * associated with them, describing their placement in the project, such as - * {@link Raster} and {@link PlacedSymbol}. - * - * @extends Item - */ -var PlacedItem = this.PlacedItem = Item.extend(/** @lends PlacedItem# */{ - // PlacedItem uses strokeBounds for bounds - _boundsGetter: { getBounds: 'getStrokeBounds' }, - - _hitTest: function(point, options, matrix) { - var result = this._symbol._definition._hitTest(point, options, matrix); - // TODO: When the symbol's definition is a path, should hitResult - // contain information like HitResult#curve? - if (result) - result.item = this; - return result; - } -}); \ No newline at end of file diff --git a/src/item/PlacedSymbol.js b/src/item/PlacedSymbol.js index a6c73f7f..30326970 100644 --- a/src/item/PlacedSymbol.js +++ b/src/item/PlacedSymbol.js @@ -16,10 +16,12 @@ * @class A PlacedSymbol represents an instance of a symbol which has been * placed in a Paper.js project. * - * @extends PlacedItem + * @extends Item */ -var PlacedSymbol = this.PlacedSymbol = PlacedItem.extend(/** @lends PlacedSymbol# */{ +var PlacedSymbol = this.PlacedSymbol = Item.extend(/** @lends PlacedSymbol# */{ _class: 'PlacedSymbol', + // PlacedSymbol uses strokeBounds for bounds + _boundsGetter: { getBounds: 'getStrokeBounds' }, _boundsSelected: true, _serializeFields: { symbol: null @@ -110,6 +112,15 @@ var PlacedSymbol = this.PlacedSymbol = PlacedItem.extend(/** @lends PlacedSymbol return this.symbol._definition._getCachedBounds(getter, matrix); }, + _hitTest: function(point, options, matrix) { + var result = this._symbol._definition._hitTest(point, options, matrix); + // TODO: When the symbol's definition is a path, should hitResult + // contain information like HitResult#curve? + if (result) + result.item = this; + return result; + }, + _draw: function(ctx, param) { this.symbol._definition.draw(ctx, param); } diff --git a/src/item/Raster.js b/src/item/Raster.js index 25320650..d5b0f498 100644 --- a/src/item/Raster.js +++ b/src/item/Raster.js @@ -15,17 +15,17 @@ * * @class The Raster item represents an image in a Paper.js project. * - * @extends PlacedItem + * @extends Item */ -var Raster = this.Raster = PlacedItem.extend(/** @lends Raster# */{ +var Raster = this.Raster = Item.extend(/** @lends Raster# */{ _class: 'Raster', + // Raster doesn't make the distinction between the different bounds, + // so use the same name for all of them + _boundsGetter: 'getBounds', _boundsSelected: true, _serializeFields: { source: null }, - // Raster doesn't make the distinction between the different bounds, - // so use the same name for all of them - _boundsGetter: 'getBounds', // TODO: Implement type, width, height. // TODO: Have PlacedSymbol & Raster inherit from a shared class? diff --git a/src/paper.js b/src/paper.js index 64b3ef7c..8f86dbac 100644 --- a/src/paper.js +++ b/src/paper.js @@ -62,7 +62,6 @@ var paper = new function() { /*#*/ include('item/Item.js'); /*#*/ include('item/Group.js'); /*#*/ include('item/Layer.js'); -/*#*/ include('item/PlacedItem.js'); /*#*/ include('item/Raster.js'); /*#*/ include('item/PlacedSymbol.js'); /*#*/ include('item/HitResult.js'); diff --git a/src/project/Symbol.js b/src/project/Symbol.js index 3f3db626..f10c42fb 100644 --- a/src/project/Symbol.js +++ b/src/project/Symbol.js @@ -95,7 +95,7 @@ var Symbol = this.Symbol = Base.extend(/** @lends Symbol# */{ * @param {ChangeFlag} flags describes what exactly has changed. */ _changed: function(flags) { - // Notify all PlacedItems of the change in our definition, so they + // Notify all PlacedSymbols of the change in our definition, so they // can clear cached bounds. Base.each(this._instances, function(item) { item._changed(flags);