From 7e0c709b4f0557d0f8fd6da8a47dc26172513cc8 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 30 Jan 2012 09:54:55 -0800 Subject: Checkbox and Combobox change/changing events were not setting wasSetByCode property correctly, causing our PI to dispatch events at improper times. Signed-off-by: Nivesh Rajbhandari --- js/components/combobox.reel/combobox.js | 2 +- js/components/radio.reel/radio.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'js') diff --git a/js/components/combobox.reel/combobox.js b/js/components/combobox.reel/combobox.js index f262bb06..a68a7d6b 100644 --- a/js/components/combobox.reel/combobox.js +++ b/js/components/combobox.reel/combobox.js @@ -67,7 +67,7 @@ exports.Combobox = Montage.create(Component, { var e = document.createEvent("CustomEvent"); e.initEvent("change", true, true); e.type = "change"; - e._wasSetByCode = this._wasSetByCode; + e.wasSetByCode = this._wasSetByCode; e.value = this._value; this.dispatchEvent(e); diff --git a/js/components/radio.reel/radio.js b/js/components/radio.reel/radio.js index 954da3c4..c661ec11 100644 --- a/js/components/radio.reel/radio.js +++ b/js/components/radio.reel/radio.js @@ -41,7 +41,7 @@ exports.RadioGroup = Montage.create(Component, { e = document.createEvent("CustomEvent"); e.initEvent("change", true, true); e.type = "change"; - e._wasSetByCode = this._wasSetByCode; + e.wasSetByCode = this._wasSetByCode; e.selectedIndex = i; e.selectedItem = value; this.dispatchEvent(e); @@ -77,7 +77,7 @@ exports.RadioGroup = Montage.create(Component, { { value:function(event) { - this._wasSetByCode = event._event._wasSetByCode; + this._wasSetByCode = event._event.wasSetByCode; this.selectedItem = event._event.value; } } @@ -126,7 +126,7 @@ exports.Radio = Montage.create(Component, { var e = document.createEvent("CustomEvent"); e.initEvent("change", true, true); e.type = "change"; - e._wasSetByCode = this._wasSetByCode; + e.wasSetByCode = this._wasSetByCode; e.value = this; this.dispatchEvent(e); -- cgit v1.2.3 From 51b4e61d6c6df5e88e9a5dfcdfd7944e2a3f64e7 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 30 Jan 2012 13:25:15 -0800 Subject: Syncing stage view when rotating stage. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/draw-utils.js | 25 +++++++++++++++++++++++++ js/models/properties-3d.js | 2 ++ js/stage/layout.js | 14 +++++++++++--- js/stage/stage.reel/stage.js | 2 +- js/tools/SelectionTool.js | 1 - 5 files changed, 39 insertions(+), 5 deletions(-) (limited to 'js') diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 3fd6e8fc..c26a5cd1 100644 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -107,6 +107,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { this.eventManager.addEventListener("elementAdded", this, false); this.eventManager.addEventListener("elementDeleted", this, false); + this.eventManager.addEventListener("elementChange", this, false); } }, @@ -124,6 +125,27 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { }, + handleElementChange: { + value: function(event) { + var els = event.detail.data.els; + if(els) + { + var len = els.length, + i = 0, + item, + el; + + for(i=0; i < len; i++) { + item = els[i]; + el = item._element || item; + el.elementModel.props3D.elementPlane.init(); + } + + this.drawWorkingPlane(); + } + } + }, + /////////////////////////////////////////////////////////////////////// // Methods /////////////////////////////////////////////////////////////////////// @@ -150,6 +172,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { plane.setElement( elt ); plane.init(); this._planesArray.push( plane ); + elt.elementModel.props3D.elementPlane = plane; } }, @@ -166,6 +189,8 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { // Then remove the element this._eltArray.splice(i, 1); + + // TODO - May need to delete props3D and elementPlane as well return; } } diff --git a/js/models/properties-3d.js b/js/models/properties-3d.js index 6d65bc91..3c809f06 100644 --- a/js/models/properties-3d.js +++ b/js/models/properties-3d.js @@ -36,6 +36,8 @@ exports.Properties3D = Montage.create(Component, { perspectiveDist : { value : 1400, enumerable: true}, perspectiveMode : { value : null, enumerable: true}, + elementPlane : { value : null, enumerable: true}, + init : { value : function(elt) { diff --git a/js/stage/layout.js b/js/stage/layout.js index 625c09ad..89fa44f3 100644 --- a/js/stage/layout.js +++ b/js/stage/layout.js @@ -112,6 +112,7 @@ exports.Layout = Montage.create(Component, { } this.draw(); // Not a reel yet :) + this.draw3DInfo(false); } @@ -128,9 +129,16 @@ exports.Layout = Montage.create(Component, { }, draw3DInfo: { - value: function() { - drawUtils.updatePlanes(); - if(this.stage.appModel.show3dGrid) drawUtils.drawWorkingPlane(); + value: function(updatePlanes) { + if(updatePlanes) + { + drawUtils.updatePlanes(); + } + if(this.stage.appModel.show3dGrid) + { + this.application.ninja.stage.stageDeps.snapManager.updateWorkingPlaneFromView(); + drawUtils.drawWorkingPlane(); + } drawUtils.draw3DCompass(); } }, diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 3e0b852e..31d0f8c2 100644 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -175,7 +175,7 @@ exports.Stage = Montage.create(Component, { } else if(this.updatedStage) { this.layout.draw(); - this.layout.draw3DInfo(); + this.layout.draw3DInfo(true); } } }, diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index 5f2a959f..862b2e88 100644 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js @@ -180,7 +180,6 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { this._handleMode = null; this._delta = null; this.DrawHandles(); - console.log( "move: (" + dx + ", " + dy + ")" ); } this.endDraw(event); -- cgit v1.2.3 From 8b8b9bc1cd033b483f3a5c57acc75dfb56e099a4 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 30 Jan 2012 14:21:59 -0800 Subject: Fixed grid not drawing bug when switching from front to top and side. Signed-off-by: Nivesh Rajbhandari --- js/stage/stage.reel/stage.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'js') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 31d0f8c2..8c4efd58 100644 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -814,8 +814,8 @@ exports.Stage = Montage.create(Component, { setStageView: { value: function(side) { var mat, - workingPlane = null, - currentDoc = this.application.ninja.currentDocument.documentRoot; + currentDoc = this.application.ninja.currentDocument.documentRoot, + isDrawingGrid = this.application.ninja.appModel.show3dGrid; // Stage 3d Props. currentDoc.elementModel.props3D.ResetTranslationValues(); currentDoc.elementModel.props3D.ResetRotationValues(); @@ -826,7 +826,7 @@ exports.Stage = Montage.create(Component, { mat = Matrix.RotationX(Math.PI * 270.0/180.0); drawUtils.drawXY = drawUtils.drawYZ = false; - drawUtils.drawXZ = drawUtils.isDrawingGrid(); + drawUtils.drawXZ = isDrawingGrid; workingPlane = [0,1,0,0]; break; @@ -834,7 +834,7 @@ exports.Stage = Montage.create(Component, { mat = Matrix.RotationY(Math.PI * 270/180); drawUtils.drawXY = drawUtils.drawXZ = false; - drawUtils.drawYZ = drawUtils.isDrawingGrid(); + drawUtils.drawYZ = isDrawingGrid; workingPlane = [1,0,0,0]; break; @@ -842,7 +842,7 @@ exports.Stage = Montage.create(Component, { mat = Matrix.I(4); drawUtils.drawYZ = drawUtils.drawXZ = false; - drawUtils.drawXY = drawUtils.isDrawingGrid(); + drawUtils.drawXY = isDrawingGrid; workingPlane = [0,0,1,0]; break; } -- cgit v1.2.3 From b88ebb47d82fc1ffebea49c3bf182aaf3c9419af Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 30 Jan 2012 15:53:11 -0800 Subject: Fixed issue with elements not drawing in the correct plane. When first adding an element, force the 3d model to update with the element's webkit transform values. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/element-controller.js | 59 +++++++++++++-------------- js/mediators/element-mediator.js | 5 +++ js/models/properties-3d.js | 4 +- 3 files changed, 36 insertions(+), 32 deletions(-) (limited to 'js') diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index f254220c..30469db0 100644 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -127,36 +127,35 @@ var ElementController = exports.ElementController = Montage.create(NJComponent, } else { - // TODO - for now, just return the identity matrix - return Matrix.I(4); -// var mat; -// -// if (elt) -// { -// var xformStr = ElementsMediator.getProperty(elt, "-webkit-transform"); -// if (xformStr) -// mat = this.transformStringToMat( xformStr ); -// if (!mat) -// mat = Matrix.I(4); -// -// if (elt.style && elt.style.zoom) -// { -// var zoom = Number(elt.style.zoom); -// if (zoom != 1) -// { -// var zoomMat = Matrix.create( [ -// [ zoom, 0, 0, 0], -// [ 0, zoom, 0, 0], -// [ 0, 0, zoom, 0], -// [ 0, 0, 0, 1] -// ] ); -// glmat4.multiply( zoomMat, mat, mat ); -// } -// } -// } -// -// elt.elementModel.props3D.matrix3d = mat; -// return mat; + var mat; + + if (el) + { + var xformStr = this.application.ninja.elementMediator.getProperty(el, "-webkit-transform"); + if (xformStr) + mat = this.transformStringToMat( xformStr ); + if (!mat) + mat = Matrix.I(4); + + var zoom = this.application.ninja.elementMediator.getProperty(el, "zoom"); + if (zoom) + { + zoom = Number(zoom); + if (zoom != 1) + { + var zoomMat = Matrix.create( [ + [ zoom, 0, 0, 0], + [ 0, zoom, 0, 0], + [ 0, 0, zoom, 0], + [ 0, 0, 0, 1] + ] ); + glmat4.multiply( zoomMat, mat, mat ); + } + } + } + + el.elementModel.props3D.matrix3d = mat; + return mat; } } }, diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index 91b09475..a6f31703 100644 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js @@ -92,6 +92,11 @@ exports.ElementMediator = Montage.create(NJComponent, { _addElement: { value: function(el, rules, noEvent) { ElementController.addElement(el, rules); + var p3d = this.get3DProperties(el); + if(p3d) + { + el.elementModel.controller["set3DProperties"](el, [p3d], 0, true); + } if(!noEvent) NJevent("elementAdded", el); } }, diff --git a/js/models/properties-3d.js b/js/models/properties-3d.js index 3c809f06..cf4a045f 100644 --- a/js/models/properties-3d.js +++ b/js/models/properties-3d.js @@ -22,7 +22,7 @@ exports.Properties3D = Montage.create(Component, { _world : {value : null, enumerable:true}, // keep a referenceto the GLWorld (if any) // Keep track of 3d properties - matrix3d : {value : [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1], enumerable: true}, + matrix3d : {value : null, enumerable: true}, xAngle : {value : 0, enumerable: true}, yAngle : {value : 0, enumerable: true}, @@ -33,7 +33,7 @@ exports.Properties3D = Montage.create(Component, { z3D : {value : 0, enumerable: true}, //TODO - not sure if this should be part of the tool or stage or a utility - perspectiveDist : { value : 1400, enumerable: true}, + perspectiveDist : { value : null, enumerable: true}, perspectiveMode : { value : null, enumerable: true}, elementPlane : { value : null, enumerable: true}, -- cgit v1.2.3 From cbdc001ea4afd054e7a9e1b4e54629254a68376b Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 30 Jan 2012 16:14:43 -0800 Subject: Removing unused Properties3D file since those values are now saved with the models. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/Properties3D.js | 82 --------------------------------------- 1 file changed, 82 deletions(-) delete mode 100644 js/helper-classes/Properties3D.js (limited to 'js') diff --git a/js/helper-classes/Properties3D.js b/js/helper-classes/Properties3D.js deleted file mode 100644 index 42499877..00000000 --- a/js/helper-classes/Properties3D.js +++ /dev/null @@ -1,82 +0,0 @@ -/* -This file contains proprietary software owned by Motorola Mobility, Inc.
-No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
-(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ - -/* Class that holds all 3d properties per element. -*/ - -exports.Properties3D = Object.create(Object.prototype, { - m_element : {value : null, writable:true, enumerable:true, configurable:true}, - -// m_upVector : {value : Vector.create( [0,1,0] ), writable: true, enumerable: true, configurable: true}, - m_azimuth : {value : 0.0, writable: true, enumerable: true, configurable: true}, - m_altitude : {value : 0.0, writable: true, enumerable: true, configurable: true}, - - m_transformCtr : {value : null, writable: true, enumerable: true, configurable: true}, -// m_targetPos : {value : Vector.create( [0,0,0] ), writable: true, enumerable: true, configurable: true}, - - m_endAzimuth : {value : 0, writable: true, enumerable: true, configurable: true}, - m_endAltitude : {value : 0, writable: true, enumerable: true, configurable: true}, - -// m_objStartPos : {value : Vector.create( [0,0,0] ), writable: true, enumerable: true, configurable: true}, - - //TODO - not sure if this should be part of the tool or stage or a utility - perspectiveDist : { value : 1400, writable: true, enumerable: true, configurable: true}, - - // keep a referenceto the GLWorld (if any) - _world : {value : null, writable:true, enumerable:true, configurable:true}, - - // keep a flag indicating the element is in the 2D snap cache - _eltIsIn2DSnapCache : { value: false, writable: true, enumerable: true, configurable: true}, - - Init : { - value : function(elt) - { - this.m_element = elt; - - this.m_azimuth = 0.0; - this.m_altitude = 0.0; - - this.m_endAzimuth = 0.0; - this.m_endAltitude = 0.0; - -// this.m_upVector = Vector.create( [0,1,0] ); -// this.m_viewDir = Vector.create( [0,0,1] ); -// this.m_endUpVector = Vector.create( [0,1,0] ); - - this.m_transformCtr = null; -// this.m_targetPos = Vector.create( [0,0,0] ); - -// this.m_objStartPos = Vector.create( [0,0,0] ); - - this.perspectiveDist = 1400; - } - }, - - ResetRotationValues : { - value : function(elt) - { -// this.m_upVector = Vector.create( [0,1,0] ); -// this.m_viewDir = Vector.create( [0,0,1] ); - - this.m_azimuth = 0.0; - this.m_altitude = 0.0; - - this.m_endAzimuth = 0.0; - this.m_endAltitude = 0.0; - - this.m_transformCtr = null; -// this.m_targetPos = Vector.create( [0,0,0] ); - } - }, - - ResetTranslationValues : { - value : function(elt) - { -// this.m_objStartPos = Vector.create( [0,0,0] ); - this.perspectiveDist = 1400; - } - } -}); \ No newline at end of file -- cgit v1.2.3 From d6e80f16b70034ba8cc7193f4359f764ce28f68b Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 30 Jan 2012 16:20:45 -0800 Subject: Forgot to remove a require in previous checkin. Signed-off-by: Nivesh Rajbhandari --- js/tools/drawing-tool-base.js | 1 - 1 file changed, 1 deletion(-) (limited to 'js') diff --git a/js/tools/drawing-tool-base.js b/js/tools/drawing-tool-base.js index 6fc34911..cd895102 100644 --- a/js/tools/drawing-tool-base.js +++ b/js/tools/drawing-tool-base.js @@ -10,7 +10,6 @@ var Component = require("montage/ui/component").Component; var snapManager = require("js/helper-classes/3D/snap-manager").SnapManager; var viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils; var vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; -var Properties3D = require("js/helper-classes/Properties3D").Properties3D; var drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils; exports.DrawingToolBase = Montage.create(Montage, { -- cgit v1.2.3 From e53f325cf80694d5895cc36c36d1f66c5a44e1d9 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Mon, 30 Jan 2012 11:21:15 -0800 Subject: CSSPanel Updates - Add new original CSS error icon --- js/panels/CSSPanel/CSSPanelBase.reel/CSSPanelBase.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/panels/CSSPanel/CSSPanelBase.reel/CSSPanelBase.css b/js/panels/CSSPanel/CSSPanelBase.reel/CSSPanelBase.css index ff70b5b6..27d19e58 100644 --- a/js/panels/CSSPanel/CSSPanelBase.reel/CSSPanelBase.css +++ b/js/panels/CSSPanel/CSSPanelBase.reel/CSSPanelBase.css @@ -400,7 +400,7 @@ .nj-css-error:not(.nj-css-no-error) { background-repeat: no-repeat; background-position: 3px 2px; - background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAAXNSR0IArs4c6QAAAMtJREFUGJV1kM0KAXEUxc/SWh7MM0zJE3gQCxM2EpJ8bEiNjWHhBWYjYkUkRdQoGde5f2Q03PrV6ZzTrXuB0MgQiU0ba0U1/k3gwBYXoqj+WeKG2LaBgwxYJEbTixa7yMyLLPlLw6xATS9SXDWx25cZ7sYG1ep9b3OR8h3cTyUWtyMylnMNcqGn2WdbHQs94FqFnPtxg2r1NHsfkTx0EMiEG7IMpy2D0fSOPWbsgD/zzEtoik323hP75THTDvJpVHIW5I1t4aaEPe08AF+CuEXWXJtHAAAAAElFTkSuQmCC); + background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAALCAYAAABGbhwYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw%2FeHBhY2tldCBiZWdpbj0i77u%2FIiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8%2BIDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYxIDY0LjE0MDk0OSwgMjAxMC8xMi8wNy0xMDo1NzowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNS4xIE1hY2ludG9zaCIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDowMzYyMERFNTQwNzMxMUUxQTREQ0IxQTRGNEI2MTE3RiIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDowMzYyMERFNjQwNzMxMUUxQTREQ0IxQTRGNEI2MTE3RiI%2BIDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjAzNjIwREUzNDA3MzExRTFBNERDQjFBNEY0QjYxMTdGIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjAzNjIwREU0NDA3MzExRTFBNERDQjFBNEY0QjYxMTdGIi8%2BIDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY%2BIDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8%2Bc4fwegAAAWpJREFUeNo8kLtLA0EQxr%2B9l3lcDAaCBsEqEOysBFEQsRAsRVCEpBREsbIUSxtBrAxEewsrK8VHQIhK%2FoIUUVJIQFFjYi65XDZ36%2Bz5GFgWZr75fjPDhBD4C%2BucjWgaphjQdTgK%2FfPi5a%2FGpPDtjEVjERyqKlag%2FlY8gHPsfzSwPbQgbDyfIs6vURa3EKK8Jf6jmhUy51yiWDlBUDED2NF0JKGQS3IPVn4ATXqIL0EYJgwD42YQG4quE45EggOtCwbWrUM1Ej%2F0jkXDAYaOtOa6iIH2YSQOBugPj4KN3aFdnIThkprynoeUYjtwIRO0hCLxiU3wp12odgl0AXhUa3VQ0xoWCqEApiNhEpFzt7Tm%2F4Tzo9kGvtq4UjNzqJB1mswURvNoqayP57V7KcB7HfZnE8v%2BHYtZtmiGcBzqQ1TSZUPP85HVlo1MfCaX94WPpSO83qwO6wbWCTtBQocoD70eDgZncw3Z%2BC3AAFMzlxlnnpevAAAAAElFTkSuQmCC); opacity: 0.5; } .nj-editing.nj-css-error { -- cgit v1.2.3 From 4aac9e06107e9f8fa32f2dcd2f0addb382fc1f6c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Mon, 30 Jan 2012 16:35:59 -0800 Subject: Adding a version json object to Ninja Versions object to start keeping track of versions for Ninja, Montage and eventually other dependencies. Loaded before montage to use in the splash screen. Signed-off-by: Valerio Virgillito --- js/ninja.reel/ninja.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js') diff --git a/js/ninja.reel/ninja.js b/js/ninja.reel/ninja.js index bc31e0e1..75ec7fcc 100644 --- a/js/ninja.reel/ninja.js +++ b/js/ninja.reel/ninja.js @@ -36,6 +36,7 @@ exports.Ninja = Montage.create(Component, { prepareForDraw: { value: function() { + console.log("Loading Ninja --> ", window.ninjaVersion.ninja.version); this.application.ninja = this; -- cgit v1.2.3 From b9881840e83acbc2d816a9ede66f7fc2d3c3de59 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Mon, 30 Jan 2012 16:36:31 -0800 Subject: Code cleanup - Removed extra log. Signed-off-by: Valerio Virgillito --- js/preloader/Preloader.js | 1 - 1 file changed, 1 deletion(-) (limited to 'js') diff --git a/js/preloader/Preloader.js b/js/preloader/Preloader.js index f137f4b6..93d71e8f 100755 --- a/js/preloader/Preloader.js +++ b/js/preloader/Preloader.js @@ -136,7 +136,6 @@ exports.Preloader = Montage.create(Component, { deserializedFromTemplate: { value: function() { - console.log("Start Preloading"); this.filesTotal = this.ninjaJsRequire.length + this.ninjaCssRequire.length; -- cgit v1.2.3 From 43d53af9cade33cff20601dfbce8a16d7212fe20 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 31 Jan 2012 08:57:57 +0800 Subject: Adding the version to the main Ninja reel component. Signed-off-by: Valerio Virgillito --- js/ninja.reel/ninja.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'js') diff --git a/js/ninja.reel/ninja.js b/js/ninja.reel/ninja.js index 75ec7fcc..465533cd 100644 --- a/js/ninja.reel/ninja.js +++ b/js/ninja.reel/ninja.js @@ -13,6 +13,10 @@ exports.Ninja = Montage.create(Component, { _appLoaded: { value: false }, _preload: { value: false }, + ninjaVersion: { + value: window.ninjaVersion.ninja.version + }, + toolsData: { value: null }, appData: { value: AppData }, @@ -36,7 +40,7 @@ exports.Ninja = Montage.create(Component, { prepareForDraw: { value: function() { - console.log("Loading Ninja --> ", window.ninjaVersion.ninja.version); + console.log("Loading Ninja --> ", this.ninjaVersion); this.application.ninja = this; -- cgit v1.2.3 From 6066b9bda2990c9d6b4311d221b0d0c773b20f60 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 31 Jan 2012 10:28:39 -0800 Subject: Merging Jose's colorchip change. Signed-off-by: Nivesh Rajbhandari --- js/panels/Color/colorchippopup.reel/colorchippopup.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/panels/Color/colorchippopup.reel/colorchippopup.js b/js/panels/Color/colorchippopup.reel/colorchippopup.js index 03e14b28..05bcb447 100644 --- a/js/panels/Color/colorchippopup.reel/colorchippopup.js +++ b/js/panels/Color/colorchippopup.reel/colorchippopup.js @@ -109,7 +109,7 @@ exports.ColorChipPopup = Montage.create(Component, { this.cc_hexinput.labelFunction = this._hexLabel.bind(this); this.cc_hexinput.inputFunction = this._hexInput.bind(this); // - if (this.application.ninja.colorController.colorView.currentChip && this.application.ninja.colorController.colorView.currentChip.colorValue.a) { + if (this.application.ninja.colorController.colorView.currentChip && this.application.ninja.colorController.colorView.currentChip.colorValue && this.application.ninja.colorController.colorView.currentChip.colorValue.a) { this.combo.slider.value = Math.round(this.application.ninja.colorController.colorView.currentChip.colorValue.a*100); } else { this.combo.slider.value = 100; -- cgit v1.2.3 From 12371bb25ca51286c19a426611d9b7db369bec87 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 31 Jan 2012 11:09:21 -0800 Subject: Support stage in PI's 3d section. Signed-off-by: Nivesh Rajbhandari --- .../sections/three-d-view.reel/three-d-view.js | 63 ++++++++++++++-------- 1 file changed, 41 insertions(+), 22 deletions(-) (limited to 'js') diff --git a/js/panels/properties/sections/three-d-view.reel/three-d-view.js b/js/panels/properties/sections/three-d-view.reel/three-d-view.js index 38dbb110..dda9f993 100644 --- a/js/panels/properties/sections/three-d-view.reel/three-d-view.js +++ b/js/panels/properties/sections/three-d-view.reel/three-d-view.js @@ -40,19 +40,16 @@ exports.ThreeD = Montage.create(Component, { else { this.inGlobalMode = true; - if(this.application.ninja.selectedElements.length) + var item = this.item; + if(item) { - var item = this.application.ninja.selectedElements[0]._element; - if(item) - { - this.x3D = item.elementModel.props3D.x3D; - this.y3D = item.elementModel.props3D.y3D; - this.z3D = item.elementModel.props3D.z3D; - - this.xAngle = item.elementModel.props3D.xAngle; - this.yAngle = item.elementModel.props3D.yAngle; - this.zAngle = item.elementModel.props3D.zAngle; - } + this.x3D = item.elementModel.props3D.x3D; + this.y3D = item.elementModel.props3D.y3D; + this.z3D = item.elementModel.props3D.z3D; + + this.xAngle = item.elementModel.props3D.xAngle; + this.yAngle = item.elementModel.props3D.yAngle; + this.zAngle = item.elementModel.props3D.zAngle; } } } @@ -98,6 +95,10 @@ exports.ThreeD = Montage.create(Component, { } }, + item: { + value: null + }, + handleChange: { value: function(event) { if(event.wasSetByCode) { @@ -106,7 +107,7 @@ exports.ThreeD = Montage.create(Component, { this.apply3DProperties(event.currentTarget.identifier, event.currentTarget, - this.application.ninja.selectedElements[0]._element, + this.item, this.inGlobalMode, false); } @@ -120,7 +121,7 @@ exports.ThreeD = Montage.create(Component, { this.apply3DProperties(event.currentTarget.identifier, event.currentTarget, - this.application.ninja.selectedElements[0]._element, + this.item, this.inGlobalMode, true); } @@ -128,9 +129,8 @@ exports.ThreeD = Montage.create(Component, { apply3DProperties : { value : function(prop, value, item, inGlobalMode, isChanging){ - // TODO - May want to use mediator instead - var curMat = item.elementModel.props3D.matrix3d; - var delta = value.value - item.elementModel.props3D[prop]; + var curMat = this.application.ninja.elementMediator.getMatrix(item); + var delta = value.value - this.application.ninja.elementMediator.get3DProperty(item, prop); var xFormMat = Matrix.I(4); switch (prop) @@ -183,12 +183,31 @@ exports.ThreeD = Montage.create(Component, { templateDidLoad : { value: function() { - Object.defineBinding(this, "axisMode", { - boundObject: this.axisModeGroupControl, - boundObjectPropertyPath: "selectedIndex", - oneway: false - }); + Object.defineBinding(this, "axisMode", { + boundObject: this.axisModeGroupControl, + boundObjectPropertyPath: "selectedIndex", + oneway: false + }); + + Object.defineBinding(this, "item", { + boundObject: this, + boundObjectPropertyPath: "application.ninja.selectedElements", + boundValueMutator: this._getSelectedItem + }); + } + }, + _getSelectedItem: { + value: function(els) + { + if(els.length) + { + return els[0]._element || els[0]; + } + else + { + return this.boundObject.application.ninja.currentDocument.documentRoot; + } } }, -- cgit v1.2.3 From c0f43749523f4720ca4c8942fa9ac17753d93a67 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 31 Jan 2012 15:01:04 -0800 Subject: Fixing 3d section of the PI. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/element-controller.js | 2 +- .../sections/three-d-view.reel/three-d-view.html | 12 +++++----- .../sections/three-d-view.reel/three-d-view.js | 27 ++++++++++++++++++++-- 3 files changed, 32 insertions(+), 9 deletions(-) (limited to 'js') diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index 30469db0..f2b54014 100644 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -206,7 +206,7 @@ var ElementController = exports.ElementController = Montage.create(NJComponent, el.elementModel.props3D.matrix3d = mat; el.elementModel.props3D.perspectiveDist = dist; -// if(update3DModel) + if(update3DModel) { this._update3DProperties(el, mat, dist); } diff --git a/js/panels/properties/sections/three-d-view.reel/three-d-view.html b/js/panels/properties/sections/three-d-view.reel/three-d-view.html index 1e24cb55..11a5b3f2 100644 --- a/js/panels/properties/sections/three-d-view.reel/three-d-view.html +++ b/js/panels/properties/sections/three-d-view.reel/three-d-view.html @@ -39,7 +39,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot "value": { "boundObject": {"@": "owner"}, "boundObjectPropertyPath": "x3D", - "oneway": false + "oneway": true } }, "listeners": [ @@ -68,7 +68,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot "value": { "boundObject": {"@": "owner"}, "boundObjectPropertyPath": "y3D", - "oneway": false + "oneway": true } }, "listeners": [ @@ -97,7 +97,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot "value": { "boundObject": {"@": "owner"}, "boundObjectPropertyPath": "z3D", - "oneway": false + "oneway": true } }, "listeners": [ @@ -128,7 +128,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot "value": { "boundObject": {"@": "owner"}, "boundObjectPropertyPath": "xAngle", - "oneway": false + "oneway": true } }, "listeners": [ @@ -159,7 +159,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot "value": { "boundObject": {"@": "owner"}, "boundObjectPropertyPath": "yAngle", - "oneway": false + "oneway": true } }, "listeners": [ @@ -190,7 +190,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot "value": { "boundObject": {"@": "owner"}, "boundObjectPropertyPath": "zAngle", - "oneway": false + "oneway": true } }, "listeners": [ diff --git a/js/panels/properties/sections/three-d-view.reel/three-d-view.js b/js/panels/properties/sections/three-d-view.reel/three-d-view.js index dda9f993..96053490 100644 --- a/js/panels/properties/sections/three-d-view.reel/three-d-view.js +++ b/js/panels/properties/sections/three-d-view.reel/three-d-view.js @@ -99,6 +99,14 @@ exports.ThreeD = Montage.create(Component, { value: null }, + _curMat: { + value: null + }, + + _curProp: { + value: null + }, + handleChange: { value: function(event) { if(event.wasSetByCode) { @@ -110,6 +118,9 @@ exports.ThreeD = Montage.create(Component, { this.item, this.inGlobalMode, false); + + this._curMat = null; + this._curProp = null; } }, @@ -129,8 +140,20 @@ exports.ThreeD = Montage.create(Component, { apply3DProperties : { value : function(prop, value, item, inGlobalMode, isChanging){ - var curMat = this.application.ninja.elementMediator.getMatrix(item); - var delta = value.value - this.application.ninja.elementMediator.get3DProperty(item, prop); + if(!this._curMat) + { + this._curMat = this.application.ninja.elementMediator.getMatrix(item); + } + var curMat = this._curMat; + var delta = value.value; + if(inGlobalMode) + { + if(!this._curProp) + { + this._curProp = this.application.ninja.elementMediator.get3DProperty(item, prop); + } + delta -= this._curProp; + } var xFormMat = Matrix.I(4); switch (prop) -- cgit v1.2.3 From 89d64cf06e170c3c50b02eeadd9dcf10d6efe1a3 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 2 Feb 2012 13:22:30 -0800 Subject: Updating Shapes PI to support corner radii. Also fixed PI bug where we were always updating custom section 0. Signed-off-by: Nivesh Rajbhandari --- .../rect-properties.reel/rect-properties.js | 2 +- js/controllers/elements/shapes-controller.js | 28 +++++++++++++ js/data/pi/pi-data.js | 48 +++++++++++++++------- js/panels/properties/content.reel/content.js | 7 +++- 4 files changed, 68 insertions(+), 17 deletions(-) (limited to 'js') diff --git a/js/components/tools-properties/rect-properties.reel/rect-properties.js b/js/components/tools-properties/rect-properties.reel/rect-properties.js index 8d0cd21f..1e717f88 100644 --- a/js/components/tools-properties/rect-properties.reel/rect-properties.js +++ b/js/components/tools-properties/rect-properties.reel/rect-properties.js @@ -113,7 +113,7 @@ exports.RectProperties = Montage.create(ToolProperties, { handleChange: { value: function(event) { - var hotTxt = event.currentTarget + var hotTxt = event.currentTarget; if(hotTxt.units === "%") { if(hotTxt.value > 50) { hotTxt.maxValue = 50; diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index d34644a7..c5f22138 100644 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -24,6 +24,26 @@ exports.ShapesController = Montage.create(CanvasController, { el.elementModel.shapeModel.GLGeomObj.setInnerRadius(val/100); el.elementModel.shapeModel.GLGeomObj.buildBuffers(); break; + case "tlRadius": + this.setShapeProperty(el, "tlRadius", value); + el.elementModel.shapeModel.GLGeomObj.setTLRadius(val); + el.elementModel.shapeModel.GLGeomObj.buildBuffers(); + break; + case "trRadius": + this.setShapeProperty(el, "trRadius", value); + el.elementModel.shapeModel.GLGeomObj.setTRRadius(val); + el.elementModel.shapeModel.GLGeomObj.buildBuffers(); + break; + case "blRadius": + this.setShapeProperty(el, "blRadius", value); + el.elementModel.shapeModel.GLGeomObj.setBLRadius(val); + el.elementModel.shapeModel.GLGeomObj.buildBuffers(); + break; + case "brRadius": + this.setShapeProperty(el, "brRadius", value); + el.elementModel.shapeModel.GLGeomObj.setBRRadius(val); + el.elementModel.shapeModel.GLGeomObj.buildBuffers(); + break; case "width": el.elementModel.shapeModel.GLGeomObj.setWidth(val); CanvasController.setProperty(el, p, value); @@ -46,8 +66,16 @@ exports.ShapesController = Montage.create(CanvasController, { getProperty: { value: function(el, p) { switch(p) { + case "stroke": + case "fill": case "strokeSize": case "innerRadius": + case "tlRadius": + case "trRadius": + case "blRadius": + case "brRadius": + case "strokeMaterial": + case "fillMaterial": return this.getShapeProperty(el, p); default: return CanvasController.getProperty(el, p); diff --git a/js/data/pi/pi-data.js b/js/data/pi/pi-data.js index f162e919..de5cd34d 100644 --- a/js/data/pi/pi-data.js +++ b/js/data/pi/pi-data.js @@ -279,11 +279,13 @@ exports.PiData = Montage.create( Montage, { [ { type : "color", - id : "stroke" + id : "stroke", + prop : "stroke" }, { type : "color", id : "fill", + prop : "fill", divider : true } ], @@ -313,10 +315,11 @@ exports.PiData = Montage.create( Montage, { id: "tlRadius", prop : "tlRadius", label: "TL", + valueMutator: parseFloat, value : 0, min : 0, max : 100, - unit : "%", + unit : "px", acceptableUnits: ["px", "pt", "%"] }, { @@ -324,10 +327,12 @@ exports.PiData = Montage.create( Montage, { id : "trRadius", prop : "trRadius", label : "TR", + valueMutator: parseFloat, min : 0, max : 100, - unit : "%", - acceptableUnits: ["px", "pt", "%"] + unit : "px", + acceptableUnits: ["px", "pt", "%"], + divider: true } ], [ @@ -336,9 +341,10 @@ exports.PiData = Montage.create( Montage, { id : "blRadius", prop : "blRadius", label : "BL", + valueMutator: parseFloat, min : 0, max : 100, - unit : "%", + unit : "px", acceptableUnits: ["px", "pt", "%"] }, { @@ -346,9 +352,10 @@ exports.PiData = Montage.create( Montage, { id : "brRadius", prop : "brRadius", label : "BR", + valueMutator: parseFloat, min : 0, max : 100, - unit : "%", + unit : "px", acceptableUnits: ["px", "pt", "%"] } ] @@ -362,13 +369,18 @@ exports.PiData = Montage.create( Montage, { { type: "dropdown", id: "strokeMaterial", + prop: "strokeMaterial", label: "Stroke", labelField: "_name", - items : { boundObject: "this.application.ninja.appModel", boundProperty: "materials" } - }, + items : { boundObject: "this.application.ninja.appModel", boundProperty: "materials" }, + divider : true + } + ], + [ { type: "dropdown", id: "fillMaterial", + prop: "fillMaterial", label: "Fill", labelField: "_name", items : { boundObject: "this.application.ninja.appModel", boundProperty: "materials" } @@ -387,7 +399,8 @@ exports.PiData = Montage.create( Montage, { [ { type : "color", - id : "stroke" + id : "stroke", + prop : "stroke" }, { type : "color", @@ -438,11 +451,13 @@ exports.PiData = Montage.create( Montage, { [ { type : "color", - id : "stroke" + id : "stroke", + prop : "stroke" }, { type : "color", id : "fill", + prop : "fill", divider : true } ], @@ -452,7 +467,6 @@ exports.PiData = Montage.create( Montage, { id : "strokeSize", prop : "strokeSize", label : "Stroke", - valueMutator: parseFloat, min : 0, max : 100, value : 1, @@ -471,7 +485,8 @@ exports.PiData = Montage.create( Montage, { type: "hottext", id: "innerRadius", prop: "innerRadius", - label: "Inner Radius", + label: "Inner R", + valueMutator: parseFloat, value : 0, min : 0, max : 100, @@ -490,13 +505,18 @@ exports.PiData = Montage.create( Montage, { { type: "dropdown", id: "strokeMaterial", + prop: "strokeMaterial", label: "Stroke", labelFunction: function(item) { return item.getName(); }, - items : { boundObject: "this.application.ninja.appModel", boundProperty: "materials" } - }, + items : { boundObject: "this.application.ninja.appModel", boundProperty: "materials" }, + divider : true + } + ], + [ { type: "dropdown", id: "fillMaterial", + prop: "fillMaterial", label: "Fill", labelField: "_name", items : { boundObject: "this.application.ninja.appModel", boundProperty: "materials" } diff --git a/js/panels/properties/content.reel/content.js b/js/panels/properties/content.reel/content.js index fe6faef8..3cedee6d 100644 --- a/js/panels/properties/content.reel/content.js +++ b/js/panels/properties/content.reel/content.js @@ -182,8 +182,11 @@ exports.Content = Montage.create(Component, { if(control.prop !== "border-color" && control.prop !== "background-color") { var currentValue = ElementsMediator.getProperty(el, control.prop, control.valueMutator); - currentValue ? currentValue = currentValue : currentValue = control.defaultValue; - this.customSections[0].content.controls[control.id] = currentValue; + if(currentValue === null) + { + currentValue = control.defaultValue; + } + this.customSections[i].content.controls[control.id] = currentValue; } } } -- cgit v1.2.3 From 7534bd7acc822dea641b1547cd955801920055aa Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 2 Feb 2012 13:55:55 -0800 Subject: Adding legal attribution for decompose matrix routine. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/math-utils.js | 54 ++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 25 deletions(-) (limited to 'js') diff --git a/js/helper-classes/3D/math-utils.js b/js/helper-classes/3D/math-utils.js index 49c77c41..71ed62a0 100644 --- a/js/helper-classes/3D/math-utils.js +++ b/js/helper-classes/3D/math-utils.js @@ -891,36 +891,32 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, { } }, +/** +* decompose matrix in javascript found at https://github.com/joelambert/morf/blob/master/js/src/WebkitCSSMatrix.ext.js +* used with permission from Joe Lambert: "as long as the original licence text and attribution is left in then you're +* good to use it as you see fit." +* +* WebKitCSSMatrix Extensions +* +* Copyright 2011, Joe Lambert (http://www.joelambert.co.uk) +* Free to use under the MIT license. +* http://joelambert.mit-license.org/ +*/ + +/** +* Decomposes the matrix into its component parts. +* A Javascript implementation of the pseudo code available from http://www.w3.org/TR/css3-2d-transforms/#matrix-decomposition +* @author Joe Lambert +* @returns {Object} An object with each of the components of the matrix (perspective, translate, skew, scale, rotate) or identity matrix on failure +*/ + // Input: matrix ; a 4x4 matrix // Output: translation ; a 3 component vector // rotation ; Euler angles, represented as a 3 component vector // scale ; a 3 component vector // skew ; skew factors XY,XZ,YZ represented as a 3 component vector // perspective ; a 4 component vector -// Returns false if the matrix cannot be decomposed, an object with the above output values if it can -// -// Supporting functions (point is a 3 component vector, matrix is a 4x4 matrix): -// float determinant(matrix) returns the 4x4 determinant of the matrix -// matrix inverse(matrix) returns the inverse of the passed matrix -// matrix transpose(matrix) returns the transpose of the passed matrix -// point multVecMatrix(point, matrix) multiplies the passed point by the passed matrix -// and returns the transformed point -// float length(point) returns the length of the passed vector -// point normalize(point) normalizes the length of the passed point to 1 -// float dot(point, point) returns the dot product of the passed points -// float cos(float) returns the cosine of the passed angle in radians -// float asin(float) returns the arcsine in radians of the passed value -// float atan2(float y, float x) returns the principal value of the arc tangent of -// y/x, using the signs of both arguments to determine -// the quadrant of the return value -// -// Decomposition also makes use of the following function: -// point combine(point a, point b, float ascl, float bscl) -// result[0] = (ascl * a[0]) + (bscl * b[0]) -// result[1] = (ascl * a[1]) + (bscl * b[1]) -// result[2] = (ascl * a[2]) + (bscl * b[2]) -// return result -// +// Returns false if the matrix cannot be decomposed. An object with the above output values if it can. decomposeMatrix2: { value: function(m) { @@ -1077,7 +1073,6 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, { rotate[2] = 0; } -// return true; return {translation: translate, rotation: rotate, scale: scale, @@ -1087,6 +1082,15 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, { } }, +/** +* Helper function required for matrix decomposition +* A Javascript implementation of pseudo code available from http://www.w3.org/TR/css3-2d-transforms/#matrix-decomposition +* @param {Vector4} aPoint A 3D point +* @param {float} ascl +* @param {float} bscl +* @author Joe Lambert +* @returns {Vector4} +*/ combine: { value: function(a, b, ascl, bscl) { -- cgit v1.2.3 From d41dee0c552a30724a146965ae4272a268777fc5 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 2 Feb 2012 14:53:14 -0800 Subject: Integrating Pan and Zoom tool and snap manager fixes. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/canvas-controller.js | 14 ++++---- js/helper-classes/3D/draw-utils.js | 3 +- js/helper-classes/3D/snap-manager.js | 11 +++++- js/stage/stage.reel/stage.js | 51 +++++++++++++++++++--------- js/tools/PanTool.js | 33 +++++++----------- js/tools/ZoomTool.js | 39 ++++++--------------- 6 files changed, 77 insertions(+), 74 deletions(-) (limited to 'js') diff --git a/js/controllers/elements/canvas-controller.js b/js/controllers/elements/canvas-controller.js index 21de9879..b5df3911 100644 --- a/js/controllers/elements/canvas-controller.js +++ b/js/controllers/elements/canvas-controller.js @@ -34,12 +34,12 @@ exports.CanvasController = Montage.create(ElementController, { } } }, - - setProperties: { - value: function(el, props, index) { - for(var p in props) { - el.elementModel.controller.setProperty(el, p, props[p][index]); - } - } + + setProperties: { + value: function(el, props, index) { + for(var p in props) { + el.elementModel.controller.setProperty(el, p, props[p][index]); + } + } } }); \ No newline at end of file diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index c26a5cd1..fd96af4d 100644 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -1089,7 +1089,8 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { var resMat = glmat4.multiply( tMat, mat, [] ); var origin = [0,0,0,1]; - var arrowSize = 50; + var zoomFactor = this.application.ninja.documentBar.zoomFactor/100.0; + var arrowSize = 50 / zoomFactor; var xAxis = [arrowSize,0,0,1]; //var rO = resMat.multiply(origin); var rO = glmat4.multiplyVec3( resMat, origin, []); diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js index 3ed96082..8819f637 100644 --- a/js/helper-classes/3D/snap-manager.js +++ b/js/helper-classes/3D/snap-manager.js @@ -1780,7 +1780,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { var mergedSnap = this.mergeHitRecords( hitRecs ); if (mergedSnap) { - while (hitRecs.length > 0) hitRecs.pop(); + while (hitRecs.length > 0) hitRecs.pop(); hitRecs.push( mergedSnap ); //console.log( "merged snaps" ); } @@ -1836,6 +1836,9 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { hSnap.setLocalPoint( localPt ); hSnap.setScreenPoint( scrPt ); hSnap.setType( hSnap.SNAP_TYPE_ALIGN_MERGED ); + hSnap.setElement( stage ); + hSnap.setPlane( [0,0,1,0] ); + hSnap.setPlaneMatrix( Matrix.I(4) ); if (vSnap.hasAssociatedScreenPoint() ) hSnap.setAssociatedScreenPoint( vSnap.getAssociatedScreenPoint() ); if (vSnap.hasAssociatedScreenPoint2() ) @@ -1882,6 +1885,9 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { hSnap.setLocalPoint( localPt ); hSnap.setScreenPoint( scrPt ); hSnap.setType( hSnap.SNAP_TYPE_ALIGN_MERGED ); + hSnap.setElement( stage ); + hSnap.setPlane( [0,0,1,0] ); + hSnap.setPlaneMatrix( Matrix.I(4) ); if (vSnap.hasAssociatedScreenPoint() ) hSnap.setAssociatedScreenPoint( vSnap.getAssociatedScreenPoint() ); if (vSnap.hasAssociatedScreenPoint2() ) @@ -1934,6 +1940,9 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { hSnap.setLocalPoint( localPt ); hSnap.setScreenPoint( scrPt ); hSnap.setType( hSnap.SNAP_TYPE_ALIGN_MERGED ); + hSnap.setElement( stage ); + hSnap.setPlane( [0,0,1,0] ); + hSnap.setPlaneMatrix( Matrix.I(4) ); if (vSnap.hasAssociatedScreenPoint() ) hSnap.setAssociatedScreenPoint( vSnap.getAssociatedScreenPoint() ); if (vSnap.hasAssociatedScreenPoint2() ) diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 8c4efd58..9e2df5a2 100644 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -787,14 +787,9 @@ exports.Stage = Montage.create(Component, { var userContent = this.application.ninja.currentDocument.documentRoot; if (userContent) { - var w = userContent.offsetWidth, - h = userContent.offsetHeight; - if(userContent.width) - w = userContent.width; - if(userContent.height) - h = userContent.height; - var localPt = [ w/2, h/2, 0]; - var globalPt = this.stageDeps.viewUtils.localToGlobal( localPt, userContent ); + var w = this._canvas.width, + h = this._canvas.height; + var globalPt = [w/2, h/2, 0]; this.stageDeps.viewUtils.setStageZoom( globalPt, value/100 ); @@ -811,6 +806,36 @@ exports.Stage = Montage.create(Component, { } }, + getPlaneForView: + { + value: function( side ) + { + var plane = [0,0,1,0]; + switch(side) + { + case "top": + plane = [0,1,0,0]; + plane[3] = this.application.ninja.currentDocument.documentRoot.offsetHeight / 2.0; + break; + + case "side": + plane = [1,0,0,0]; + plane[3] = this.application.ninja.currentDocument.documentRoot.offsetWidth / 2.0; + break; + + case "front": + plane = [0,0,1,0]; + break; + + default: + console.log( "unrecognized view in snapManager.getPlaneForView: " + side ); + break; + } + + return plane; + } + }, + setStageView: { value: function(side) { var mat, @@ -821,32 +846,26 @@ exports.Stage = Montage.create(Component, { currentDoc.elementModel.props3D.ResetRotationValues(); - switch(side) { + switch(side){ case "top": mat = Matrix.RotationX(Math.PI * 270.0/180.0); - drawUtils.drawXY = drawUtils.drawYZ = false; drawUtils.drawXZ = isDrawingGrid; - workingPlane = [0,1,0,0]; break; case "side": mat = Matrix.RotationY(Math.PI * 270/180); - drawUtils.drawXY = drawUtils.drawXZ = false; drawUtils.drawYZ = isDrawingGrid; - workingPlane = [1,0,0,0]; break; case "front": mat = Matrix.I(4); - drawUtils.drawYZ = drawUtils.drawXZ = false; drawUtils.drawXY = isDrawingGrid; - workingPlane = [0,0,1,0]; break; } - + workingPlane = this.getPlaneForView( side ); this.stageDeps.viewUtils.setMatrixForElement(currentDoc, mat, false); diff --git a/js/tools/PanTool.js b/js/tools/PanTool.js index ba40b020..71301d46 100644 --- a/js/tools/PanTool.js +++ b/js/tools/PanTool.js @@ -19,6 +19,7 @@ exports.PanTool = Montage.create(toolBase, _globalPt :{value: [0,0] , writable:true}, _globalToUCWorld :{value: [] , writable:true}, _lastGPt :{value: [0,0], writable:true}, + _lastY :{value: 0, writable:true}, Configure: { value: function ( doActivate ) @@ -43,6 +44,7 @@ exports.PanTool = Montage.create(toolBase, HandleLeftButtonDown: { value : function ( event ) { this._isDrawing = true; + this.isDrawing = true; this.mouseDown( event ); } @@ -68,6 +70,7 @@ exports.PanTool = Montage.create(toolBase, this.application.ninja.stage.clearDrawingCanvas(); this._hasDraw = false; this._isDrawing = false; + this.isDrawing = false; } } }, @@ -77,7 +80,6 @@ exports.PanTool = Montage.create(toolBase, if(event.altKey) { this._altKeyDown = true; - //console.log( "altKeyDown" ); } } }, @@ -87,7 +89,6 @@ exports.PanTool = Montage.create(toolBase, if(event.keyCode === Keyboard.ALT) { this._altKeyDown = false; - console.log( "altKeyUp" ); } } }, @@ -220,6 +221,7 @@ exports.PanTool = Montage.create(toolBase, var tmpLocal = MathUtils.transformAndDivideHomogeneousPoint( this._globalPt, globalToLocalMat ); this._lastGPt = this._globalPt.slice(); + this._lastY = this._lastGPt[1]; // set up the matrices we will be needing var eltToStageWorldMat = glmat4.multiply( ucMat, viewUtils.getObjToStageWorldMatrix(elt, true), []); @@ -275,14 +277,19 @@ exports.PanTool = Montage.create(toolBase, { if (this._isDrawing) { - //console.log( "PanTool.mouseMove (drag)" ); - // get the global screen point var gPt = [point.x, point.y, this._globalPt[2]]; + if (this._altKeyDown) + { + var dy = 5*(point.y - this._lastY); + this._globalPt[2] += dy; + gPt = [this._lastGPt[0], this._lastGPt[1], this._globalPt[2]]; + } // update the scrollbars var deltaGPt = VecUtils.vecSubtract(2, gPt, this._lastGPt); this._lastGPt = gPt.slice(); + this._lastY = point.y; var oldLeft = this.application.ninja.stage._iframeContainer.scrollLeft, oldTop = this.application.ninja.stage._iframeContainer.scrollTop; @@ -297,27 +304,13 @@ exports.PanTool = Montage.create(toolBase, this.updateGlobalToUCWorldMatrix(); var wPt = MathUtils.transformAndDivideHomogeneousPoint( gPt, this._globalToUCWorld ); - //console.log( "wPt: " + wPt ); var delta = vecUtils.vecSubtract( 3, wPt, this._worldPt ); - if (this._altKeyDown) - { - //console.log( "moveZ" ); - var dist = vecUtils.vecMag(2, delta); - delta[0] = 0; delta[1] = 0; delta[2] = dist; - var dy = point.y - this._globalPt[1]; - if (dy < 0) delta[2] = -delta[2]; - } - else - { - console.log( "NOT MOVING Z" ); + + if (!this._altKeyDown) delta[2] = 0; - } var transMat = Matrix.Translation( delta ); this._worldPt = wPt; - if (this._altKeyDown) - this._globalPt[1] = point.y; - // update everything this.applyDeltaMat( transMat ); } diff --git a/js/tools/ZoomTool.js b/js/tools/ZoomTool.js index cabf3a3d..4b6705c1 100644 --- a/js/tools/ZoomTool.js +++ b/js/tools/ZoomTool.js @@ -74,10 +74,12 @@ exports.ZoomTool = Montage.create(DrawingTool, { if(wasSelected) { this.AddCustomFeedback(); this.eventManager.addEventListener( "toolDoubl