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 --- js/panels/properties.reel/properties.js | 40 ++++++---- .../sections/three-d-view.reel/three-d-view.js | 91 ++++++++++------------ 2 files changed, 67 insertions(+), 64 deletions(-) (limited to 'js/panels/properties.reel') diff --git a/js/panels/properties.reel/properties.js b/js/panels/properties.reel/properties.js index 84b0d589..e99f58e9 100755 --- a/js/panels/properties.reel/properties.js +++ b/js/panels/properties.reel/properties.js @@ -13,6 +13,32 @@ var ElementsMediator = require("js/mediators/element-mediator").ElementMediator; exports.Properties = Montage.create(Component, { + _currentDocument: { + value : null, + enumerable : false + }, + + 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 + this._currentDocument.model.views.design.propertiesPanel = this; + + // Display the default document root PI + this.displayElementProperties(this._currentDocument.model.documentRoot); + } + } + }, + elementName: { value: null }, @@ -46,7 +72,7 @@ exports.Properties = Montage.create(Component, { prepareForDraw: { value : function() { - this.eventManager.addEventListener("openDocument", this, false); + this.eventManager.addEventListener("elementChange", this, false); this.eventManager.addEventListener("selectionChange", this, false); this.eventManager.addEventListener("closeDocument", this, false); @@ -65,18 +91,6 @@ exports.Properties = Montage.create(Component, { } }, - handleOpenDocument: { - value: function() { - this.eventManager.addEventListener( "elementChange", this, false); - - // Save a reference of the pi inside the document view to be able to clear - this.application.ninja.currentDocument.model.views.design.propertiesPanel = this; - - // Display the default document root PI - this.displayElementProperties(this.application.ninja.currentDocument.model.documentRoot); - } - }, - handleCloseDocument: { value: function(){ this.clear(); 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