From 31be916c4ffcb4fc664eaa7589ca87126d6ed14f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sun, 15 May 2011 20:34:22 +0100 Subject: [PATCH] Add dontModify parameter to #set() method in Linked* classes, and rename #_set to #_setter. --- src/basic/Point.js | 13 +++++++------ src/basic/Rectangle.js | 18 +++++++++--------- src/basic/Size.js | 13 +++++++------ 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/basic/Point.js b/src/basic/Point.js index 29b17b3d..dc446acc 100644 --- a/src/basic/Point.js +++ b/src/basic/Point.js @@ -438,10 +438,11 @@ var Point = this.Point = Base.extend({ var LinkedPoint = Point.extend({ beans: true, - set: function(x, y) { + set: function(x, y, dontNotify) { this._x = x; this._y = y; - this._owner[this._set](this); + if (!dontNotify) + this._owner[this._setter](this); return this; }, @@ -451,7 +452,7 @@ var LinkedPoint = Point.extend({ setX: function(x) { this._x = x; - this._owner[this._set](this); + this._owner[this._setter](this); }, getY: function() { @@ -460,16 +461,16 @@ var LinkedPoint = Point.extend({ setY: function(y) { this._y = y; - this._owner[this._set](this); + this._owner[this._setter](this); }, statics: { - create: function(owner, set, x, y) { + create: function(owner, setter, x, y) { var point = new LinkedPoint(LinkedPoint.dont); point._x = x; point._y = y; point._owner = owner; - point._set = set; + point._setter = setter; return point; } } diff --git a/src/basic/Rectangle.js b/src/basic/Rectangle.js index d0c37537..133ecded 100644 --- a/src/basic/Rectangle.js +++ b/src/basic/Rectangle.js @@ -279,13 +279,13 @@ var Rectangle = this.Rectangle = Base.extend({ var LinkedRectangle = Rectangle.extend({ beans: true, - set: function(x, y, width, height) { + set: function(x, y, width, height, dontNotify) { this._x = x; this._y = y; this._width = width; this._height = height; - if (this._owner) - this._owner[this._set](this); + if (!dontNotify) + this._owner[this._setter](this); return this; }, @@ -295,11 +295,11 @@ var LinkedRectangle = Rectangle.extend({ * does not rely on Point#initialize at all. This speeds up all math * operations a lot. */ - create: function(owner, set, x, y, width, height) { - var rect = new LinkedRectangle(LinkedRectangle.dont).set(x, y, - width, height); + create: function(owner, setter, x, y, width, height) { + var rect = new LinkedRectangle(LinkedRectangle.dont).set( + x, y, width, height, true); rect._owner = owner; - rect._set = set; + rect._setter = setter; return rect; } } @@ -318,7 +318,7 @@ var LinkedRectangle = Rectangle.extend({ // Check if this setter is called from another one which sets // _dontNotify, as it will notify itself if (!this._dontNotify) - this._owner[this._set](this); + this._owner[this._setter](this); }; }, Base.each(['Point', 'Size', 'Center', 'Left', 'Top', 'Right', 'Bottom', 'CenterX', 'CenterY', @@ -333,7 +333,7 @@ var LinkedRectangle = Rectangle.extend({ this._dontNotify = true; proto[name].apply(this, arguments); delete this._dontNotify; - this._owner[this._set](this); + this._owner[this._setter](this); return this; }; }, { beans: true }) diff --git a/src/basic/Size.js b/src/basic/Size.js index 1733cc2a..8d05abe4 100644 --- a/src/basic/Size.js +++ b/src/basic/Size.js @@ -140,10 +140,11 @@ var Size = this.Size = Base.extend({ var LinkedSize = Size.extend({ beans: true, - set: function(width, height) { + set: function(width, height, dontNotify) { this._width = width; this._height = height; - this._owner[this._set](this); + if (!dontNotify) + this._owner[this._setter](this); return this; }, @@ -153,7 +154,7 @@ var LinkedSize = Size.extend({ setWidth: function(width) { this._width = width; - this._owner[this._set](this); + this._owner[this._setter](this); }, getHeight: function() { @@ -162,16 +163,16 @@ var LinkedSize = Size.extend({ setHeight: function(height) { this._height = height; - this._owner[this._set](this); + this._owner[this._setter](this); }, statics: { - create: function(owner, set, width, height) { + create: function(owner, setter, width, height) { var point = new LinkedSize(LinkedSize.dont); point._width = width; point._height = height; point._owner = owner; - point._set = set; + point._setter = setter; return point; } }