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 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 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