From 31d73bccdda6145c6bbb5c25f6db3e139fcb9e6c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 23 Feb 2012 01:49:33 -0800 Subject: Enabling outline on open documents and parsing doom on open to create models. Signed-off-by: Valerio Virgillito --- js/stage/layout.js | 71 ++++++++++++++++++++------------------------ js/stage/stage.reel/stage.js | 2 ++ 2 files changed, 34 insertions(+), 39 deletions(-) (limited to 'js/stage') diff --git a/js/stage/layout.js b/js/stage/layout.js index 56bb70bf..a94dd10c 100755 --- a/js/stage/layout.js +++ b/js/stage/layout.js @@ -53,36 +53,38 @@ exports.Layout = Montage.create(Component, { this.ctx.lineWidth = this.ctxLineWidth; this.ctx.fillStyle = this.drawFillColor; - this.eventManager.addEventListener("elementAdded", this, false); +// this.eventManager.addEventListener("elementAdded", this, false); this.eventManager.addEventListener("elementDeleted", this, false); this.eventManager.addEventListener("selectionChange", this, false); this.eventManager.addEventListener("deleteSelection", this, false); - -// this.addEventListener("change@stage.appModel.layoutView", this.handleLayoutView, false); - } }, - handleLayoutView: { + handleOpenDocument: { value: function() { - console.log(this.stage.appModel.layoutView); + // Initial elements to draw is the entire node list + this.elementsToDraw = this.application.ninja.documentController.activeDocument._liveNodeList; + + // Draw the elements and the 3d info + this.draw(); + this.draw3DInfo(false); } }, + // No need to keep track of the added elements. We now have a live node list of the dom handleElementAdded: { value: function(event) { - this.domTree.push(event.detail); - - this.draw(); - this.draw3DInfo(false); + // this.domTree.push(event.detail); + // this.draw(); + // this.draw3DInfo(false); } }, handleElementDeleted: { value: function(event) { - this.domTree.splice(this.domTree.indexOf(event.detail), 1); + //this.domTree.splice(this.domTree.indexOf(event.detail), 1); } }, @@ -96,8 +98,13 @@ exports.Layout = Montage.create(Component, { handleSelectionChange: { value: function(event) { - this.elementsToDraw = []; + // Make an array copy of the line node list which is not an array like object + this.domTree = Array.prototype.slice.call(this.application.ninja.documentController.activeDocument._liveNodeList, 0); + + // Clear the elements to draw + this.elementsToDraw.length = 0; + // Draw the non selected elements if(!event.detail.isDocument) { var tmp = event.detail.elements.map(function(element){ return element._element}); @@ -111,13 +118,15 @@ exports.Layout = Montage.create(Component, { this.draw(); // Not a reel yet :) this.draw3DInfo(false); - + // Clear the domTree copy + this.domTree.length = 0; } }, draw: { value: function() { this.clearCanvas(); + var els = this.elementsToDraw.length; for(var i = 0, el; i < els; i++){ this.drawTagOutline(this.elementsToDraw[i]); @@ -127,15 +136,15 @@ exports.Layout = Montage.create(Component, { draw3DInfo: { value: function(updatePlanes) { - if(updatePlanes) - { + if(updatePlanes) { drawUtils.updatePlanes(); } - if(this.stage.appModel.show3dGrid) - { + + if(this.stage.appModel.show3dGrid) { this.application.ninja.stage.stageDeps.snapManager.updateWorkingPlaneFromView(); drawUtils.drawWorkingPlane(); } + drawUtils.draw3DCompass(); } }, @@ -152,29 +161,22 @@ exports.Layout = Montage.create(Component, { if(!item) return; // TODO Bind the layoutview mode to the current document -// var mode = this.application.ninja.currentDocument.layoutMode; + // var mode = this.application.ninja.currentDocument.layoutMode; if(this.layoutView === "layoutOff") return; // Don't draw outlines for shapes. // TODO Use the element mediator/controller/model to see if its a shape - /* - if (utilsModule.utils.isElementAShape(item)) - { - return; - } - */ + // if (utilsModule.utils.isElementAShape(item)) return; - /** - * New Drawing layout code using 3D calculations - */ + + // draw the layout viewUtils.setViewportObj( item ); var bounds3D = viewUtils.getElementViewBounds3D( item ); var tmpMat = viewUtils.getLocalToGlobalMatrix( item ); var zoomFactor = 1; - if (this.stage._viewport.style && this.stage._viewport.style.zoom) - { + if (this.stage._viewport.style && this.stage._viewport.style.zoom) { zoomFactor = Number(this.stage._viewport.style.zoom); } @@ -185,8 +187,7 @@ exports.Layout = Montage.create(Component, { var localPt = bounds3D[j]; var tmpPt = viewUtils.localToGlobal2(localPt, tmpMat); - if(zoomFactor !== 1) - { + if(zoomFactor !== 1) { tmpPt = vecUtils.vecScale(3, tmpPt, zoomFactor); tmpPt[0] += sSL*(zoomFactor - 1); @@ -255,14 +256,6 @@ exports.Layout = Montage.create(Component, { value: function(elements) { this.clearCanvas(); this.WalkDOM(this.application.ninja.currentDocument.documentRoot, elements); - - //drawUtils.updatePlanes(); - - if(this.application.ninja.currentDocument.draw3DGrid) { - //drawUtils.drawWorkingPlane(); - } - - //drawUtils.draw3DCompass(); } }, diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 44e14827..6536a45d 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -258,6 +258,8 @@ exports.Stage = Montage.create(Component, { this.application.ninja.toolsData.selectedToolInstance._configure(true); this.addEventListener("change@appModel.show3dGrid", this, false); + + this.layout.handleOpenDocument(); } }, -- cgit v1.2.3 From 7283884c39df537694b21419a3ea9e3ca7793b4b Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 23 Feb 2012 13:43:35 -0800 Subject: switch html document - re-initialize draw-utils and snap-manager on opening a document and while switching documents Signed-off-by: Ananya Sen --- js/stage/stage-deps.js | 38 ++++++++++++++++++++-------------- js/stage/stage-view.reel/stage-view.js | 14 +++++-------- js/stage/stage.reel/stage.js | 4 ++++ 3 files changed, 31 insertions(+), 25 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js index d46e2b81..316a5bb0 100755 --- a/js/stage/stage-deps.js +++ b/js/stage/stage-deps.js @@ -23,6 +23,10 @@ exports.StageDeps = Montage.create(Component, { value: snapManager }, + drawUtils: { + value: drawUtils + }, + currentStage: { value: null }, @@ -119,29 +123,31 @@ exports.StageDeps = Montage.create(Component, { }, handleOpenDocument: { - value: function() { + value: function() { + + workingPlane = Vector.create( [0,0,1,0] ); - workingPlane = Vector.create( [0,0,1,0] ); + snapManager.setCurrentStage(this.currentStage); - snapManager.setCurrentStage(this.currentStage); + viewUtils.setCurrentDocument(this.currentDocument); + viewUtils.setRootElement(this.currentStage.parentNode); + viewUtils.setStageElement(this.currentStage); - viewUtils.setCurrentDocument(this.currentDocument); - viewUtils.setRootElement(this.currentStage.parentNode); - viewUtils.setStageElement(this.currentStage); + drawUtils.viewUtils = viewUtils; + drawUtils.snapManager = snapManager; + drawUtils.ElementPlanes = ElementPlanes; - drawUtils.setDrawingSurfaceElement(this.stage.canvas); - drawUtils.setSourceSpaceElement( this.currentStage ); - drawUtils.setWorkingPlane( workingPlane ); - drawUtils.viewUtils = viewUtils; - drawUtils.snapManager = snapManager; - drawUtils.ElementPlanes = ElementPlanes; + snapManager._isCacheInvalid=true; - snapManager.setupDragPlaneFromPlane ( workingPlane ); + snapManager.setupDragPlaneFromPlane ( workingPlane ); - DrawingToolBase.stage = this.currentStage; - DrawingToolBase.stageComponent = this.stage; + DrawingToolBase.stage = this.currentStage; + DrawingToolBase.stageComponent = this.stage; + 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 dc9980f0..0b688c75 100755 --- a/js/stage/stage-view.reel/stage-view.js +++ b/js/stage/stage-view.reel/stage-view.js @@ -122,10 +122,6 @@ exports.StageView = Montage.create(Component, { switchDocument:{ value: function(doc){ - //save editor cursor position - if(!!this.application.ninja.documentController.activeDocument && !!this.application.ninja.documentController.activeDocument.editor){ - this.application.ninja.documentController.activeDocument.hline = this.application.ninja.documentController.activeDocument.editor.getCursor(true); - } this.application.ninja.documentController._hideCurrentDocument(); this.application.ninja.documentController.activeDocument = doc; @@ -133,17 +129,17 @@ exports.StageView = Montage.create(Component, { this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe this.application.ninja.documentController._showCurrentDocument(); - var documentController = this.application.ninja.documentController; - - //restore editor cursor position + //focus current document if(!!this.application.ninja.documentController.activeDocument && !!this.application.ninja.documentController.activeDocument.editor){ - this.application.ninja.documentController.activeDocument.editor.setCursor(this.application.ninja.documentController.activeDocument.hline); document.getElementById("codeMirror_"+this.application.ninja.documentController.activeDocument.uuid).getElementsByClassName("CodeMirror")[0].focus(); } if(this.application.ninja.documentController.activeDocument.currentView === "design") { this.application.ninja.stage._scrollFlag = true; // TODO HACK to prevent type error on Hide/Show Iframe - this.application.ninja.currentDocument = this.application.ninja.documentController.activeDocument; + this.application.ninja.currentDocument = this.application.ninja.documentController.activeDocument; + + this.application.ninja.stage.snapManager._isCacheInvalid=true; + this.application.ninja.stage.drawUtils.initializeFromDocument(); // TODO dispatch event here // appDelegateModule.MyAppDelegate.onSetActiveDocument(); diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 44e14827..6bb626c2 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -37,6 +37,10 @@ exports.Stage = Montage.create(Component, { get: function() { return this.stageDeps.snapManager; } }, + drawUtils: { + get: function() { return this.stageDeps.drawUtils; } + }, + resizeCanvases: { get: function() { return this._resizeCanvases; -- cgit v1.2.3 From 6e66f411ba02eaaeb33471115345ecf3c7ce4ce9 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 23 Feb 2012 17:55:59 -0800 Subject: refresh draw-utils, snap-manager, view-utils for html document stitching Signed-off-by: Ananya Sen --- js/stage/stage-deps.js | 56 +++++++++++++++++++++++++--------- js/stage/stage-view.reel/stage-view.js | 9 +++--- js/stage/stage.reel/stage.js | 10 +++--- 3 files changed, 50 insertions(+), 25 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js index 316a5bb0..16f2c652 100755 --- a/js/stage/stage-deps.js +++ b/js/stage/stage-deps.js @@ -123,30 +123,56 @@ exports.StageDeps = Montage.create(Component, { }, handleOpenDocument: { - value: function() { + value: function() { - workingPlane = Vector.create( [0,0,1,0] ); + workingPlane = Vector.create( [0,0,1,0] ); - snapManager.setCurrentStage(this.currentStage); + snapManager.setCurrentStage(this.currentStage); - viewUtils.setCurrentDocument(this.currentDocument); - viewUtils.setRootElement(this.currentStage.parentNode); - viewUtils.setStageElement(this.currentStage); + viewUtils.setCurrentDocument(this.currentDocument); + viewUtils.setRootElement(this.currentStage.parentNode); + viewUtils.setStageElement(this.currentStage); - drawUtils.viewUtils = viewUtils; - drawUtils.snapManager = snapManager; - drawUtils.ElementPlanes = ElementPlanes; + drawUtils.viewUtils = viewUtils; + drawUtils.snapManager = snapManager; + drawUtils.ElementPlanes = ElementPlanes; - snapManager._isCacheInvalid=true; + snapManager._isCacheInvalid=true; - snapManager.setupDragPlaneFromPlane ( workingPlane ); + snapManager.setupDragPlaneFromPlane ( workingPlane ); - DrawingToolBase.stage = this.currentStage; - DrawingToolBase.stageComponent = this.stage; + DrawingToolBase.stage = this.currentStage; + DrawingToolBase.stageComponent = this.stage; - drawUtils.initializeFromDocument(); - } + drawUtils.initializeFromDocument(); + } + }, + + reinitializeForSwitchDocument: { + value: function() { + + workingPlane = Vector.create( [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; + + drawUtils.initializeFromDocument(); } + } diff --git a/js/stage/stage-view.reel/stage-view.js b/js/stage/stage-view.reel/stage-view.js index 0b688c75..ab02661d 100755 --- a/js/stage/stage-view.reel/stage-view.js +++ b/js/stage/stage-view.reel/stage-view.js @@ -118,8 +118,7 @@ exports.StageView = Montage.create(Component, { } }, - - + //called for switching between html documents switchDocument:{ value: function(doc){ this.application.ninja.documentController._hideCurrentDocument(); @@ -138,8 +137,10 @@ exports.StageView = Montage.create(Component, { this.application.ninja.stage._scrollFlag = true; // TODO HACK to prevent type error on Hide/Show Iframe this.application.ninja.currentDocument = this.application.ninja.documentController.activeDocument; - this.application.ninja.stage.snapManager._isCacheInvalid=true; - this.application.ninja.stage.drawUtils.initializeFromDocument(); + //reinitialize draw-util, snapmanager and view-util + this.application.ninja.stage.stageDeps.reinitializeForSwitchDocument(); + + //this.application.ninja.stage.layout.reinitializeForSwitchDocument(); // TODO dispatch event here // appDelegateModule.MyAppDelegate.onSetActiveDocument(); diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 755c7ff1..9784f14d 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -148,12 +148,12 @@ exports.Stage = Montage.create(Component, { userContentLeft: { get: function() { return this._userContentLeft; }, - set: function(value) { this._userContentLeft = value; } + set: function(value) { this._userContentLeft = value;} }, userContentTop: { get: function() { return this._userContentTop; }, - set: function(value) { this._userContentTop = value; } + set: function(value) { this._userContentTop = value;} }, userContentBorder: { @@ -439,12 +439,11 @@ exports.Stage = Montage.create(Component, { */ handleScroll: { value: function() { - this._scrollLeft = this._iframeContainer.scrollLeft; this._scrollTop = this._iframeContainer.scrollTop; - this._userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder; - this._userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder; + this.userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder; + this.userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder; // Need to clear the snap cache and set up the drag plane //snapManager.setupDragPlaneFromPlane( workingPlane ); @@ -452,7 +451,6 @@ exports.Stage = Montage.create(Component, { this.needsDraw = true; this.layout.draw(); - //this._toolsList.action("DrawHandles"); } -- cgit v1.2.3 From 85d59d57ea556b114c5cad9b2ec67ccc27119380 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 24 Feb 2012 12:05:16 -0800 Subject: - added flag for timeline to identify new file flow - added switchDocument event for timeline Signed-off-by: Ananya Sen --- js/stage/stage-view.reel/stage-view.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'js/stage') diff --git a/js/stage/stage-view.reel/stage-view.js b/js/stage/stage-view.reel/stage-view.js index ab02661d..91047e51 100755 --- a/js/stage/stage-view.reel/stage-view.js +++ b/js/stage/stage-view.reel/stage-view.js @@ -146,6 +146,8 @@ exports.StageView = Montage.create(Component, { // appDelegateModule.MyAppDelegate.onSetActiveDocument(); } + NJevent("switchDocument"); + } }, -- cgit v1.2.3 From 818ec3b66d4394d80fcffbfcee82b40fe1477319 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 24 Feb 2012 11:56:42 -0800 Subject: Distinguish between border top/right/bottom/left colors. Also, fall back to snapping routine when selecting only if the active tool allows snapping. Signed-off-by: Nivesh Rajbhandari --- js/stage/stage.reel/stage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/stage') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 641ac247..922abc33 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -519,7 +519,7 @@ exports.Stage = Montage.create(Component, { elt = this.application.ninja.currentDocument.GetElementFromPoint(point.x + this.scrollLeft,point.y + this.scrollTop); // workaround Chrome 3d bug - if(this.application.ninja.currentDocument.inExclusion(elt) !== -1) + if(this.application.ninja.toolsData.selectedToolInstance._canSnap && this.application.ninja.currentDocument.inExclusion(elt) !== -1) { return this._getElementUsingSnapping(point); } else { -- cgit v1.2.3 From b056b4bef5982466d80d72e5cbb31e63087990e1 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 24 Feb 2012 15:30:55 -0800 Subject: - added closeDocument event for timeline - minor bug fixes Signed-off-by: Ananya Sen --- js/stage/layout.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'js/stage') diff --git a/js/stage/layout.js b/js/stage/layout.js index a94dd10c..de4c67c1 100755 --- a/js/stage/layout.js +++ b/js/stage/layout.js @@ -98,6 +98,11 @@ exports.Layout = Montage.create(Component, { handleSelectionChange: { value: function(event) { + + if(this.application.ninja.documentController.activeDocument === null){ + return; + } + // Make an array copy of the line node list which is not an array like object this.domTree = Array.prototype.slice.call(this.application.ninja.documentController.activeDocument._liveNodeList, 0); -- cgit v1.2.3