From 4c3aac5eabd93052b1554a03d78235215bb49db4 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 29 May 2012 00:34:40 -0700 Subject: document bindings phase 1 - using array controller to bind the current document to all ninja components - removed open document event - removed references to the document controller Signed-off-by: Valerio Virgillito --- .../sections/three-d-view.reel/three-d-view.js | 91 ++++++++++------------ 1 file changed, 40 insertions(+), 51 deletions(-) (limited to 'js/panels/properties.reel/sections/three-d-view.reel') diff --git a/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js b/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js index e16e3509..0320c327 100755 --- a/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js +++ b/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js @@ -26,8 +26,7 @@ exports.ThreeD = Montage.create(Component, { set: function(value) { this._axisMode = value; - if(value === 0) - { + if(value === 0) { this.inGlobalMode = false; this.x3D = 0; this.y3D = 0; @@ -36,13 +35,10 @@ exports.ThreeD = Montage.create(Component, { this.xAngle = 0; this.yAngle = 0; this.zAngle = 0; - } - else - { + } else { this.inGlobalMode = true; var item = this.item; - if(item) - { + if(item) { this.x3D = item.elementModel.props3D.x3D; this.y3D = item.elementModel.props3D.y3D; this.z3D = item.elementModel.props3D.z3D; @@ -114,8 +110,7 @@ exports.ThreeD = Montage.create(Component, { handleAction: { value: function(event) { if(event.currentTarget.identifier === "flatten") { - this.application.ninja.elementMediator.setProperty([this.item], - "-webkit-transform-style", + this.application.ninja.elementMediator.setProperty([this.item], "-webkit-transform-style", event.currentTarget.checked ? ["flat"] : ["preserve-3d"]); } } @@ -127,11 +122,7 @@ exports.ThreeD = Montage.create(Component, { return; } - this.apply3DProperties(event.currentTarget.identifier, - event.currentTarget, - this.item, - this.inGlobalMode, - false); + this.apply3DProperties(event.currentTarget.identifier, event.currentTarget, this.item, this.inGlobalMode, false); this._curMat = null; this._curProp = null; @@ -144,28 +135,24 @@ exports.ThreeD = Montage.create(Component, { return; } - this.apply3DProperties(event.currentTarget.identifier, - event.currentTarget, - this.item, - this.inGlobalMode, - true); + this.apply3DProperties(event.currentTarget.identifier, event.currentTarget, this.item, this.inGlobalMode, true); } }, apply3DProperties : { value : function(prop, value, item, inGlobalMode, isChanging){ - if(!this._curMat) - { + if(!this._curMat) { this._curMat = this.application.ninja.elementMediator.getMatrix(item); } + var curMat = this._curMat; var delta = value.value; - if(inGlobalMode) - { - if(!this._curProp) - { + if(inGlobalMode) { + + if(!this._curProp) { this._curProp = this.application.ninja.elementMediator.get3DProperty(item, prop); } + delta -= this._curProp; } @@ -193,31 +180,47 @@ exports.ThreeD = Montage.create(Component, { } var mat = []; - if(inGlobalMode) - { + if(inGlobalMode) { glmat4.multiply(xFormMat, curMat, mat); - } - else - { + } else { glmat4.multiply(curMat, xFormMat, mat); } - if(isChanging) - { + if(isChanging) { this.application.ninja.elementMediator.setMatrix(item, mat, true); - } - else - { + } else { this.application.ninja.elementMediator.setMatrix(item, mat, false); - if(!inGlobalMode) - { + if(!inGlobalMode) { value.value = 0; } } } }, + currentDocument : { + get : function() { + return this._currentDocument; + }, + set : function(value) { + if (value === this._currentDocument) { + return; + } + + this._currentDocument = value; + + if(this._currentDocument.currentView === "design") { + // Save a reference of the pi inside the document view to be able to clear + Object.defineBinding(this, "item", { + boundObject: this, + boundObjectPropertyPath: "application.ninja.selectedElements", + boundValueMutator: this._getSelectedItem, + oneway: true + }); + } + } + }, + templateDidLoad : { value: function() { Object.defineBinding(this, "axisMode", { @@ -225,20 +228,6 @@ exports.ThreeD = Montage.create(Component, { boundObjectPropertyPath: "selectedIndex", oneway: false }); - - this.eventManager.addEventListener("openDocument", this, false); - } - }, - - handleOpenDocument: { - value: function() { - - Object.defineBinding(this, "item", { - boundObject: this, - boundObjectPropertyPath: "application.ninja.selectedElements", - boundValueMutator: this._getSelectedItem, - oneway: true - }); } }, -- cgit v1.2.3 From 752f76fa464e2c9e48b4a0e5429a5b8062c00b39 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 30 May 2012 13:38:39 -0700 Subject: PI's 3d section was not binding correctly to the current document. Signed-off-by: Nivesh Rajbhandari --- js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'js/panels/properties.reel/sections/three-d-view.reel') diff --git a/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js b/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js index 0320c327..49907c9d 100755 --- a/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js +++ b/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js @@ -198,6 +198,10 @@ exports.ThreeD = Montage.create(Component, { } }, + _currentDocument: { + value : null + }, + currentDocument : { get : function() { return this._currentDocument; -- cgit v1.2.3 From 66632a6e0de0998ff6d36abdaa8c3a546eada0f5 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 30 May 2012 23:02:46 -0700 Subject: fixing the closing of documents Signed-off-by: Valerio Virgillito --- js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/panels/properties.reel/sections/three-d-view.reel') diff --git a/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js b/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js index 49907c9d..104d474d 100755 --- a/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js +++ b/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js @@ -213,7 +213,7 @@ exports.ThreeD = Montage.create(Component, { this._currentDocument = value; - if(this._currentDocument.currentView === "design") { + if(this._currentDocument && this._currentDocument.currentView === "design") { // Save a reference of the pi inside the document view to be able to clear Object.defineBinding(this, "item", { boundObject: this, -- cgit v1.2.3