From b5d41c64de2875e2f8b31ec11268cb9f2d30780a Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 16 Feb 2012 23:38:48 -0800 Subject: Fixing the getStageWorldToGlobalMatrix bug removing the snapManager reference in viewUtils Signed-off-by: Valerio Virgillito --- js/helper-classes/3D/view-utils.js | 42 ++++++++++++++------------------------ 1 file changed, 15 insertions(+), 27 deletions(-) (limited to 'js') diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js index c8e20def..a2fac34f 100755 --- a/js/helper-classes/3D/view-utils.js +++ b/js/helper-classes/3D/view-utils.js @@ -4,16 +4,16 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ -var vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils, - snapManagerModule = require("js/helper-classes/3D/snap-manager"), +var Montage = require("montage/core/core").Montage, + Component = require("montage/ui/component").Component, + vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils, Rectangle = require("js/helper-classes/3D/rectangle").Rectangle, ElementsMediator = require("js/mediators/element-mediator").ElementMediator; /////////////////////////////////////////////////////////////////////// // Class ViewUtils // Viewing Utility functions /////////////////////////////////////////////////////////////////////// -var ViewUtils = exports.ViewUtils = Object.create(Object.prototype, -{ +exports.ViewUtils = Montage.create(Component, { /////////////////////////////////////////////////////////////////////// // Instance variables /////////////////////////////////////////////////////////////////////// @@ -133,7 +133,7 @@ var ViewUtils = exports.ViewUtils = Object.create(Object.prototype, var xVec = [mat[0], mat[1], mat[2], mat[3]]; var yVec = [mat[4], mat[5], mat[6], mat[7]]; - var stage = snapManagerModule.SnapManager.getStage(); + var stage = this.application.ninja.currentDocument.documentRoot; var stageMat = this.getMatrixFromElement(stage); var stagePlane = [stageMat[8], stageMat[9], stageMat[10], stageMat[11]]; @@ -412,7 +412,7 @@ var ViewUtils = exports.ViewUtils = Object.create(Object.prototype, // get the four corners of the element in global space var bounds = this.getElementViewBounds3D( elt ); var bounds3D = new Array(); - var stage = snapManagerModule.SnapManager.getStage(); + var stage = this.application.ninja.currentDocument.documentRoot; for (var i=0; i<3; i++) { var gPt = this.localToGlobal( bounds[i], elt ); @@ -789,7 +789,7 @@ var ViewUtils = exports.ViewUtils = Object.create(Object.prototype, getStageWorldToGlobalMatrix: { value: function() { - var stage = snapManagerModule.SnapManager.getStage(); + var stage = this.application.ninja.currentDocument.documentRoot; this.pushViewportObj( stage ); // get the matrix to the parent @@ -1190,12 +1190,7 @@ var ViewUtils = exports.ViewUtils = Object.create(Object.prototype, // drawLayoutModule.drawLayout.redrawDocument() OR // window.stageManager.drawSelectionRec(true) this.getStage().draw(); // drawLayoutModule.drawLayout.redrawDocument(); -// -// SNAP MANAGER -// snapManager: snapManagerModule.SnapManager -// snapManagerModule: snapManagerModule = r_equire("js/helper-classes/3D/snap-manager") -// stage stage = snapManagerModule.SnapManager.getStage(); -// + // SELECTION MANAGER // selected elements: this.application.ninja.selectedElements // selectionManager this.application.ninja.selectionController @@ -1213,10 +1208,10 @@ var ViewUtils = exports.ViewUtils = Object.create(Object.prototype, clearStageTranslation: { value: function() { - if (snapManagerModule.SnapManager.application.ninja.currentDocument) + if (this.application.ninja.currentDocument) { // get the user content object - var userContent = snapManagerModule.SnapManager.application.ninja.currentDocument.documentRoot; + var userContent = this.application.ninja.currentDocument.documentRoot; if (!userContent) return; this.setViewportObj( userContent ); @@ -1235,9 +1230,10 @@ var ViewUtils = exports.ViewUtils = Object.create(Object.prototype, value:function( globalPt, zoomFactor ) { var localPt; var tmp1, tmp2, tmp3; - if (snapManagerModule.SnapManager.application.ninja.currentDocument) + + if (this.application.ninja.currentDocument) { - var userContent = snapManagerModule.SnapManager.application.ninja.currentDocument.documentRoot; + var userContent = this.application.ninja.currentDocument.documentRoot; if (!userContent) return; this.setViewportObj( userContent ); var userContentMat = this.getMatrixFromElement(userContent); @@ -1285,7 +1281,7 @@ var ViewUtils = exports.ViewUtils = Object.create(Object.prototype, tmp2 = this.localToGlobal( localPt, userContent ); // DEBUG - remove this line // apply to the stage background -// var stageBG = snapManagerModule.SnapManager.application.ninja.currentDocument.stageBG; +// var stageBG = this.application.ninja.currentDocument.stageBG; // var stageBGMat = this.getMatrixFromElement(stageBG); // var newStageBGMat = glmat4.multiply( mat, stageBGMat, []); // this.setMatrixForElement(stageBG, newStageBGMat ); @@ -1298,15 +1294,7 @@ var ViewUtils = exports.ViewUtils = Object.create(Object.prototype, { value: function() { - return this.getStage.canvas; - } - }, - - getSnapManager: - { - value: function() - { - return snapManagerModule.SnapManager; + return this.application.ninjs.stage.canvas; } }, -- cgit v1.2.3 From d47c4c0f6053fb8390526f32c2ee08dee0bdec20 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 17 Feb 2012 15:22:23 -0800 Subject: Chrome Preview --- js/controllers/document-controller.js | 3 +-- js/data/menu-data.js | 9 +++++++ js/document/html-document.js | 45 +++++++++++++++++++++++++++++++++++ js/mediators/keyboard-mediator.js | 6 +++++ js/models/app-model.js | 12 ++++++++++ js/ninja.reel/ninja.js | 7 ++++++ 6 files changed, 80 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 5e2a6461..1f339fe7 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -61,11 +61,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.eventManager.addEventListener("recordStyleChanged", this, false); - - } }, + handleWebRequest: { value: function (request) { diff --git a/js/data/menu-data.js b/js/data/menu-data.js index 6503e776..7c3ca5d4 100755 --- a/js/data/menu-data.js +++ b/js/data/menu-data.js @@ -139,6 +139,15 @@ exports.MenuData = Montage.create( Montage, { "boundProperty": "livePreview" } }, + { + "displayText" : "Chrome Preview", + "hasSubMenu" : false, + "enabled": true, + "checked": { + "value": false, + "boundProperty": "chromePreview" + } + }, { "displayText" : "Layout View", "hasSubMenu" : false, diff --git a/js/document/html-document.js b/js/document/html-document.js index ae2b4600..77cc711d 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -363,6 +363,9 @@ exports.HTMLDocument = Montage.create(TextDocument, { // handleEvent: { value: function(event){ + //TODO: Remove + window.hackPreview = this.livePreview.bind(this); + this.application.ninja.documentController._hackRootFlag = true; //console.log(this._userDocument.root, this); //TODO: Clean up, using for prototyping save @@ -471,6 +474,48 @@ exports.HTMLDocument = Montage.create(TextDocument, { } }, + + + + + + + + + + + + + + + + + + + + + + + //////////////////////////////////////////////////////////////////// + // + livePreview: { + enumerable: false, + value: function () { + //this.application.ninja.documentController + //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]); + chrome.tabs.create({url: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]}); + } + }, + //////////////////////////////////////////////////////////////////// + + + + + + + + + //////////////////////////////////////////////////////////////////// // save: { diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js index a1fdead3..e8a11ad8 100755 --- a/js/mediators/keyboard-mediator.js +++ b/js/mediators/keyboard-mediator.js @@ -201,6 +201,12 @@ exports.KeyboardMediator = Montage.create(Component, { if(this.application.ninja.toolsData) this.application.ninja.toolsData.selectedToolInstance.HandleEscape(evt); //menuViewManagerModule.MenuViewManager.closeMenu("mainMenuBar"); } + + // Check if cmd+a/ctrl+a for Select All + if((evt.keyCode == Keyboard.ENTER) && (evt.ctrlKey || evt.metaKey)) { + this.application.ninja.executeChromePreview(); + return; + } if(this.application.ninja.toolsData) this.application.ninja.toolsData.selectedToolInstance.HandleKeyPress(evt); diff --git a/js/models/app-model.js b/js/models/app-model.js index bfa1871c..1c599a32 100755 --- a/js/models/app-model.js +++ b/js/models/app-model.js @@ -21,6 +21,18 @@ exports.AppModel = Montage.create(Component, { this._livePreview = value; } }, + _chromePreview: { + value: false + }, + + chromePreview: { + get: function() { + return this._chromePreview; + }, + set: function(value) { + this._chromePreview = value; + } + }, _layoutView: { value: "layoutAll" diff --git a/js/ninja.reel/ninja.js b/js/ninja.reel/ninja.js index 43087c39..399d7b4d 100755 --- a/js/ninja.reel/ninja.js +++ b/js/ninja.reel/ninja.js @@ -60,11 +60,18 @@ exports.Ninja = Montage.create(Component, { this.eventManager.addEventListener( "onOpenDocument", this, false); this.addEventListener("change@appModel.livePreview", this.executeLivePreview, false); + this.addEventListener("change@appModel.chromePreview", this.executeChromePreview, false); this.addEventListener("change@appModel.debug", this.toggleDebug, false); NJevent("appLoading"); } }, + + executeChromePreview: { + value: function () { + this.application.ninja.documentController.activeDocument.livePreview(); + } + }, handleResize: { value: function() { -- cgit v1.2.3 From 9bfdc1fff649fa4a086e7dc291af21b431a5b95c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 17 Feb 2012 15:54:34 -0800 Subject: Re-adding stage mouse wheel scrolling Signed-off-by: Valerio Virgillito --- js/stage/stage.reel/stage.html | 2 +- js/stage/stage.reel/stage.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'js') diff --git a/js/stage/stage.reel/stage.html b/js/stage/stage.reel/stage.html index 9ed0f636..812e3d55 100755 --- a/js/stage/stage.reel/stage.html +++ b/js/stage/stage.reel/stage.html @@ -82,7 +82,7 @@
-
asdasd asd asd asd asd asd
+
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 59eb9317..37b1df35 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -201,6 +201,7 @@ exports.Stage = Montage.create(Component, { this._drawingCanvas.addEventListener("mousedown", this, false); this._drawingCanvas.addEventListener("mouseup", this, false); this._drawingCanvas.addEventListener("dblclick", this, false); + this._drawingCanvas.addEventListener("mousewheel", this, false); // Hide the canvas this.hideCanvas(true); @@ -360,6 +361,16 @@ exports.Stage = Montage.create(Component, { } }, + handleMousewheel: { + value: function(event) { + if(event._event.wheelDelta > 0) { + this._iframeContainer.scrollTop -= 20; + } else { + this._iframeContainer.scrollTop += 20; + } + } + }, + /** * Enables the MouseMove on Canvas */ -- cgit v1.2.3