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') 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 76db3eb0aa4ffe9e75812db570c793e9f852f853 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Mon, 11 Jun 2012 14:06:09 -0700 Subject: fix the brush tool runtime: update the brush coordinates to account for change in bounding box due to smoothing --- js/io/system/ninjalibrary.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/io/system/ninjalibrary.json b/js/io/system/ninjalibrary.json index e9df5e58..03753da9 100644 --- a/js/io/system/ninjalibrary.json +++ b/js/io/system/ninjalibrary.json @@ -1,6 +1,6 @@ { "libraries": [ {"name": "Montage", "path": "/node_modules/descriptor.json", "version": "0.10.0.0"}, - {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.5.9.0"} + {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.6.0.0"} ] } \ No newline at end of file -- 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') 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') 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 c629361d7182d5f4727caeab7c2b0822f33187c7 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 11 Jun 2012 15:43:31 -0700 Subject: Adding close Ninja prompt Adding a prompt to the user to ensure all data is saved prior to closing the application. This will not let me check for documents to need saving, so it must be general and will appear at all times. --- js/ninja.reel/ninja.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'js') diff --git a/js/ninja.reel/ninja.js b/js/ninja.reel/ninja.js index 38f5efcf..f0f8b46d 100755 --- a/js/ninja.reel/ninja.js +++ b/js/ninja.reel/ninja.js @@ -184,6 +184,10 @@ exports.Ninja = Montage.create(Component, { this.setupGlobalHelpers(); window.addEventListener("resize", this, false); + //Prompting the user to make sure data was saved before closing Ninja + window.onbeforeunload = function () { + return 'Are you sure you want to close Ninja? Any unsaved data will be lost.'; + }; this.eventManager.addEventListener("selectTool", this, false); this.eventManager.addEventListener("selectSubTool", this, false); -- cgit v1.2.3 From 19c77d87df72a85345e527d790878fc65eca189a Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 11 Jun 2012 15:44:15 -0700 Subject: Adding temp prompt UI component Added a temp prompt component and added on before close logic to ensure user does not lose data if the file needs saving when they close. --- js/components/prompt.reel/prompt.js | 73 +++++++++++++++++++++++++++++++++++++ js/document/document-html.js | 6 +-- js/document/models/base.js | 66 ++++++++++++++++++++++++--------- 3 files changed, 123 insertions(+), 22 deletions(-) create mode 100644 js/components/prompt.reel/prompt.js (limited to 'js') diff --git a/js/components/prompt.reel/prompt.js b/js/components/prompt.reel/prompt.js new file mode 100644 index 00000000..652d7b7e --- /dev/null +++ b/js/components/prompt.reel/prompt.js @@ -0,0 +1,73 @@ +/* +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. +
*/ + +//////////////////////////////////////////////////////////////////////// +// +var Montage = require("montage/core/core").Montage, + Component = require("montage/ui/component").Component; +//////////////////////////////////////////////////////////////////////// +// +exports.NinjaPrompt = Montage.create(Component, { + //////////////////////////////////////////////////////////////////// + //TODO: This should have an UI template eventually + hasTemplate: { + value: false + }, + //////////////////////////////////////////////////////////////////// + //Type of prompt window (should be confirm, prompt, alert, or input) + _type: { + value: null + }, + //////////////////////////////////////////////////////////////////// + // + _params: { + value: null + }, + //////////////////////////////////////////////////////////////////// + // + _callback: { + value: null + }, + //////////////////////////////////////////////////////////////////// + // + initialize: { + value: function (type, params, callback) { + // + this._type = type.toLowerCase(); + this._params = params; + this._callback = callback; + } + }, + //////////////////////////////////////////////////////////////////// + // + show: { + value: function () { + // + var input; + // + switch (this._type) { + case 'confirm': + input = confirm(this._params.message); + if (this._callback) this._callback(input); + break; + default: + //TODO: Add support for other standard box types + break; + } + } + }, + //////////////////////////////////////////////////////////////////// + //This is for later, need to hide if need (overwrite) + hide: { + value: function () { + //TODO: Add support as real UI component + } + } + //////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// +}); +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/js/document/document-html.js b/js/document/document-html.js index 04565753..8874c34b 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -115,10 +115,8 @@ exports.HtmlDocument = Montage.create(Component, { // closeDocument: { value: function (context, callback) { - //Closing document and getting outcome - var closed = this.model.close(null); - //Making callback if specified - if (callback) callback.call(context, this); + //Closing document (sending null to close all views) + this.model.close(null, function () {if (callback) callback.call(context, this);}.bind(this)); } }, //////////////////////////////////////////////////////////////////// diff --git a/js/document/models/base.js b/js/document/models/base.js index 5fa06259..0fd609c3 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -6,8 +6,9 @@ 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; +var Montage = require("montage/core/core").Montage, + Component = require("montage/ui/component").Component, + NinjaPrompt = require("js/components/prompt.reel").NinjaPrompt; //////////////////////////////////////////////////////////////////////// // exports.BaseDocumentModel = Montage.create(Component, { @@ -264,30 +265,59 @@ exports.BaseDocumentModel = Montage.create(Component, { if (this.callback) this.callback(result); } }, + //////////////////////////////////////////////////////////////////// + // + handleSavePrompt: { + value: function (continueToClose, callback) { + //TODO: Perhaps add logic to save the file is the user wants + if (continueToClose) { + if (callback) callback(); + } else { + //User canceled + //this.saveAll(null, callback); + } + } + }, //////////////////////////////////////////////////////////////////// //TODO: Implement better logic to include different views on single document close: { value: function (view, callback) { - //Outcome of close (pending on save logic) - var success; - // + //Checking if files needs to be saved to avoid losing data if (this.needsSave) { - //TODO: Prompt user to save or lose data + //Creating prompt to ask user to save the file + var prompt = NinjaPrompt.create(); + prompt.initialize('confirm', {message: 'Do you want to save the changes you made in the document '+this.file.name+'?\n\nYour changes will be lost if you do not save them.'}, function (result){this.handleSavePrompt(result, callback);}.bind(this)); + //Showing the prompt, it will make callback with user input + prompt.show(); } else { - //Close file - success = true; - } - //Checking for view mode to close - if (this.views.design && (!view || view === 'design')) { - //TODO: Create a destroy method, this is messy - this.views.design.pauseAndStopVideos(); - this.parentContainer.removeChild(this.views.design.iframe); - this.views.design = null; + //TODO: Add support for other views + if (!view || view === 'design') { + this.closeView('design'); + } + //Making callback + if (callback) callback(); } - //Returning result of operation - return success; + } - } + }, + //////////////////////////////////////////////////////////////////// + // + closeView: { + value: function (view) { + //Checking for view mode to close + switch (view.toLowerCase()) { + case 'design': + //TODO: Make into clean method in the design view + this.views.design.pauseAndStopVideos(); + this.parentContainer.removeChild(this.views.design.iframe); + this.views.design = null; + break; + default: + //TODO: Error? + break; + } + } + } //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// }); -- cgit v1.2.3 From e170a58eb8905d98fcdad3d61d652dad45443019 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Tue, 12 Jun 2012 09:14:32 -0700 Subject: allow the addition of anchor points to a closed path (the mouse move cursor still needs to be updated) --- js/tools/PenTool.js | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) (limited to 'js') diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index e296d0e5..52af294a 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js @@ -288,16 +288,35 @@ exports.PenTool = Montage.create(ShapeTool, { //assume we are not starting a new path as we will set this to true if we create a new Subpath() this._isNewPath = false; - - //if we had closed the selected subpath previously, or if we have not yet started anything, create a subpath - if (this._entryEditMode !== this.ENTRY_SELECT_PATH && this._selectedSubpath && this._selectedSubpath.getIsClosed() && this._makeMultipleSubpaths) { - this._selectedSubpath = null; - } if (this._subtool !== this.SUBTOOL_NONE && this._selectedSubpath===null) { //do nothing because the pen plus and pen minus subtools need a selected subpath return; } + + //build the hit record for the current mouse position (on the stage or the plane of the path canvas) + var hitRec = this.getHitRecord(event.pageX, event.pageY, false); + var globalMousePos=null, localMousePos=null, stageWorldMousePos = null, drawingCanvas=null; + if (this._selectedSubpathCanvas){ + globalMousePos = hitRec.getScreenPoint(); + localMousePos = ViewUtils.globalToLocal(globalMousePos, this._selectedSubpathCanvas); + } + + //if we have a selected subpath and canvas, check if the current click location hits the path + // todo optimize this...currently pickPath is called twice (see later in this function) + var hitPath = false; + if (this._selectedSubpath && this._selectedSubpathCanvas ) { + var tempSelAnchorAndParamAndCode = this._selectedSubpath.pickPath(localMousePos[0], localMousePos[1], localMousePos[2], this._PICK_POINT_RADIUS, true); + if (tempSelAnchorAndParamAndCode[2] !== this._selectedSubpath.SEL_NONE){ // ******* if we hit the path anywhere ********* + hitPath = true; + } + } + + //if we had closed the selected subpath previously, or if we have not yet started anything, create a subpath + if (this._entryEditMode !== this.ENTRY_SELECT_PATH && this._selectedSubpath && this._selectedSubpath.getIsClosed() && this._makeMultipleSubpaths && !hitPath) { + this._selectedSubpath = null; + } + if (this._selectedSubpath === null) { this._selectedSubpath = new SubPath(); this._selectedSubpathCanvas = null; @@ -335,9 +354,7 @@ exports.PenTool = Montage.create(ShapeTool, { this._selectedSubpath.setFillColor(colorArray); } //if the selectedSubpath was null and needed to be constructed - //build the hit record for the current mouse position (on the stage or the plane of the path canvas) - var hitRec = this.getHitRecord(event.pageX, event.pageY, false); - var globalMousePos=null, localMousePos=null, stageWorldMousePos = null, drawingCanvas=null; + //build the current mouse position in stage world space in case we don't already have a canvas if (!this._selectedSubpathCanvas){ drawingCanvas = this.application.ninja.currentDocument.model.documentRoot;//ViewUtils.getStageElement(); stageWorldMousePos = hitRec.calculateStageWorldPoint(); @@ -345,10 +362,7 @@ exports.PenTool = Montage.create(ShapeTool, { stageWorldMousePos[1]+= snapManager.getStageHeight()*0.5; localMousePos = stageWorldMousePos; //since the subpath points are in stage world space, set the 'localMousePos' to be stage world as well } - else { - globalMousePos = hitRec.getScreenPoint(); - localMousePos = ViewUtils.globalToLocal(globalMousePos, this._selectedSubpathCanvas); - } + if (this._selectedSubpathCanvas === null && this._subtool===this.SUBTOOL_NONE){ //IF this is the first anchor point of the selected subpath @@ -358,7 +372,6 @@ exports.PenTool = Montage.create(ShapeTool, { if (this._selectedSubpath.getNumAnchors()===0) { this._selectedSubpathPlaneMat = hitRec.getPlaneMatrix(); } - //check if the mouse click location is close to the existing anchor var indexAndCode = this._selectedSubpath.pickAnchor(stageWorldMousePos[0], stageWorldMousePos[1], stageWorldMousePos[2], this._PICK_POINT_RADIUS); if (indexAndCode[0]>=0){ @@ -853,9 +866,9 @@ exports.PenTool = Montage.create(ShapeTool, { this._editMode = this.EDIT_NONE; //if we're not in edit_path mode and we closed the selected subpath, then we are going to start a new subpath, so we nullify the selected subpath - if (this._selectedSubpath && this._selectedSubpath.getIsClosed() && this._entryEditMode !== this.ENTRY_SELECT_PATH){ - this._selectedSubpath = null; - } + //if (this._selectedSubpath && this._selectedSubpath.getIsClosed() && this._entryEditMode !== this.ENTRY_SELECT_PATH){ + // this._selectedSubpath = null; + //} if (this._selectedSubpath){ this.DrawSubpathAnchors(this._selectedSubpath);//render the subpath anchors on canvas -- cgit v1.2.3 From 0dd995834865202de1c51b1b4635f6515f54b1ea Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Tue, 12 Jun 2012 09:57:13 -0700 Subject: correct mouse cursor on mousemove --- js/tools/PenTool.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'js') diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index 52af294a..33ca5c71 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js @@ -539,7 +539,9 @@ exports.PenTool = Montage.create(ShapeTool, { //set the cursor to be the default cursor (depending on whether the selected subpath has any points yet) if (this._subtool===this.SUBTOOL_NONE){ - if (this._selectedSubpath && this._selectedSubpath.getNumAnchors()>0){ + if ((this._selectedSubpath && this._selectedSubpath.getNumAnchors()>0 && !this._selectedSubpath.getIsClosed()) + || + this._entryEditMode === this.ENTRY_SELECT_PATH){ this.application.ninja.stage.drawingCanvas.style.cursor = //"auto"; "url('images/cursors/penCursors/Pen_.png') 5 1, default"; } -- cgit v1.2.3 From 4d9b676db06a3d4ff5f4cf0f35e8fc998e0000c5 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Tue, 12 Jun 2012 10:16:20 -0700 Subject: ignore hardness for calligraphic brushes if stroke width is 1 --- js/lib/geom/brush-stroke.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'js') diff --git a/js/lib/geom/brush-stroke.js b/js/lib/geom/brush-stroke.js index d9c2ab53..0e0406dd 100755 --- a/js/lib/geom/brush-stroke.js +++ b/js/lib/geom/brush-stroke.js @@ -719,7 +719,10 @@ BrushStroke.prototype.drawToContext = function(ctx, drawStageWorldPts, stageWorl var disp = [brushStamp[t][0], brushStamp[t][1]]; var alphaVal = 1.0; var distFromOpaqueRegion = Math.abs(t-halfNumTraces) - opaqueRegionHalfWidth; - if (distFromOpaqueRegion>0) { + if (numTraces === 1){ + distFromOpaqueRegion = 0; + } + else if (distFromOpaqueRegion>0) { var transparencyFactor = distFromOpaqueRegion/maxTransparentRegionHalfWidth; alphaVal = 1.0 - transparencyFactor;//(transparencyFactor*transparencyFactor);//the square term produces nonlinearly varying alpha values alphaVal *= 0.5; //factor that accounts for lineWidth == 2 -- cgit v1.2.3 From 58b07496e616fe1c05c7f8e47ba97a7368b0ea88 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 12 Jun 2012 16:30:43 -0700 Subject: IKNINJA-1675 - Cannot resize SVG using free transform tool. Signed-off-by: Nivesh Rajbhandari --- js/models/element-model.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'js') diff --git a/js/models/element-model.js b/js/models/element-model.js index 76f15b21..e5a0f33a 100755 --- a/js/models/element-model.js +++ b/js/models/element-model.js @@ -91,6 +91,8 @@ var elementNameToController = function(name) { return "block"; } else if(name === "img") { return "image"; + } else if(name === "embed") { + return "image"; } else { return name; } @@ -174,6 +176,8 @@ var elmo = exports.ElementModel = Montage.create(Montage, { return "block"; } else if(name === "img") { return "image"; + } else if(name === "embed") { + return "image"; } else { return name; } -- cgit v1.2.3