Replace Item#_boundsSelected with #_selectBounds

Plus some refactoring.
This commit is contained in:
Jürg Lehni 2016-03-17 13:09:02 +01:00
parent f0edcd31b0
commit 336bc1092e
7 changed files with 11 additions and 8 deletions

View file

@ -21,6 +21,7 @@
*/
var Group = Item.extend(/** @lends Group# */{
_class: 'Group',
_selectBounds: false,
_selectChildren: true,
_serializeFields: {
children: []

View file

@ -59,7 +59,10 @@ var Item = Base.extend(Emitter, /** @lends Item# */{
_guide: false,
_clipMask: false,
_selection: 0,
_boundsSelected: false,
// Controls whether bounds should appear selected when the item is selected.
// This is only turned off for Group, Layer and PathItem, where it can be
// selected separately by setting item.bounds.selected = true;
_selectBounds: true,
_selectChildren: false,
// Provide information about fields to be serialized, with their defaults
// that can be omitted.
@ -4252,7 +4255,7 @@ new function() { // Injection scope for hit-test functions shared with project
var selection = this._selection,
itemSelected = selection & /*#=*/ItemSelection.ITEM,
boundsSelected = selection & /*#=*/ItemSelection.BOUNDS
|| itemSelected && this._boundsSelected;
|| itemSelected && this._selectBounds;
if (!this._drawSelected)
itemSelected = false;
if ((itemSelected || boundsSelected) && this._isUpdated(updateVersion)) {
@ -4272,13 +4275,15 @@ new function() { // Injection scope for hit-test functions shared with project
// Now draw a rectangle that connects the transformed
// bounds corners, and draw the corners.
ctx.beginPath();
for (var i = 0; i < 8; i++)
for (var i = 0; i < 8; i++) {
ctx[i === 0 ? 'moveTo' : 'lineTo'](coords[i], coords[++i]);
}
ctx.closePath();
ctx.stroke();
for (var i = 0; i < 8; i++)
for (var i = 0; i < 8; i++) {
ctx.fillRect(coords[i] - half, coords[++i] - half,
size, size);
}
}
}
},

View file

@ -24,7 +24,6 @@ var Raster = Item.extend(/** @lends Raster# */{
// Raster doesn't make the distinction between the different bounds,
// so use the same name for all of them
_boundsOptions: { stroke: false, handle: false },
_boundsSelected: true,
_serializeFields: {
crossOrigin: null, // NOTE: Needs to be set before source to work!
source: null

View file

@ -22,7 +22,6 @@ var Shape = Item.extend(/** @lends Shape# */{
_applyMatrix: false,
_canApplyMatrix: false,
_canScaleStroke: true,
_boundsSelected: true,
_serializeFields: {
type: null,
size: null,

View file

@ -24,7 +24,6 @@ var SymbolItem = Item.extend(/** @lends SymbolItem# */{
_canApplyMatrix: false,
// SymbolItem uses strokeBounds for bounds
_boundsOptions: { stroke: true },
_boundsSelected: true,
_serializeFields: {
symbol: null
},

View file

@ -21,6 +21,7 @@
*/
var PathItem = Item.extend(/** @lends PathItem# */{
_class: 'PathItem',
_selectBounds: false,
_canScaleStroke: true,
initialize: function PathItem() {

View file

@ -23,7 +23,6 @@
*/
var TextItem = Item.extend(/** @lends TextItem# */{
_class: 'TextItem',
_boundsSelected: true,
_applyMatrix: false,
_canApplyMatrix: false,
_serializeFields: {