From 48bb94a72126e7be712b2c4ca9be2f03ecb65aea Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 25 Jun 2012 14:54:16 -0700 Subject: IKNinja-1688 - Creating a banner file after a code file causes body div to shift to the right and has different scroll bars. Signed-off-by: Nivesh Rajbhandari --- js/panels/Splitter.js | 8 ++++++-- js/stage/stage.reel/stage.js | 16 ++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) (limited to 'js') diff --git a/js/panels/Splitter.js b/js/panels/Splitter.js index c6d46911..4f2a137e 100755 --- a/js/panels/Splitter.js +++ b/js/panels/Splitter.js @@ -156,7 +156,7 @@ exports.Splitter = Montage.create(Component, { } }, restore:{ - value: function() { + value: function(onSwitchFromCodeDocument) { //Get splitter initial value from SettingManager var storedData = this.application.localStorage.getItem(this.element.getAttribute("data-montage-id")), temp = this.collapsed; if(storedData && this.element.getAttribute("data-montage-id") !== null) { @@ -172,7 +172,11 @@ exports.Splitter = Montage.create(Component, { this.panel.addEventListener("webkitTransitionEnd", this, false); } this.disabled = false; - this.needsDraw = true; + if(onSwitchFromCodeDocument) { + this.draw(); // When switching from code document, draw immediately so stage size is correct + } else { + this.needsDraw = true; + } } } } diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 5e913c76..319ffe87 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -19,6 +19,7 @@ exports.Stage = Montage.create(Component, { // TODO - Need to figure out how to remove this dependency // Needed by some tools that depend on selectionDrawn event to set up some logic drawNow: { value : false }, + switchedFromCodeDoc: { value : false }, // TO REVIEW zoomFactor: {value : 1 }, @@ -256,6 +257,8 @@ exports.Stage = Montage.create(Component, { //call configure false with the old document on the selected tool to tear down down any temp. stuff this.application.ninja.toolsData.selectedToolInstance._configure(false); + } else if(this.currentDocument && (this.currentDocument.currentView === "code")) { + this.switchedFromCodeDoc = true; // Switching from code document affects stage's size and scrollbar } this._currentDocument = value; @@ -266,7 +269,8 @@ exports.Stage = Montage.create(Component, { drawUtils._eltArray.length = 0; drawUtils._planesArray.length = 0; } else if(this._currentDocument.currentView === "design") { - this.restoreAllPanels(); + this.restoreAllPanels(this.switchedFromCodeDoc); + this.switchedFromCodeDoc = false; this.hideCanvas(false); this.showRulers(); @@ -1271,11 +1275,11 @@ exports.Stage = Montage.create(Component, { } }, restoreAllPanels:{ - value:function(){ - this.application.ninja.panelSplitter.restore(); - this.application.ninja.timelineSplitter.restore(); - this.application.ninja.toolsSplitter.restore(); - this.application.ninja.optionsSplitter.restore(); + value:function(onSwitchDocument){ + this.application.ninja.panelSplitter.restore(onSwitchDocument); + this.application.ninja.timelineSplitter.restore(onSwitchDocument); + this.application.ninja.toolsSplitter.restore(onSwitchDocument); + this.application.ninja.optionsSplitter.restore(onSwitchDocument); } }, -- cgit v1.2.3 From 3b2c406210854a95c27660496f5aef1c1391c1e4 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 25 Jun 2012 16:02:04 -0700 Subject: Fix for Pan Tool not working when initially opening banner or animation template files. Also, fixed a case where the "stage" would become transparent due to rounding issues. Signed-off-by: Nivesh Rajbhandari --- js/tools/PanTool.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/tools/PanTool.js b/js/tools/PanTool.js index a8911c0c..fce8a7d7 100755 --- a/js/tools/PanTool.js +++ b/js/tools/PanTool.js @@ -47,8 +47,8 @@ exports.PanTool = Montage.create(toolBase, HandleLeftButtonDown: { value : function ( event ) { // Determine the maximum horizontal and vertical scroll values - this._maxHorizontalScroll = this.application.ninja.currentDocument.model.documentRoot.scrollWidth - this.application.ninja.stage._canvas.width - 11; - this._maxVerticalScroll = this.application.ninja.currentDocument.model.documentRoot.scrollHeight - this.application.ninja.stage._canvas.height - 11; + this._maxHorizontalScroll = this.application.ninja.currentDocument.model.views.design.document.body.scrollWidth - this.application.ninja.stage._canvas.width - 11; + this._maxVerticalScroll = this.application.ninja.currentDocument.model.views.design.document.body.scrollHeight - this.application.ninja.stage._canvas.height - 11; if((this._maxHorizontalScroll > 0) || (this._maxVerticalScroll > 0) || this._altKeyDown) { this._isDrawing = true; @@ -239,6 +239,8 @@ exports.PanTool = Montage.create(toolBase, this._localPt = [cop[0] + localPt[0], cop[1] + localPt[1], localPt[2]]; viewUtils.popViewportObj(); } + this._localPt[0] = Math.round(this._localPt[0]); + this._localPt[1] = Math.round(this._localPt[1]); this._globalPt = MathUtils.transformAndDivideHomogeneousPoint( this._localPt, localToGlobalMat ); var tmpLocal = MathUtils.transformAndDivideHomogeneousPoint( this._globalPt, globalToLocalMat ); -- cgit v1.2.3 From 96e1bb2a8d842dc37e4982a273a5bde48f6944c3 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Mon, 25 Jun 2012 16:37:06 -0700 Subject: Fix for IKNINJA-1615: Enable mouse up event on top of the user document scrollbar Chrome has a bug where mouse up does not fire when the mouse is released on top of a scrollbar. To work around this issue, I temporary increase the canvas to cover the scrollbar when drawing and then shrink it back on mouse up. Signed-off-by: Valerio Virgillito --- js/mediators/mouse-mediator.js | 31 ------------------------------- js/ninja.reel/ninja.html | 4 ---- js/stage/stage.reel/stage.js | 33 ++++++++++++++++++++++++++++++--- 3 files changed, 30 insertions(+), 38 deletions(-) delete mode 100755 js/mediators/mouse-mediator.js (limited to 'js') diff --git a/js/mediators/mouse-mediator.js b/js/mediators/mouse-mediator.js deleted file mode 100755 index 4d1fb62a..00000000 --- a/js/mediators/mouse-mediator.js +++ /dev/null @@ -1,31 +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. -
*/ - -var Montage = require("montage/core/core").Montage, - Component = require("montage/ui/component").Component; - -exports.MouseMediator = Montage.create(Component, { - hasTemplate: { - value: false - }, - - deserializedFromTemplate: { - value: function() { - document.addEventListener("mouseup", this, false); - } - }, - - handleMouseup: { - value: function(event) { - - if(event._event.target.id !== "drawingCanvas") { - NJevent( "appMouseUp"); - } - - return true; - } - } -}); diff --git a/js/ninja.reel/ninja.html b/js/ninja.reel/ninja.html index beae59d9..1bd002ae 100755 --- a/js/ninja.reel/ninja.html +++ b/js/ninja.reel/ninja.html @@ -261,10 +261,6 @@ } }, - "mouseMediator": { - "prototype": "js/mediators/mouse-mediator" - }, - "keyboardMediator": { "prototype": "js/mediators/keyboard-mediator", "properties":{ diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index f4de3070..1de4e003 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -343,8 +343,6 @@ exports.Stage = Montage.create(Component, { // Hide the canvas this.hideCanvas(true); - this.eventManager.addEventListener( "appMouseUp", this, false); - this.eventManager.addEventListener( "enableStageMove", this, false); this.eventManager.addEventListener( "disableStageMove", this, false); @@ -454,6 +452,7 @@ exports.Stage = Montage.create(Component, { enableMouseInOut: { value: function() { + document.addEventListener("mouseup", this, true); this._drawingCanvas.addEventListener("mouseout", this, false); this._drawingCanvas.addEventListener("mouseover", this, false); } @@ -466,6 +465,19 @@ exports.Stage = Montage.create(Component, { } }, + captureMouseup: { + value: function(event) { + var target = event._event.target.getAttribute("data-montage-id"); + + if(target && target === "drawingCanvas") { + return true; + } else { + this.handleAppMouseUp(event); + return true; + } + } + }, + handleMouseout: { value: function(event) { this.outFlag = true; @@ -480,6 +492,11 @@ exports.Stage = Montage.create(Component, { handleMousedown: { value: function(event) { + + // Increase the canvas to cover the scroll bars + this._drawingCanvas.height = this._drawingCanvas.height + 11; + this._drawingCanvas.width = this._drawingCanvas.width + 11; + // Call the focus manager to set focus to blur any focus'd elements this.focusManager.setFocus(); @@ -509,13 +526,18 @@ exports.Stage = Montage.create(Component, { handleMouseup: { value: function(event) { + // Restore canvas to un-cover the scroll bars. + this._drawingCanvas.height = this._drawingCanvas.height - 11; + this._drawingCanvas.width = this._drawingCanvas.width - 11; // If the mouse up comes from dismissing the context menu return + if(this.contextMenu) { this.contextMenu = false; return; } - //this.disableMouseInOut(); + this.disableMouseInOut(); + document.removeEventListener("mouseup", this, true); this.application.ninja.toolsData.selectedToolInstance.HandleLeftButtonUp(event); @@ -563,12 +585,17 @@ exports.Stage = Montage.create(Component, { handleAppMouseUp: { value: function(event) { if(this.outFlag) { + this._drawingCanvas.height = this._drawingCanvas.height - 11; + this._drawingCanvas.width = this._drawingCanvas.width - 11; + if(this.application.ninja.toolsData.selectedToolInstance.isDrawing) { this.application.ninja.toolsData.selectedToolInstance.HandleLeftButtonUp(event); } this.disableMouseInOut(); this.outFlag = false; } + + document.removeEventListener("mouseup", this, true); } }, -- cgit v1.2.3