From 0e1a276f19ea70009c5a649e9667861d7c346a7e Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 6 Jun 2012 00:25:27 -0700 Subject: first iteration of adding serializable to ninja plus other changes to run the latest montage Signed-off-by: Valerio Virgillito --- js/panels/properties.reel/properties.html | 9 ++-- js/panels/properties.reel/properties.js | 19 ++++++-- js/panels/properties.reel/section.reel/section.js | 9 ++-- .../sections/position-size.reel/position-size.html | 9 ++-- .../sections/position-size.reel/position-size.js | 41 ++++++++++++++++ .../sections/three-d-view.reel/three-d-view.html | 2 - .../sections/three-d-view.reel/three-d-view.js | 55 ++++++++++++++++++++++ 7 files changed, 125 insertions(+), 19 deletions(-) (limited to 'js/panels/properties.reel') diff --git a/js/panels/properties.reel/properties.html b/js/panels/properties.reel/properties.html index b9aa206b..a737bd39 100755 --- a/js/panels/properties.reel/properties.html +++ b/js/panels/properties.reel/properties.html @@ -13,24 +13,21 @@ "elementName": { "prototype": "montage/ui/textfield.reel", "properties": { - "element": {"#": "elementName"}, - "readOnly": true + "element": {"#": "elementName"} } }, "elementId": { "prototype": "montage/ui/textfield.reel", "properties": { - "element": {"#": "elementId"}, - "readOnly": false + "element": {"#": "elementId"} } }, "elementClass": { "prototype": "montage/ui/textfield.reel", "properties": { - "element": {"#": "elementClass"}, - "readOnly": false + "element": {"#": "elementClass"} } }, diff --git a/js/panels/properties.reel/properties.js b/js/panels/properties.reel/properties.js index 934a3851..0017b54f 100755 --- a/js/panels/properties.reel/properties.js +++ b/js/panels/properties.reel/properties.js @@ -43,15 +43,28 @@ exports.Properties = Montage.create(Component, { }, elementName: { - value: null + value: null, + serializable: true }, elementId: { - value: null + value: null, + serializable: true }, elementClass: { - value: null + value: null, + serializable: true + }, + + positionSize: { + value: null, + serializable: true + }, + + threeD: { + value: null, + serializable: true }, customSections: { diff --git a/js/panels/properties.reel/section.reel/section.js b/js/panels/properties.reel/section.reel/section.js index b246c171..1873eb8c 100755 --- a/js/panels/properties.reel/section.reel/section.js +++ b/js/panels/properties.reel/section.reel/section.js @@ -10,15 +10,18 @@ var Component = require("montage/ui/component").Component; exports.Section = Montage.create(Component, { name: { - value: "Panel" + value: "Panel", + serializable: true }, slot: { - value: null + value: null, + serializable: true }, content: { - value: null + value: null, + serializable: true }, prepareForDraw: { diff --git a/js/panels/properties.reel/sections/position-size.reel/position-size.html b/js/panels/properties.reel/sections/position-size.reel/position-size.html index 5d1a805a..ccc7a159 100755 --- a/js/panels/properties.reel/sections/position-size.reel/position-size.html +++ b/js/panels/properties.reel/sections/position-size.reel/position-size.html @@ -32,7 +32,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot "minValue": -10000 }, "bindings": { - "value": {"<<->": "@owner.leftPosition"} + "value": {"<->": "@owner.leftPosition"} } }, "PosY": { @@ -43,7 +43,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot "minValue": -10000 }, "bindings": { - "value": {"<<->": "@owner.topPosition"} + "value": {"<->": "@owner.topPosition"} } }, @@ -53,7 +53,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot "element": {"#": "PosH"} }, "bindings": { - "value": {"<<->": "@owner.heightSize"} + "value": {"<->": "@owner.heightSize"} } }, @@ -65,7 +65,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot "units": "px" }, "bindings": { - "value": {"<<->": "@owner.widthSize"} + "value": {"<->": "@owner.widthSize"} } }, @@ -74,7 +74,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot "properties": { "element": {"#": "posBound"}, "pressedClass": "lockUp", - "preventFocus": true, "identifier": "ratio" } } diff --git a/js/panels/properties.reel/sections/position-size.reel/position-size.js b/js/panels/properties.reel/sections/position-size.reel/position-size.js index 7c24e02a..fef2b195 100755 --- a/js/panels/properties.reel/sections/position-size.reel/position-size.js +++ b/js/panels/properties.reel/sections/position-size.reel/position-size.js @@ -8,6 +8,47 @@ var Montage = require("montage/core/core").Montage; var Component = require("montage/ui/component").Component; exports.PositionSize = Montage.create(Component, { + + position: { + value: null, + serializable: true + }, + + leftLabel: { + value: null, + serializable: true + }, + + leftControl: { + value: null, + serializable: true + }, + + topLabel: { + value: null, + serializable: true + }, + + topControl: { + value: null, + serializable: true + }, + + heightControl: { + value: null, + serializable: true + }, + + widthControl: { + value: null, + serializable: true + }, + + bindButton: { + value: null, + serializable: true + }, + leftPosition: { value: 0 }, diff --git a/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.html b/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.html index 5ef13fab..572e5a60 100755 --- a/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.html +++ b/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.html @@ -219,7 +219,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot "properties": { "element": {"#": "rdioLocal"}, "label": "Local", - "value": "Local", "group": {"@": "axisModeGroup"}, "checked": true } @@ -229,7 +228,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot "properties": { "element": {"#": "rdioGlobal"}, "label": "Global", - "value": "Global", "group": {"@": "axisModeGroup"} } }, 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 104d474d..70fca99b 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 @@ -51,6 +51,61 @@ exports.ThreeD = Montage.create(Component, { } }, + x3DControl: { + value: null, + serializable: true + }, + + y3DControl: { + value: null, + serializable: true + }, + + z3DControl: { + value: null, + serializable: true + }, + + x3DLabel: { + value: null, + serializable: true + }, + + y3DLabel: { + value: null, + serializable: true + }, + + z3DLabel: { + value: null, + serializable: true + }, + + xAngleControl: { + value: null, + serializable: true + }, + + yAngleControl: { + value: null, + serializable: true + }, + + zAngleControl: { + value: null, + serializable: true + }, + + axisModeGroupControl: { + value: null, + serializable: true + }, + + flattenControl: { + value: null, + serializable: true + }, + x3D: { value: 0 }, -- cgit v1.2.3 From 007676e50a23bbc714fa56c7e1917a281fd3a67b Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 11 Jun 2012 13:55:24 -0700 Subject: IKNinja-1377 - Global rotation does not work if object is translated in z. Signed-off-by: Nivesh Rajbhandari --- .../sections/three-d-view.reel/three-d-view.js | 66 +++++++++++++++++++--- 1 file changed, 59 insertions(+), 7 deletions(-) (limited to 'js/panels/properties.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 104d474d..478a6de5 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 @@ -5,7 +5,9 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot */ var Montage = require("montage/core/core").Montage; -var Component = require("montage/ui/component").Component; + Component = require("montage/ui/component").Component, + viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, + drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils; exports.ThreeD = Montage.create(Component, { @@ -107,6 +109,10 @@ exports.ThreeD = Montage.create(Component, { value: null }, + _transformCtr: { + value: null + }, + handleAction: { value: function(event) { if(event.currentTarget.identifier === "flatten") { @@ -143,10 +149,20 @@ exports.ThreeD = Montage.create(Component, { value : function(prop, value, item, inGlobalMode, isChanging){ if(!this._curMat) { this._curMat = this.application.ninja.elementMediator.getMatrix(item); +// this._transformCtr = item.elementModel.props3D.m_transformCtr || [0,0,0]; + // TODO - Always use the center for now until we support multiple selections + this._transformCtr = [0,0,0]; + if(inGlobalMode) { + this._transformCtr = MathUtils.transformPoint(this._transformCtr, this._curMat); + } } - var curMat = this._curMat; - var delta = value.value; + var curMat = this._curMat, + delta = value.value, + isRotating = false, + xFormMat = Matrix.I(4), + tMat = Matrix.I(4), + mat = []; if(inGlobalMode) { if(!this._curProp) { @@ -156,17 +172,19 @@ exports.ThreeD = Montage.create(Component, { delta -= this._curProp; } - var xFormMat = Matrix.I(4); switch (prop) { case "xAngle": xFormMat = Matrix.RotationX(MathUtils.DEG_TO_RAD * delta); + isRotating = true; break; case "yAngle": xFormMat = Matrix.RotationY(MathUtils.DEG_TO_RAD * delta); + isRotating = true; break; case "zAngle": xFormMat = Matrix.RotationZ(MathUtils.DEG_TO_RAD * delta); + isRotating = true; break; case "x3D": xFormMat[12] = delta; @@ -179,11 +197,45 @@ exports.ThreeD = Montage.create(Component, { break; } - var mat = []; if(inGlobalMode) { - glmat4.multiply(xFormMat, curMat, mat); + + if(isRotating) { + + // pre-translate by the transformation center + tMat[12] = this._transformCtr[0]; + tMat[13] = this._transformCtr[1]; + tMat[14] = this._transformCtr[2]; + + glmat4.multiply(tMat, xFormMat, mat); + + // translate back + tMat[12] = -this._transformCtr[0]; + tMat[13] = -this._transformCtr[1]; + tMat[14] = -this._transformCtr[2]; + + glmat4.multiply(mat, tMat, mat); + glmat4.multiply(mat, curMat, mat); + } else { + glmat4.multiply(xFormMat, curMat, mat); + } } else { - glmat4.multiply(curMat, xFormMat, mat); + if(isRotating) { + tMat[12] = this._transformCtr[0]; + tMat[13] = this._transformCtr[1]; + tMat[14] = this._transformCtr[2]; + + glmat4.multiply(curMat, tMat, mat); + + // translate back + tMat[12] = -this._transformCtr[0]; + tMat[13] = -this._transformCtr[1]; + tMat[14] = -this._transformCtr[2]; + + glmat4.multiply(mat, xFormMat, mat); + glmat4.multiply(mat, tMat, mat); + } else { + glmat4.multiply(curMat, xFormMat, mat); + } } if(isChanging) { -- cgit v1.2.3 From 71ee5770ff83a27f874084a11d269f3d7f1fd9ca Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 11 Jun 2012 14:26:10 -0700 Subject: Removing unused requires from 3d PI section. Signed-off-by: Nivesh Rajbhandari --- js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'js/panels/properties.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 478a6de5..101ca705 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 @@ -5,9 +5,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot */ var Montage = require("montage/core/core").Montage; - Component = require("montage/ui/component").Component, - viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, - drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils; + Component = require("montage/ui/component").Component; exports.ThreeD = Montage.create(Component, { -- cgit v1.2.3 From cc0662909639d6635d5e1c4df0bacc55d94c9f5e Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 11 Jun 2012 14:28:11 -0700 Subject: Fixing typo. Signed-off-by: Nivesh Rajbhandari --- 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') 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 101ca705..f8d158ce 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 @@ -4,7 +4,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ -var Montage = require("montage/core/core").Montage; +var Montage = require("montage/core/core").Montage, Component = require("montage/ui/component").Component; exports.ThreeD = Montage.create(Component, { -- cgit v1.2.3 From 471776facca730c57b0f6b8448535914df6624fd Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 12 Jun 2012 11:12:32 -0700 Subject: adding more nonexistent properties Signed-off-by: Valerio Virgillito --- .../sections/custom-rows/single-row.reel/single-row.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'js/panels/properties.reel') diff --git a/js/panels/properties.reel/sections/custom-rows/single-row.reel/single-row.js b/js/panels/properties.reel/sections/custom-rows/single-row.reel/single-row.js index b606d6b8..a11cd3f6 100755 --- a/js/panels/properties.reel/sections/custom-rows/single-row.reel/single-row.js +++ b/js/panels/properties.reel/sections/custom-rows/single-row.reel/single-row.js @@ -8,6 +8,10 @@ var Montage = require("montage/core/core").Montage; var Component = require("montage/ui/component").Component; exports.SingleRow = Montage.create(Component, { + slot: { + value: null + }, + id: { value: null }, -- cgit v1.2.3 From 16d859a284805cd8bf14187fd421b6a14e6d8912 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 12 Jun 2012 15:12:27 -0700 Subject: remove serializable from custom section Signed-off-by: Valerio Virgillito --- js/panels/properties.reel/section.reel/section.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'js/panels/properties.reel') diff --git a/js/panels/properties.reel/section.reel/section.js b/js/panels/properties.reel/section.reel/section.js index 1873eb8c..310bc48f 100755 --- a/js/panels/properties.reel/section.reel/section.js +++ b/js/panels/properties.reel/section.reel/section.js @@ -10,18 +10,16 @@ var Component = require("montage/ui/component").Component; exports.Section = Montage.create(Component, { name: { - value: "Panel", - serializable: true + value: "Panel" + }, slot: { - value: null, - serializable: true + value: null }, content: { - value: null, - serializable: true + value: null }, prepareForDraw: { -- cgit v1.2.3 From 509092ff335f74517a413cfb2deeb9d2de20f8e3 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 12 Jun 2012 15:13:09 -0700 Subject: Fixing properties panel to support px and % for body and other elements. Signed-off-by: Nivesh Rajbhandari --- js/panels/properties.reel/properties.js | 70 +++++++++++++++++----- .../properties.reel/sections/custom.reel/custom.js | 6 ++ .../sections/position-size.reel/position-size.html | 16 ++++- .../sections/position-size.reel/position-size.js | 40 +++++++++---- 4 files changed, 103 insertions(+), 29 deletions(-) (limited to 'js/panels/properties.reel') diff --git a/js/panels/properties.reel/properties.js b/js/panels/properties.reel/properties.js index cc99ca6c..33e66515 100755 --- a/js/panels/properties.reel/properties.js +++ b/js/panels/properties.reel/properties.js @@ -143,6 +143,7 @@ exports.Properties = Montage.create(Component, { handleElementChange: { value: function(event) { + var l, t, h, w, lvu, tvu, hvu, wvu; // console.log("Element Change PI ", event.detail.source); // If the event comes from the pi don't need to update if(event.detail.source && event.detail.source !== "pi") { var el = this.application.ninja.currentDocument.model.documentRoot; @@ -151,10 +152,24 @@ exports.Properties = Montage.create(Component, { } // TODO - This should only update the properties that were changed. - this.positionSize.leftPosition = parseFloat(ElementsMediator.getProperty(el, "left")); - this.positionSize.topPosition = parseFloat(ElementsMediator.getProperty(el, "top")); - this.positionSize.heightSize = parseFloat(ElementsMediator.getProperty(el, "height")); - this.positionSize.widthSize = parseFloat(ElementsMediator.getProperty(el, "width")); + l = ElementsMediator.getProperty(el, "left"); + t = ElementsMediator.getProperty(el, "top"); + lvu = document.application.njUtils.getValueAndUnits(l); + tvu = document.application.njUtils.getValueAndUnits(t); + this.positionSize.leftUnits = lvu[1]; + this.positionSize.leftPosition = lvu[0]; + this.positionSize.topUnits = tvu[1]; + this.positionSize.topPosition = tvu[0]; + + h = ElementsMediator.getProperty(el, "height"); + w = ElementsMediator.getProperty(el, "width"); + hvu = document.application.njUtils.getValueAndUnits(h); + wvu = document.application.njUtils.getValueAndUnits(w); + + this.positionSize.heightUnits = hvu[1] || "px"; // canvas (and shapes) don't have units. + this.positionSize.heightSize = hvu[0]; + this.positionSize.widthUnits = wvu[1] || "px"; + this.positionSize.widthSize = wvu[0]; if(this.threeD.inGlobalMode) { this.threeD.x3D = ElementsMediator.get3DProperty(el, "x3D"); @@ -209,7 +224,8 @@ exports.Properties = Montage.create(Component, { displayElementProperties: { value: function (el) { - var customPI, currentValue, isRoot = this.application.ninja.selectionController.isDocument; + var customPI, currentValue, isRoot = this.application.ninja.selectionController.isDocument, + l, t, h, w, lvu, tvu, hvu, wvu; this.elementName.value = el.elementModel.selection; this.elementId.value = el.getAttribute("id") || ""; @@ -219,11 +235,24 @@ exports.Properties = Montage.create(Component, { this.threeD.disableTranslation = isRoot; this.threeD.flatten = ElementsMediator.getProperty(el, "-webkit-transform-style") !== "preserve-3d"; - this.positionSize.leftPosition = parseFloat(ElementsMediator.getProperty(el, "left")); - this.positionSize.topPosition = parseFloat(ElementsMediator.getProperty(el, "top")); - this.positionSize.heightSize = parseFloat(ElementsMediator.getProperty(el, "height")); - this.positionSize.widthSize = parseFloat(ElementsMediator.getProperty(el, "width")); -// this.positionSize.widthSize = ElementsMediator.getProperty(el, "width"); + l = ElementsMediator.getProperty(el, "left"); + t = ElementsMediator.getProperty(el, "top"); + lvu = document.application.njUtils.getValueAndUnits(l); + tvu = document.application.njUtils.getValueAndUnits(t); + this.positionSize.leftUnits = lvu[1]; + this.positionSize.leftPosition = lvu[0]; + this.positionSize.topUnits = tvu[1]; + this.positionSize.topPosition = tvu[0]; + + h = ElementsMediator.getProperty(el, "height"); + w = ElementsMediator.getProperty(el, "width"); + hvu = document.application.njUtils.getValueAndUnits(h); + wvu = document.application.njUtils.getValueAndUnits(w); + + this.positionSize.heightUnits = hvu[1] || "px"; // canvas (and shapes) don't have units. + this.positionSize.heightSize = hvu[0]; + this.positionSize.widthUnits = wvu[1] || "px"; + this.positionSize.widthSize = wvu[0]; if(this.threeD.inGlobalMode) { @@ -277,10 +306,19 @@ exports.Properties = Montage.create(Component, { if(control.type !== "color") { currentValue = ElementsMediator.getProperty(el, control.prop, control.valueMutator); - if(currentValue === null) { - currentValue = control.defaultValue; + if(control.type === "hottext") { + if(currentValue == null) { + currentValue = control.defaultValue; + } + currentValue = document.application.njUtils.getValueAndUnits(currentValue); + this.customSections[i].content.controls[control.id + "Units"] = currentValue[1] || "px"; + this.customSections[i].content.controls[control.id] = currentValue[0]; + } else { + if(currentValue === null) { + currentValue = control.defaultValue; + } + this.customSections[i].content.controls[control.id] = currentValue; } - this.customSections[i].content.controls[control.id] = currentValue; } else { if(control.prop === "border") { // TODO - For now, always return the top border if multiple border sides @@ -402,7 +440,11 @@ exports.Properties = Montage.create(Component, { value: function(e) { if(e.wasSetByCode) return; - ElementsMediator.setProperty(this.application.ninja.selectedElements, e.prop, [e.value + "px"], "Changing", "pi"); + var newValue; + + e.units ? newValue = e.value + e.units : newValue = e.value; + + ElementsMediator.setProperty(this.application.ninja.selectedElements, e.prop, [newValue], "Changing", "pi"); } } diff --git a/js/panels/properties.reel/sections/custom.reel/custom.js b/js/panels/properties.reel/sections/custom.reel/custom.js index 9df16112..c599dcb0 100755 --- a/js/panels/properties.reel/sections/custom.reel/custom.js +++ b/js/panels/properties.reel/sections/custom.reel/custom.js @@ -233,6 +233,12 @@ exports.CustomSection = Montage.create(Component, { boundObjectPropertyPath: "value" }); + //Bind object value to controls list so it can be manipulated + Object.defineBinding(this.controls, aField.id + "Units", { + boundObject: obj, + boundObjectPropertyPath: "units" + }); + return obj; } }, diff --git a/js/panels/properties.reel/sections/position-size.reel/position-size.html b/js/panels/properties.reel/sections/position-size.reel/position-size.html index 5d1a805a..bc93da33 100755 --- a/js/panels/properties.reel/sections/position-size.reel/position-size.html +++ b/js/panels/properties.reel/sections/position-size.reel/position-size.html @@ -29,9 +29,12 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot "properties": { "element": {"#": "PosX"}, "maxValue": 10000, - "minValue": -10000 + "minValue": -10000, + "acceptableUnits" : ["px", "%"], + "units": "px" }, "bindings": { + "units": {"<<->": "@owner.leftUnits"}, "value": {"<<->": "@owner.leftPosition"} } }, @@ -40,9 +43,12 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot "properties": { "element": {"#": "PosY"}, "maxValue": 10000, - "minValue": -10000 + "minValue": -10000, + "acceptableUnits" : ["px", "%"], + "units": "px" }, "bindings": { + "units": {"<<->": "@owner.topUnits"}, "value": {"<<->": "@owner.topPosition"} } }, @@ -50,9 +56,12 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot "PosH": { "prototype": "js/components/hottextunit.reel[HotTextUnit]", "properties": { - "element": {"#": "PosH"} + "element": {"#": "PosH"}, + "acceptableUnits" : ["px", "%"], + "units": "px" }, "bindings": { + "units": {"<<->": "@owner.heightUnits"}, "value": {"<<->": "@owner.heightSize"} } }, @@ -65,6 +74,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot "units": "px" }, "bindings": { + "units": {"<<->": "@owner.widthUnits"}, "value": {"<<->": "@owner.widthSize"} } diff --git a/js/panels/properties.reel/sections/position-size.reel/position-size.js b/js/panels/properties.reel/sections/position-size.reel/position-size.js index 7c24e02a..d9fd629c 100755 --- a/js/panels/properties.reel/sections/position-size.reel/position-size.js +++ b/js/panels/properties.reel/sections/position-size.reel/position-size.js @@ -12,17 +12,33 @@ exports.PositionSize = Montage.create(Component, { value: 0 }, + leftUnits: { + value: "px" + }, + topPosition: { value: 0 }, + topUnits: { + value: "px" + }, + heightSize: { value: 0 }, + heightUnits: { + value: "px" + }, + widthSize: { value: 0 }, + + widthUnits: { + value: "px" + }, /* widthSize: { get: function() { return this._widthSize;}, @@ -132,7 +148,7 @@ exports.PositionSize = Montage.create(Component, { if(!event.wasSetByCode) { if(this.savedPosition) prevPosition = [this.savedPosition + "px"]; - this.application.ninja.elementMediator.setProperty(this.application.ninja.selectedElements, "left", [this.leftControl.value + "px"] , "Change", "pi", prevPosition); + this.application.ninja.elementMediator.setProperty(this.application.ninja.selectedElements, "left", [this.leftControl.value + this.leftControl.units] , "Change", "pi", prevPosition); this.savedPosition = null; } } @@ -145,7 +161,7 @@ exports.PositionSize = Montage.create(Component, { if(!event.wasSetByCode) { if(this.savedPosition) prevPosition = [this.savedPosition + "px"]; - this.application.ninja.elementMediator.setProperty(this.application.ninja.selectedElements, "top", [this.topControl.value + "px"] , "Change", "pi", prevPosition); + this.application.ninja.elementMediator.setProperty(this.application.ninja.selectedElements, "top", [this.topControl.value + this.topControl.units] , "Change", "pi", prevPosition); this.savedPosition = null; } } @@ -156,7 +172,7 @@ exports.PositionSize = Montage.create(Component, { var prevPosition, items; if(!event.wasSetByCode) { - if(this.savedPosition) prevPosition = [this.savedPosition + "px"]; + if(this.savedPosition) prevPosition = [this.savedPosition]; this.application.ninja.selectedElements.length ? items = this.application.ninja.selectedElements : items = [this.application.ninja.currentDocument.model.documentRoot]; @@ -170,7 +186,7 @@ exports.PositionSize = Montage.create(Component, { this.application.ninja.elementMediator.setProperty(items, "width", [newWidth + "px"] , "Change", "pi"); } - this.application.ninja.elementMediator.setProperty(items, "height", [this.heightControl.value + "px"] , "Change", "pi", prevPosition); + this.application.ninja.elementMediator.setProperty(items, "height", [this.heightControl.value + this.heightControl.units] , "Change", "pi", prevPosition); this.savedPosition = null; } } @@ -181,7 +197,7 @@ exports.PositionSize = Montage.create(Component, { var prevPosition, items; if(!event.wasSetByCode) { - if(this.savedPosition) prevPosition = [this.savedPosition + "px"]; + if(this.savedPosition) prevPosition = [this.savedPosition]; this.application.ninja.selectedElements.length ? items = this.application.ninja.selectedElements : items = [this.application.ninja.currentDocument.model.documentRoot]; @@ -196,7 +212,7 @@ exports.PositionSize = Montage.create(Component, { } - this.application.ninja.elementMediator.setProperty(items, "width", [this.widthControl.value + "px"] , "Change", "pi", prevPosition); + this.application.ninja.elementMediator.setProperty(items, "width", [this.widthControl.value + this.widthControl.units] , "Change", "pi", prevPosition); this.savedPosition = null; } @@ -208,7 +224,7 @@ exports.PositionSize = Montage.create(Component, { value: function(event) { if(!event.wasSetByCode) { if(!this.savedPosition) this.savedPosition = this.leftPosition; - this.application.ninja.elementMediator.setProperty(this.application.ninja.selectedElements, "left", [this.leftControl.value + "px"] , "Changing", "pi"); + this.application.ninja.elementMediator.setProperty(this.application.ninja.selectedElements, "left", [this.leftControl.value + this.leftControl.units] , "Changing", "pi"); } } @@ -218,7 +234,7 @@ exports.PositionSize = Montage.create(Component, { value: function(event) { if(!event.wasSetByCode) { if(!this.savedPosition) this.savedPosition = this.topPosition; - this.application.ninja.elementMediator.setProperty(this.application.ninja.selectedElements, "top", [this.topControl.value + "px"] , "Changing", "pi"); + this.application.ninja.elementMediator.setProperty(this.application.ninja.selectedElements, "top", [this.topControl.value + this.topControl.units] , "Changing", "pi"); } } @@ -229,7 +245,7 @@ exports.PositionSize = Montage.create(Component, { var items; if(!event.wasSetByCode) { - if(!this.savedPosition) this.savedPosition = this.heightSize; + if(!this.savedPosition) this.savedPosition = this.heightSize + " " + this.heightUnits; this.application.ninja.selectedElements.length ? items = this.application.ninja.selectedElements : items = [this.application.ninja.currentDocument.model.documentRoot]; @@ -243,7 +259,7 @@ exports.PositionSize = Montage.create(Component, { this.application.ninja.elementMediator.setProperty(items, "width", [newWidth + "px"] , "Changing", "pi"); } - this.application.ninja.elementMediator.setProperty(items, "height", [this.heightControl.value + "px"] , "Changing", "pi"); + this.application.ninja.elementMediator.setProperty(items, "height", [this.heightSize + this.heightUnits] , "Changing", "pi"); } } @@ -254,7 +270,7 @@ exports.PositionSize = Montage.create(Component, { var items; if(!event.wasSetByCode) { - if(!this.savedPosition) this.savedPosition = this.widthSize; + if(!this.savedPosition) this.savedPosition = this.widthSize + " " + this.widthUnits; this.application.ninja.selectedElements.length ? items = this.application.ninja.selectedElements : items = [this.application.ninja.currentDocument.model.documentRoot]; @@ -267,7 +283,7 @@ exports.PositionSize = Montage.create(Component, { this.application.ninja.elementMediator.setProperty(items, "height", [newHeight + "px"] , "Changing", "pi"); } - this.application.ninja.elementMediator.setProperty(items, "width", [this.widthControl.value + "px"] , "Changing", "pi"); + this.application.ninja.elementMediator.setProperty(items, "width", [this.widthSize + this.widthUnits] , "Changing", "pi"); } } } -- cgit v1.2.3 From 1bb2778224982aea7b9781c6559bb659983a400f Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 13 Jun 2012 11:25:20 -0700 Subject: We need to guard against cases where some PI controls are using HottextUnit but don't actually allow uses to change those units. Signed-off-by: Nivesh Rajbhandari --- js/panels/properties.reel/properties.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'js/panels/properties.reel') diff --git a/js/panels/properties.reel/properties.js b/js/panels/properties.reel/properties.js index 33e66515..97dc017d 100755 --- a/js/panels/properties.reel/properties.js +++ b/js/panels/properties.reel/properties.js @@ -310,9 +310,13 @@ exports.Properties = Montage.create(Component, { if(currentValue == null) { currentValue = control.defaultValue; } - currentValue = document.application.njUtils.getValueAndUnits(currentValue); - this.customSections[i].content.controls[control.id + "Units"] = currentValue[1] || "px"; - this.customSections[i].content.controls[control.id] = currentValue[0]; + if(typeof(currentValue) === "string") { + currentValue = document.application.njUtils.getValueAndUnits(currentValue); + this.customSections[i].content.controls[control.id + "Units"] = currentValue[1] || "px"; + this.customSections[i].content.controls[control.id] = currentValue[0]; + } else { + this.customSections[i].content.controls[control.id] = currentValue; + } } else { if(currentValue === null) { currentValue = control.defaultValue; -- cgit v1.2.3 From fbd9d2492aeaef392ad59792825b8757d6c363fc Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 15 Jun 2012 15:14:34 -0700 Subject: Fixing apply 'no color' This should fix canvas and standard DOM elements including the root (body or template wrapper). --- js/panels/properties.reel/properties.js | 4 ++-- js/panels/properties.reel/sections/custom.reel/custom.js | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'js/panels/properties.reel') diff --git a/js/panels/properties.reel/properties.js b/js/panels/properties.reel/properties.js index 43c92b74..fcd0ab01 100755 --- a/js/panels/properties.reel/properties.js +++ b/js/panels/properties.reel/properties.js @@ -367,7 +367,7 @@ exports.Properties = Montage.create(Component, { } } else { this.application.ninja.colorController.colorModel.alpha = {value: 1, wasSetByCode: true, type: 'change'}; - this.application.ninja.colorController.colorModel.applyNoColor(); + this.application.ninja.colorController.colorModel.applyNoColor(true); } } } @@ -397,7 +397,7 @@ exports.Properties = Montage.create(Component, { this.application.ninja.colorController.colorModel.hsv = color.c; break; default: - this.application.ninja.colorController.colorModel.applyNoColor(); + this.application.ninja.colorController.colorModel.applyNoColor(true); break; } } diff --git a/js/panels/properties.reel/sections/custom.reel/custom.js b/js/panels/properties.reel/sections/custom.reel/custom.js index c599dcb0..08434b01 100755 --- a/js/panels/properties.reel/sections/custom.reel/custom.js +++ b/js/panels/properties.reel/sections/custom.reel/custom.js @@ -116,7 +116,11 @@ exports.CustomSection = Montage.create(Component, { value: function(event) { // Change the stage color for now //console.log(this, event); - ElementsMediator.setProperty([this.application.ninja.currentDocument.model.documentRoot], this.id, [event._event.color.css], "Change", "pi", ''); + if (event._event.color && event._event.color.css) { + ElementsMediator.setProperty([this.application.ninja.currentDocument.model.documentRoot], this.id, [event._event.color.css], "Change", "pi", ''); + } else { + ElementsMediator.setProperty([this.application.ninja.currentDocument.model.documentRoot], this.id, ['none'], "Change", "pi", ''); + } /* var propEvent = document.createEvent("CustomEvent"); propEvent.initEvent("propertyChange", true, true); -- cgit v1.2.3