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)
APPEARANCE: 0x1,
// Change in item hierarchy
HIERARCHY: 0x2,
CHILDREN: 0x2,
// Item geometry (path, bounds)
GEOMETRY: 0x4,
// 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
var Change = {
// HIERARCHY also changes GEOMETRY, since removing children from groups
// change bounds
HIERARCHY: ChangeFlag.HIERARCHY | ChangeFlag.GEOMETRY
| ChangeFlag.APPEARANCE,
// CHILDREN also changes GEOMETRY, since removing children from groups
// changes bounds.
CHILDREN: ChangeFlag.CHILDREN | ChangeFlag.GEOMETRY | ChangeFlag.APPEARANCE,
GEOMETRY: ChangeFlag.GEOMETRY | ChangeFlag.APPEARANCE,
SEGMENTS: ChangeFlag.SEGMENTS | ChangeFlag.GEOMETRY | 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.base.call(this, flags);
if (flags & (/*#=*/ ChangeFlag.HIERARCHY | /*#=*/ ChangeFlag.CLIPPING)) {
if (flags & (/*#=*/ ChangeFlag.CHILDREN | /*#=*/ ChangeFlag.CLIPPING)) {
// Clear cached clip item whenever hierarchy changes
this._clipItem = undefined;
}

View file

@ -251,11 +251,11 @@ var Item = Base.extend(Callback, /** @lends Item# */{
// the parent, see getBounds().
Item._clearBoundsCache(cacheParent);
}
if (flags & /*#=*/ ChangeFlag.HIERARCHY) {
if (flags & /*#=*/ ChangeFlag.CHILDREN) {
// 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
// of the child that modified the hierarchy (that's where these
// HIERARCHY notifications go)
// CHILDREN notifications go)
Item._clearBoundsCache(this);
}
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
// cached bounds that depend on this item. We store this in our parent,
// 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
// 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
@ -2012,7 +2012,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
if (item._name)
item.setName(item._name);
}
this._changed(/*#=*/ Change.HIERARCHY);
this._changed(/*#=*/ Change.CHILDREN);
} else {
items = null;
}
@ -2166,7 +2166,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
this._installEvents(false);
// Notify parent of changed hierarchy
if (notify)
this._parent._changed(/*#=*/ Change.HIERARCHY);
this._parent._changed(/*#=*/ Change.CHILDREN);
this._parent = null;
return true;
}
@ -2213,7 +2213,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
for (var i = removed.length - 1; i >= 0; i--)
removed[i]._remove(false);
if (removed.length > 0)
this._changed(/*#=*/ Change.HIERARCHY);
this._changed(/*#=*/ Change.CHILDREN);
return removed;
},
@ -2229,7 +2229,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
// Adjust inidces
for (var i = 0, l = this._children.length; i < l; i++)
this._children[i]._index = i;
this._changed(/*#=*/ Change.HIERARCHY);
this._changed(/*#=*/ Change.CHILDREN);
}
},