Rename HIERARCHY change-flag to more precise CHILDREN.

This commit is contained in:
Jürg Lehni 2014-03-17 18:59:10 +01:00
parent 1df20c3794
commit f115072e8c
3 changed files with 12 additions and 13 deletions

View file

@ -15,7 +15,7 @@ var ChangeFlag = {
// STROKE, STYLE and ATTRIBUTE (except for the invisible ones: locked, name) // STROKE, STYLE and ATTRIBUTE (except for the invisible ones: locked, name)
APPEARANCE: 0x1, APPEARANCE: 0x1,
// Change in item hierarchy // Change in item hierarchy
HIERARCHY: 0x2, CHILDREN: 0x2,
// Item geometry (path, bounds) // Item geometry (path, bounds)
GEOMETRY: 0x4, GEOMETRY: 0x4,
// Only segment(s) have changed, and affected curves have alredy been // Only segment(s) have changed, and affected curves have alredy been
@ -37,10 +37,9 @@ var ChangeFlag = {
// Shortcuts to often used ChangeFlag values including APPEARANCE // Shortcuts to often used ChangeFlag values including APPEARANCE
var Change = { var Change = {
// HIERARCHY also changes GEOMETRY, since removing children from groups // CHILDREN also changes GEOMETRY, since removing children from groups
// change bounds // changes bounds.
HIERARCHY: ChangeFlag.HIERARCHY | ChangeFlag.GEOMETRY CHILDREN: ChangeFlag.CHILDREN | ChangeFlag.GEOMETRY | ChangeFlag.APPEARANCE,
| ChangeFlag.APPEARANCE,
GEOMETRY: ChangeFlag.GEOMETRY | ChangeFlag.APPEARANCE, GEOMETRY: ChangeFlag.GEOMETRY | ChangeFlag.APPEARANCE,
SEGMENTS: ChangeFlag.SEGMENTS | ChangeFlag.GEOMETRY | ChangeFlag.APPEARANCE, SEGMENTS: ChangeFlag.SEGMENTS | ChangeFlag.GEOMETRY | ChangeFlag.APPEARANCE,
STROKE: ChangeFlag.STROKE | ChangeFlag.STYLE | ChangeFlag.APPEARANCE, STROKE: ChangeFlag.STROKE | ChangeFlag.STYLE | ChangeFlag.APPEARANCE,

View file

@ -99,7 +99,7 @@ var Group = Item.extend(/** @lends Group# */{
_changed: function _changed(flags) { _changed: function _changed(flags) {
_changed.base.call(this, flags); _changed.base.call(this, flags);
if (flags & (/*#=*/ ChangeFlag.HIERARCHY | /*#=*/ ChangeFlag.CLIPPING)) { if (flags & (/*#=*/ ChangeFlag.CHILDREN | /*#=*/ ChangeFlag.CLIPPING)) {
// Clear cached clip item whenever hierarchy changes // Clear cached clip item whenever hierarchy changes
this._clipItem = undefined; this._clipItem = undefined;
} }

View file

@ -251,11 +251,11 @@ var Item = Base.extend(Callback, /** @lends Item# */{
// the parent, see getBounds(). // the parent, see getBounds().
Item._clearBoundsCache(cacheParent); Item._clearBoundsCache(cacheParent);
} }
if (flags & /*#=*/ ChangeFlag.HIERARCHY) { if (flags & /*#=*/ ChangeFlag.CHILDREN) {
// Clear cached bounds of all items that this item contributes to. // Clear cached bounds of all items that this item contributes to.
// We don't call this on the parent, since we're already the parent // We don't call this on the parent, since we're already the parent
// of the child that modified the hierarchy (that's where these // of the child that modified the hierarchy (that's where these
// HIERARCHY notifications go) // CHILDREN notifications go)
Item._clearBoundsCache(this); Item._clearBoundsCache(this);
} }
if (project) { if (project) {
@ -960,7 +960,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
// Set up a boundsCache structure that keeps track of items that keep // Set up a boundsCache structure that keeps track of items that keep
// cached bounds that depend on this item. We store this in our parent, // cached bounds that depend on this item. We store this in our parent,
// for multiple reasons: // for multiple reasons:
// The parent receives HIERARCHY change notifications for when its // The parent receives CHILDREN change notifications for when its
// children are added or removed and can thus clear the cache, and we // children are added or removed and can thus clear the cache, and we
// save a lot of memory, e.g. when grouping 100 items and asking the // save a lot of memory, e.g. when grouping 100 items and asking the
// group for its bounds. If stored on the children, we would have 100 // group for its bounds. If stored on the children, we would have 100
@ -2012,7 +2012,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
if (item._name) if (item._name)
item.setName(item._name); item.setName(item._name);
} }
this._changed(/*#=*/ Change.HIERARCHY); this._changed(/*#=*/ Change.CHILDREN);
} else { } else {
items = null; items = null;
} }
@ -2166,7 +2166,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
this._installEvents(false); this._installEvents(false);
// Notify parent of changed hierarchy // Notify parent of changed hierarchy
if (notify) if (notify)
this._parent._changed(/*#=*/ Change.HIERARCHY); this._parent._changed(/*#=*/ Change.CHILDREN);
this._parent = null; this._parent = null;
return true; return true;
} }
@ -2213,7 +2213,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
for (var i = removed.length - 1; i >= 0; i--) for (var i = removed.length - 1; i >= 0; i--)
removed[i]._remove(false); removed[i]._remove(false);
if (removed.length > 0) if (removed.length > 0)
this._changed(/*#=*/ Change.HIERARCHY); this._changed(/*#=*/ Change.CHILDREN);
return removed; return removed;
}, },
@ -2229,7 +2229,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
// Adjust inidces // Adjust inidces
for (var i = 0, l = this._children.length; i < l; i++) for (var i = 0, l = this._children.length; i < l; i++)
this._children[i]._index = i; this._children[i]._index = i;
this._changed(/*#=*/ Change.HIERARCHY); this._changed(/*#=*/ Change.CHILDREN);
} }
}, },