From b72c5f72ea5df4aa164350e1ba66fd1b4e23369d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 17 May 2012 23:07:48 -0700 Subject: removing all stageDeps for drawing classes. Signed-off-by: Valerio Virgillito --- js/stage/stage-deps.js | 61 ++++++------------------------------------ js/stage/stage.reel/stage.html | 3 --- 2 files changed, 8 insertions(+), 56 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js index 1825eb06..17039438 100755 --- a/js/stage/stage-deps.js +++ b/js/stage/stage-deps.js @@ -11,8 +11,7 @@ var Montage = require("montage/core/core").Montage, drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, ElementPlanes = require("js/helper-classes/3D/element-planes").ElementPlanes, MathUtilsClass = require("js/helper-classes/3D/math-utils").MathUtilsClass, - VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils, - DrawingToolBase = require("js/tools/drawing-tool-base").DrawingToolBase; + VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; exports.StageDeps = Montage.create(Component, { viewUtils: { @@ -27,24 +26,6 @@ exports.StageDeps = Montage.create(Component, { value: drawUtils }, - currentStage: { - value: null - }, - - _currentDocument: { - value: null - }, - - currentDocument: { - get: function() { return this._currentDocument; }, - set: function(value) { - if(value) { - this._currentDocument = value; - this.currentStage = value.documentRoot; - } - } - }, - _userContentLeft: { value: null }, @@ -112,7 +93,9 @@ exports.StageDeps = Montage.create(Component, { // bind the snap properties to the snap manager snapManager.bindSnap(); - + drawUtils.viewUtils = viewUtils; + drawUtils.snapManager = snapManager; + drawUtils.ElementPlanes = ElementPlanes; } }, @@ -121,22 +104,8 @@ exports.StageDeps = Montage.create(Component, { workingPlane = [0,0,1,0]; - snapManager.setCurrentStage(this.currentStage); - - viewUtils.setCurrentDocument(this.currentDocument); - viewUtils.setRootElement(this.currentStage.parentNode); - viewUtils.setStageElement(this.currentStage); - - drawUtils.viewUtils = viewUtils; - drawUtils.snapManager = snapManager; - drawUtils.ElementPlanes = ElementPlanes; - - snapManager._isCacheInvalid=true; - - snapManager.setupDragPlaneFromPlane ( workingPlane ); - - DrawingToolBase.stage = this.currentStage; - DrawingToolBase.stageComponent = this.stage; + snapManager._isCacheInvalid = true; + snapManager.setupDragPlaneFromPlane (workingPlane); drawUtils.initializeFromDocument(); } @@ -147,22 +116,8 @@ exports.StageDeps = Montage.create(Component, { workingPlane = [0,0,1,0]; - snapManager.setCurrentStage(this.currentStage); - - viewUtils.setCurrentDocument(this.currentDocument); - viewUtils.setRootElement(this.currentStage.parentNode); - viewUtils.setStageElement(this.currentStage); - - drawUtils.viewUtils = viewUtils; - drawUtils.snapManager = snapManager; - drawUtils.ElementPlanes = ElementPlanes; - - snapManager._isCacheInvalid=true; - - snapManager.setupDragPlaneFromPlane ( workingPlane ); - - DrawingToolBase.stage = this.currentStage; - DrawingToolBase.stageComponent = this.stage; + snapManager._isCacheInvalid = true; + snapManager.setupDragPlaneFromPlane (workingPlane); drawUtils.initializeFromDocument(); } diff --git a/js/stage/stage.reel/stage.html b/js/stage/stage.reel/stage.html index 88cd6149..30c3d231 100755 --- a/js/stage/stage.reel/stage.html +++ b/js/stage/stage.reel/stage.html @@ -22,9 +22,6 @@ "prototype": "js/stage/stage-deps", "properties": { "stage": {"@": "owner"} - }, - "bindings": { - "currentDocument": {"<-": "@owner.activeDocument"} } }, -- cgit v1.2.3 From 7a94696e19b14e15261df516e2ba75e693b1313d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 18 May 2012 00:21:56 -0700 Subject: enabling basic document switching Signed-off-by: Valerio Virgillito --- js/stage/stage-deps.js | 13 +++++-------- js/stage/stage-view.reel/stage-view.js | 22 ---------------------- 2 files changed, 5 insertions(+), 30 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js index 17039438..84f04249 100755 --- a/js/stage/stage-deps.js +++ b/js/stage/stage-deps.js @@ -55,8 +55,9 @@ exports.StageDeps = Montage.create(Component, { deserializedFromTemplate: { value: function() { - this.eventManager.addEventListener( "appLoaded", this, false); - this.eventManager.addEventListener( "openDocument", this, false); + this.eventManager.addEventListener("appLoaded", this, false); + this.eventManager.addEventListener("openDocument", this, false); + this.eventManager.addEventListener("switchDocument", this, false); // Initialize Deps // HACK @@ -111,9 +112,8 @@ exports.StageDeps = Montage.create(Component, { } }, - reinitializeForSwitchDocument: { - value: function() { - + handleSwitchDocument: { + value: function(){ workingPlane = [0,0,1,0]; snapManager._isCacheInvalid = true; @@ -122,7 +122,4 @@ exports.StageDeps = Montage.create(Component, { drawUtils.initializeFromDocument(); } } - - - }); \ No newline at end of file diff --git a/js/stage/stage-view.reel/stage-view.js b/js/stage/stage-view.reel/stage-view.js index ba94fadf..757c5e51 100755 --- a/js/stage/stage-view.reel/stage-view.js +++ b/js/stage/stage-view.reel/stage-view.js @@ -112,28 +112,6 @@ exports.StageView = Montage.create(Component, { */ switchDocument:{ value: function(doc){ - this.application.ninja.documentController._hideCurrentDocument(); - this.application.ninja.documentController.activeDocument = doc; - - if(this.application.ninja.documentController.activeDocument.currentView === "design") { - this.application.ninja.currentDocument = this.application.ninja.documentController.activeDocument; - } - - this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe - - -// this.application.ninja.documentController._showCurrentDocument(); - // Inline function below - if(this.activeDocument) { - this.activeDocument.container.style["display"] = "block"; - if(this.activeDocument.currentView === "design"){ - this.activeDocument.container.parentNode.style["display"] = "block"; - this.activeDocument.restoreAppState(); - } else { - //hide the iframe when switching to code view - document.getElementById("iframeContainer").style.display = "none"; - } - } //focus editor -- cgit v1.2.3 From 084bb924bc3c3a6ad1e2e21099399bba4d473fed Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 18 May 2012 00:41:31 -0700 Subject: fixing some snapping bugs Signed-off-by: Valerio Virgillito --- js/stage/stage-deps.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js index 84f04249..0d53696b 100755 --- a/js/stage/stage-deps.js +++ b/js/stage/stage-deps.js @@ -105,7 +105,7 @@ exports.StageDeps = Montage.create(Component, { workingPlane = [0,0,1,0]; - snapManager._isCacheInvalid = true; + snapManager.reload2DCache(); snapManager.setupDragPlaneFromPlane (workingPlane); drawUtils.initializeFromDocument(); @@ -116,8 +116,9 @@ exports.StageDeps = Montage.create(Component, { value: function(){ workingPlane = [0,0,1,0]; - snapManager._isCacheInvalid = true; snapManager.setupDragPlaneFromPlane (workingPlane); + snapManager.reload2DCache(); + drawUtils.initializeFromDocument(); } -- cgit v1.2.3 From 24d1873302b2fffc25d254e15e8aa36f59eedb88 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 18 May 2012 01:36:05 -0700 Subject: fixed a switch documents bug where the layout was getting called before setting the container. Signed-off-by: Valerio Virgillito --- js/stage/stage.reel/stage.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'js/stage') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index cac99326..8da89fb9 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -593,6 +593,14 @@ exports.Stage = Montage.create(Component, { } }, + clearAllCanvas: { + value: function() { + this._drawingContext.clearRect(0, 0, this._drawingCanvas.width, this._drawingCanvas.height); + this.context.clearRect(0, 0, this.canvas.width, this.canvas.height); + this.layout.clearCanvas(); + } + }, + SelectTool: { value: function(cursor) { this._drawingCanvas.style.cursor = cursor; -- cgit v1.2.3 From 66edf78c7e5df11218ef733686965beab05c7c7d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 18 May 2012 14:01:00 -0700 Subject: fixing a scrolling issue when multiple documents are switched Signed-off-by: Valerio Virgillito --- js/stage/stage.reel/stage.js | 69 +++++++++----------------------------------- 1 file changed, 14 insertions(+), 55 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 8da89fb9..73d3aaf4 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -108,7 +108,6 @@ exports.Stage = Montage.create(Component, { // We will set this to false while moving objects to improve performance showSelectionBounds: { value: true }, - _documentRoot: { value: null }, _viewport: { value: null }, _documentOffsetLeft: { value: 0 }, _documentOffsetTop: { value: 0 }, @@ -121,11 +120,6 @@ exports.Stage = Montage.create(Component, { _maxHorizontalScroll: { value: 0 }, _maxVerticalScroll: { value: 0 }, - documentRoot: { - get: function () { return this._documentRoot; }, - set: function(value) { this._documentRoot = value; } - }, - viewport: { get: function () { return this._viewport; }, set: function(value) { this._viewport = value; } @@ -195,10 +189,7 @@ exports.Stage = Montage.create(Component, { set: function(value) { this._userPaddingLeft = value; this._documentOffsetLeft = -value; - if(!this._documentRoot) { - this._documentRoot = this.application.ninja.currentDocument.documentRoot; - } - this._documentRoot.ownerDocument.getElementsByTagName("HTML")[0].style["padding-left"] = -value + "px"; + this.application.ninja.currentDocument.documentRoot.ownerDocument.getElementsByTagName("HTML")[0].style["padding-left"] = -value + "px"; this.userContentLeft = this._documentOffsetLeft; this.updatedStage = true; } @@ -209,10 +200,7 @@ exports.Stage = Montage.create(Component, { set: function(value) { this._userPaddingTop = value; this._documentOffsetTop = -value; - if(!this._documentRoot) { - this._documentRoot = this.application.ninja.currentDocument.documentRoot; - } - this._documentRoot.ownerDocument.getElementsByTagName("HTML")[0].style["padding-top"] = -value + "px"; + this.application.ninja.currentDocument.documentRoot.ownerDocument.getElementsByTagName("HTML")[0].style["padding-top"] = -value + "px"; this.userContentTop = this._documentOffsetTop; this.updatedStage = true; } @@ -287,46 +275,17 @@ exports.Stage = Montage.create(Component, { this._canvas.width = this._layoutCanvas.width = this._drawingCanvas.width = this.element.offsetWidth - 11 ; this._canvas.height = this._layoutCanvas.height = this._drawingCanvas.height = this.element.offsetHeight - 11; - this._documentRoot = this.application.ninja.currentDocument.documentRoot; - - // Hardcode this value so that it does not fail for the new stage architecture - // TODO: Remove marker for old template: NINJA-STAGE-REWORK - if(this.application.ninja.currentDocument.documentRoot.id === "UserContent") { - this._viewport = this.application.ninja.currentDocument.documentRoot.parentNode; - - this.documentOffsetLeft = this._viewport.offsetLeft; - this.documentOffsetTop = this._viewport.offsetTop; - - // Center the stage - this.centerStage(); - - this._scrollLeft = this._iframeContainer.scrollLeft; - this._scrollTop = this._iframeContainer.scrollTop; - this.application.ninja.currentDocument.savedLeftScroll = this._iframeContainer.scrollLeft; - this.application.ninja.currentDocument.savedTopScroll = this._iframeContainer.scrollTop; - - this.userContentBorder = parseInt(this._documentRoot.elementModel.controller.getProperty(this._documentRoot, "border")); - - this._userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder; - this._userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder; - - this._iframeContainer.addEventListener("scroll", this, false); - this.application.ninja.currentDocument.iframe.style.opacity = 1.0; - } else { - this.userContentBorder = 0; - - this._scrollLeft = 0; - this._scrollTop = 0; - this._userContentLeft = this._documentOffsetLeft; - this._userContentTop = this._documentOffsetTop; - - this._maxHorizontalScroll = this._documentRoot.scrollWidth - this._canvas.width - 11; - this._maxVerticalScroll = this._documentRoot.scrollHeight - this._canvas.height - 11; - this.application.ninja.currentDocument.model.views.design.iframe.contentWindow.addEventListener("scroll", this, false); - } + this.userContentBorder = 0; + this._scrollLeft = 0; + this._scrollTop = 0; + this._userContentLeft = this._documentOffsetLeft; + this._userContentTop = this._documentOffsetTop; + this._maxHorizontalScroll = this.application.ninja.currentDocument.documentRoot.scrollWidth - this._canvas.width - 11; + this._maxVerticalScroll = this.application.ninja.currentDocument.documentRoot.scrollHeight - this._canvas.height - 11; + this.application.ninja.currentDocument.model.views.design.iframe.contentWindow.addEventListener("scroll", this, false); // TODO - We will need to modify this once we support switching between multiple documents this.application.ninja.toolsData.selectedToolInstance._configure(true); @@ -526,8 +485,8 @@ exports.Stage = Montage.create(Component, { // TODO - scroll events are not dependable. We may need to use a timer to simulate // scrollBegin and scrollEnd. For now, the Pan Tool will keep track of the stage's scroll values // on mouse down. -// this._maxHorizontalScroll = this._documentRoot.scrollWidth - this._canvas.width - 11; -// this._maxVerticalScroll = this._documentRoot.scrollHeight - this._canvas.height - 11; +// this._maxHorizontalScroll = this.application.ninja.currentDocument.documentRoot.scrollWidth - this._canvas.width - 11; +// this._maxVerticalScroll = this.application.ninja.currentDocument.documentRoot.scrollHeight - this._canvas.height - 11; } // Need to clear the snap cache and set up the drag plane @@ -566,8 +525,8 @@ exports.Stage = Montage.create(Component, { centerStage: { value: function() { if(this.application.ninja.currentDocument.documentRoot.id === "UserContent") { - this._iframeContainer.scrollLeft = this._documentOffsetLeft - (this._iframeContainer.offsetWidth - this._documentRoot.parentNode.offsetWidth)/2; - this._iframeContainer.scrollTop = this._documentOffsetTop - (this._iframeContainer.offsetHeight - this._documentRoot.parentNode.offsetHeight)/2; + this._iframeContainer.scrollLeft = this._documentOffsetLeft - (this._iframeContainer.offsetWidth - this.application.ninja.currentDocument.documentRoot.parentNode.offsetWidth)/2; + this._iframeContainer.scrollTop = this._documentOffsetTop - (this._iframeContainer.offsetHeight - this.application.ninja.currentDocument.documentRoot.parentNode.offsetHeight)/2; this._scrollLeft = this._iframeContainer.scrollLeft; this._scrollTop = this._iframeContainer.scrollTop; -- cgit v1.2.3