From 2154ace6bdc2abe55fae353849d3beb64b8ada25 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 24 May 2012 16:14:40 -0700 Subject: Don't loop through layout drawing code if layout view is off. Signed-off-by: Nivesh Rajbhandari --- js/stage/layout.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'js/stage') diff --git a/js/stage/layout.js b/js/stage/layout.js index 460c8b4a..7b4ccc17 100755 --- a/js/stage/layout.js +++ b/js/stage/layout.js @@ -121,6 +121,10 @@ exports.Layout = Montage.create(Component, { value: function() { this.clearCanvas(); + // TODO Bind the layoutview mode to the current document + // var mode = this.application.ninja.currentDocument.layoutMode; + if(this.layoutView === "layoutOff") return; + var els = this.elementsToDraw.length; for(var i = 0, el; i < els; i++){ this.drawTagOutline(this.elementsToDraw[i]); @@ -154,11 +158,6 @@ exports.Layout = Montage.create(Component, { if(!item || !this.application.ninja.selectionController.isNodeTraversable(item)) return; - // TODO Bind the layoutview mode to the current document - // 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; -- cgit v1.2.3 From 4c3aac5eabd93052b1554a03d78235215bb49db4 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 29 May 2012 00:34:40 -0700 Subject: document bindings phase 1 - using array controller to bind the current document to all ninja components - removed open document event - removed references to the document controller Signed-off-by: Valerio Virgillito --- js/stage/layout.js | 37 +++++++++++++++++++++++++------------ js/stage/stage-deps.js | 40 ++++++++++++++++++++++++++++------------ js/stage/stage.reel/stage.html | 18 +++++++++--------- js/stage/stage.reel/stage.js | 37 +++++++++++++++++++++++++------------ 4 files changed, 87 insertions(+), 45 deletions(-) (limited to 'js/stage') diff --git a/js/stage/layout.js b/js/stage/layout.js index 460c8b4a..8b66150d 100755 --- a/js/stage/layout.js +++ b/js/stage/layout.js @@ -23,6 +23,28 @@ exports.Layout = Montage.create(Component, { drawFillColor: { value: 'rgba(255,255,255,1)' }, ctxLineWidth: { value: 0.2 }, + _currentDocument: { + value : null, + enumerable : false + }, + + currentDocument : { + get : function() { + return this._currentDocument; + }, + set : function(value) { + if (value === this._currentDocument || value.getProperty("currentView") !== "design") { + return; + } + + this._currentDocument = value; + + if(this._currentDocument) { + this.elementsToDraw = this._currentDocument.model.documentRoot.childNodes; + } + } + }, + _layoutView: { value: "layoutAll" }, @@ -58,15 +80,6 @@ exports.Layout = Montage.create(Component, { } }, - handleOpenDocument: { - value: function() { - // Initial elements to draw are the childrens of the root element - if(this.application.ninja.documentController.activeDocument.currentView === "design") { - this.elementsToDraw = this.application.ninja.documentController.activeDocument.model.documentRoot.childNodes; - } - } - }, - // Redraw stage only once after all deletion is completed handleElementsRemoved: { value: function(event) { @@ -79,11 +92,11 @@ exports.Layout = Montage.create(Component, { value: function(event) { var containerIndex; - if(this.application.ninja.documentController.activeDocument === null){ + if(this.currentDocument === null){ return; } - if(this.application.ninja.documentController.activeDocument.currentView === "design"){ + if(this.currentDocument.currentView === "design"){ // Make an array copy of the line node list which is not an array like object this.domTree = this.application.ninja.currentDocument.model.views.design.getLiveNodeList(true); // Index of the current container @@ -219,7 +232,7 @@ exports.Layout = Montage.create(Component, { if(this.layoutView === "layoutAll") { this.ctx.strokeStyle = 'rgba(0,0,0,1)'; // Black Stroke this.ctx.strokeRect(bounds3D[0][0]+5.5, bounds3D[0][1]-15.5, 70, 11); - this.ctx.fillStyle = 'rgba(255,255,255,1)' // White Fill + this.ctx.fillStyle = 'rgba(255,255,255,1)'; // White Fill this.ctx.fillRect(bounds3D[0][0]+6, bounds3D[0][1]-15, 69, 10); this.ctx.fillStyle = 'rgba(0,0,0,1)'; diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js index 896d4a5b..756844fd 100755 --- a/js/stage/stage-deps.js +++ b/js/stage/stage-deps.js @@ -14,6 +14,34 @@ var Montage = require("montage/core/core").Montage, VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; exports.StageDeps = Montage.create(Component, { + + _currentDocument: { + value : null, + enumerable : false + }, + + currentDocument : { + get : function() { + return this._currentDocument; + }, + set : function(value) { + if (value === this._currentDocument || value.getProperty("currentView") !== "design") { + return; + } + + this._currentDocument = value; + + if(this._currentDocument) { + workingPlane = [0,0,1,0]; + + snapManager._isCacheInvalid = true; + snapManager.setupDragPlaneFromPlane (workingPlane); + + drawUtils.initializeFromDocument(); + } + } + }, + viewUtils: { value: viewUtils }, @@ -59,18 +87,6 @@ exports.StageDeps = Montage.create(Component, { } }, - handleOpenDocument: { - value: function() { - - workingPlane = [0,0,1,0]; - - snapManager._isCacheInvalid = true; - snapManager.setupDragPlaneFromPlane (workingPlane); - - drawUtils.initializeFromDocument(); - } - }, - handleSwitchDocument: { value: function(){ workingPlane = [0,0,1,0]; diff --git a/js/stage/stage.reel/stage.html b/js/stage/stage.reel/stage.html index 30c3d231..89b674ab 100755 --- a/js/stage/stage.reel/stage.html +++ b/js/stage/stage.reel/stage.html @@ -18,25 +18,25 @@ } }, - "StageDeps1": { + "stageDeps": { "prototype": "js/stage/stage-deps", "properties": { "stage": {"@": "owner"} + }, + "bindings": { + "currentDocument": {"<-": "@owner.currentDocument"} } }, - "layout1": { + "layout": { "prototype": "js/stage/layout", "properties": { "canvas": {"#": "layoutCanvas"}, "stage": {"@": "owner"} }, "bindings": { - "layoutView": { - "boundObject": {"@": "owner" }, - "boundObjectPropertyPath": "appModel.layoutView", - "oneway": true - } + "layoutView": {"<-": "@owner.appModel.layoutView"}, + "currentDocument": {"<-": "@owner.currentDocument"} } }, @@ -59,8 +59,8 @@ "_layoutCanvas": {"#": "layoutCanvas"}, "_canvas": {"#": "stageCanvas"}, "_drawingCanvas": {"#": "drawingCanvas"}, - "stageDeps": {"@": "StageDeps1"}, - "layout": {"@": "layout1"}, + "stageDeps": {"@": "stageDeps"}, + "layout": {"@": "layout"}, "stageView": {"@": "stageView"}, "textTool": {"@": "textTool"}, "focusManager": {"@": "focusManager"} diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index c7afb95c..e00d2b54 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -155,25 +155,41 @@ exports.Stage = Montage.create(Component, { set: function(value) { this._userContentBorder = value; } }, - _activeDocument : { + _currentDocument: { value : null, enumerable : false }, - activeDocument : { + currentDocument : { get : function() { - return this._activeDocument; + return this._currentDocument; }, - set : function(document) { - ///// If the document is null set default stylesheets to null + set : function(value) { + // TODO: WRONG! Fails when going from design to code view + if (value === this._currentDocument || value.getProperty("currentView") !== "design") { + console.log("Stage - current document not set since the same value of " + this._currentDocument + " and value " + value); + return; + } - if(!document) { - return false; + if(!value) { + // Show the rulers + this.showRulers(); + // Show the canvas + this.hideCanvas(false); } - ///// setting document via binding - this._activeDocument = document; + //console.log("Stage - set current document with value of " + value); + this._currentDocument = value; + + if(this._currentDocument.currentView === "design") { + this.clearAllCanvas(); + this.initWithDocument(false); + } + if(!this._currentDocument) { + this.hideRulers(); + this.hideCanvas(true); + } }, enumerable : false }, @@ -295,9 +311,6 @@ exports.Stage = Montage.create(Component, { this._scrollLeft = 0; this._scrollTop = 0; - this.stageDeps.handleOpenDocument(); - this.layout.handleOpenDocument(); - if(designView._template) { var initialLeft = parseInt((this.canvas.width - designView._template.size.width)/2); var initialTop = parseInt((this.canvas.height - designView._template.size.height)/2); -- cgit v1.2.3 From 2fd6db5f46208a5aa8fa58d090f795e5b7eb99bb Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 29 May 2012 10:35:06 -0700 Subject: Sped up user-interaction by moving grid drawing into its own canvas so the layout code doesn't have to be run when modifying selected elements. Signed-off-by: Nivesh Rajbhandari --- js/stage/stage-deps.js | 2 -- js/stage/stage.reel/stage.html | 2 ++ js/stage/stage.reel/stage.js | 28 +++++++++++++++++++++++----- 3 files changed, 25 insertions(+), 7 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js index 896d4a5b..2469ba79 100755 --- a/js/stage/stage-deps.js +++ b/js/stage/stage-deps.js @@ -37,8 +37,6 @@ exports.StageDeps = Montage.create(Component, { window.MathUtils = MathUtilsClass; window.VecUtils = VecUtils; - snapManager.drawingCanvas = this.stage.drawingCanvas; - // Setup the listeners for the draw-util and snapmanager when removing elements // TODO Revisit when supporting multiple documents drawUtils.initialize(); diff --git a/js/stage/stage.reel/stage.html b/js/stage/stage.reel/stage.html index 30c3d231..a819fc79 100755 --- a/js/stage/stage.reel/stage.html +++ b/js/stage/stage.reel/stage.html @@ -57,6 +57,7 @@ "element": {"#": "stageAndScenesContainer"}, "_iframeContainer": {"#": "iframeContainer"}, "_layoutCanvas": {"#": "layoutCanvas"}, + "_gridCanvas": {"#": "gridCanvas"}, "_canvas": {"#": "stageCanvas"}, "_drawingCanvas": {"#": "drawingCanvas"}, "stageDeps": {"@": "StageDeps1"}, @@ -83,6 +84,7 @@
+ diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index c7afb95c..d8684739 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -97,6 +97,12 @@ exports.Stage = Montage.create(Component, { _layoutCanvas: { value: null }, layoutCanvas: { get: function() { return this._layoutCanvas; } }, + _gridCanvas: { value: null }, + gridCanvas: { get: function() { return this._gridCanvas; } }, + + _gridContext: { value: null }, + gridContext: { get: function() { return this._gridContext; } }, + _drawingCanvas: { value: null }, drawingCanvas: { get: function() { return this._drawingCanvas; } }, @@ -207,11 +213,14 @@ exports.Stage = Montage.create(Component, { value: function() { if(this.resizeCanvases) { // TODO GET THE SCROLL SIZE FROM THE CSS -- 11 px - 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;// - 26 - 26; + this._canvas.width = this._layoutCanvas.width = this._drawingCanvas.width = this._gridCanvas.width = this.element.offsetWidth - 11 ; + this._canvas.height = this._layoutCanvas.height = this._drawingCanvas.height = this._gridCanvas.height = this.element.offsetHeight - 11;// - 26 - 26; // Hack for now until a full component this.layout.draw(); + if(this.application.ninja.currentDocument) { + this.layout.draw3DInfo(true); + } } else if(this.updatedStage) { this.layout.draw(); this.layout.draw3DInfo(true); @@ -231,6 +240,7 @@ exports.Stage = Montage.create(Component, { this._context = this._canvas.getContext("2d"); this._drawingContext= this._drawingCanvas.getContext("2d"); + this._gridContext= this._gridCanvas.getContext("2d"); // Setup event listeners this._drawingCanvas.addEventListener("mousedown", this, false); @@ -276,8 +286,8 @@ exports.Stage = Montage.create(Component, { this.hideCanvas(false); // Recalculate the canvas sizes because of splitter resizing - 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._canvas.width = this._layoutCanvas.width = this._drawingCanvas.width = this._gridCanvas.width = this.element.offsetWidth - 11 ; + this._canvas.height = this._layoutCanvas.height = this._drawingCanvas.height = this._gridCanvas.height = this.element.offsetHeight - 11; designView.iframe.contentWindow.addEventListener("scroll", this, false); @@ -519,11 +529,12 @@ exports.Stage = Montage.create(Component, { this._canvas.style.visibility = "hidden"; this._layoutCanvas.style.visibility = "hidden"; this._drawingCanvas.style.visibility = "hidden"; + this._gridCanvas.style.visibility = "hidden"; } else { this._canvas.style.visibility = "visible"; this._layoutCanvas.style.visibility = "visible"; this._drawingCanvas.style.visibility = "visible"; - + this._gridCanvas.style.visibility = "visible"; } } }, @@ -560,10 +571,17 @@ exports.Stage = Montage.create(Component, { } }, + clearGridCanvas: { + value: function() { + this._gridContext.clearRect(0, 0, this._gridCanvas.width, this._gridCanvas.height); + } + }, + 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._gridContext.clearRect(0, 0, this._gridCanvas.width, this._gridCanvas.height); this.layout.clearCanvas(); } }, -- cgit v1.2.3 From 4fa08fe2ce439a5f5c248c568f72d3828ee11b36 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 29 May 2012 11:43:55 -0700 Subject: fix for the document tab close button and rulers on initial document Signed-off-by: Valerio Virgillito --- js/stage/stage.reel/stage.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index e00d2b54..a6e7c24f 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -171,10 +171,8 @@ exports.Stage = Montage.create(Component, { return; } - if(!value) { - // Show the rulers + if(!this._currentDocument) { this.showRulers(); - // Show the canvas this.hideCanvas(false); } @@ -186,7 +184,7 @@ exports.Stage = Montage.create(Component, { this.initWithDocument(false); } - if(!this._currentDocument) { + if(!value) { this.hideRulers(); this.hideCanvas(true); } -- cgit v1.2.3 From 961830a1ab076db70577df735f43cae5e8559e83 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 29 May 2012 14:55:19 -0700 Subject: Moving layout and stageDeps' handleOpenDocument into stage. Signed-off-by: Nivesh Rajbhandari --- js/stage/layout.js | 3 +-- js/stage/stage-deps.js | 24 +----------------------- js/stage/stage.reel/stage.js | 15 +++++++++++++-- 3 files changed, 15 insertions(+), 27 deletions(-) (limited to 'js/stage') diff --git a/js/stage/layout.js b/js/stage/layout.js index 7b4ccc17..4eecd4d5 100755 --- a/js/stage/layout.js +++ b/js/stage/layout.js @@ -140,9 +140,8 @@ exports.Layout = Montage.create(Component, { if(this.stage.appModel.show3dGrid) { this.application.ninja.stage.stageDeps.snapManager.updateWorkingPlaneFromView(); - drawUtils.drawWorkingPlane(); } - + drawUtils.drawWorkingPlane(); drawUtils.draw3DCompass(); } }, diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js index 2469ba79..b45315b7 100755 --- a/js/stage/stage-deps.js +++ b/js/stage/stage-deps.js @@ -55,28 +55,6 @@ exports.StageDeps = Montage.create(Component, { drawUtils.snapManager = snapManager; drawUtils.ElementPlanes = ElementPlanes; } - }, - - handleOpenDocument: { - value: function() { - - workingPlane = [0,0,1,0]; - - snapManager._isCacheInvalid = true; - snapManager.setupDragPlaneFromPlane (workingPlane); - - drawUtils.initializeFromDocument(); - } - }, - - handleSwitchDocument: { - value: function(){ - workingPlane = [0,0,1,0]; - - snapManager._isCacheInvalid = true; - snapManager.setupDragPlaneFromPlane (workingPlane); - - drawUtils.initializeFromDocument(); - } } + }); \ No newline at end of file diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index d8684739..44d6eadb 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -305,8 +305,7 @@ exports.Stage = Montage.create(Component, { this._scrollLeft = 0; this._scrollTop = 0; - this.stageDeps.handleOpenDocument(); - this.layout.handleOpenDocument(); + this.initialize3DOnOpenDocument(); if(designView._template) { var initialLeft = parseInt((this.canvas.width - designView._template.size.width)/2); @@ -1079,6 +1078,18 @@ exports.Stage = Montage.create(Component, { this.application.ninja.toolsSplitter.restore(); this.application.ninja.optionsSplitter.restore(); } + }, + + initialize3DOnOpenDocument: { + value: function() { + + workingPlane = [0,0,1,0]; + + this.snapManager._isCacheInvalid = true; + this.snapManager.setupDragPlaneFromPlane (workingPlane); + + this.drawUtils.initializeFromDocument(); + } } }); \ No newline at end of file -- cgit v1.2.3 From 820005437e7270e72b865a3436d7148e1dd19900 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 29 May 2012 15:42:24 -0700 Subject: Fixed bug with scrolling too much when moving objects in negative space. Signed-off-by: Nivesh Rajbhandari --- js/stage/stage.reel/stage.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 44d6eadb..7025c692 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -193,7 +193,7 @@ exports.Stage = Montage.create(Component, { this._userPaddingLeft = value; this._documentOffsetLeft = -value; this.application.ninja.currentDocument.model.documentRoot.ownerDocument.getElementsByTagName("HTML")[0].style["padding-left"] = -value + "px"; - this.userContentLeft = this._documentOffsetLeft; + this.userContentLeft = this._documentOffsetLeft - this._scrollLeft; this.updatedStage = true; } }, @@ -204,7 +204,7 @@ exports.Stage = Montage.create(Component, { this._userPaddingTop = value; this._documentOffsetTop = -value; this.application.ninja.currentDocument.model.documentRoot.ownerDocument.getElementsByTagName("HTML")[0].style["padding-top"] = -value + "px"; - this.userContentTop = this._documentOffsetTop; + this.userContentTop = this._documentOffsetTop - this._scrollTop; this.updatedStage = true; } }, -- cgit v1.2.3 From d8840eda0d3b3e31fb5a72306fe66608f4f99c2b Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 29 May 2012 23:52:59 -0700 Subject: fixing the menu bindings and some cleanup of the stage Signed-off-by: Valerio Virgillito --- js/stage/stage.reel/stage.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index a6e7c24f..82c4d652 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -156,8 +156,7 @@ exports.Stage = Montage.create(Component, { }, _currentDocument: { - value : null, - enumerable : false + value : null }, currentDocument : { @@ -176,7 +175,6 @@ exports.Stage = Montage.create(Component, { this.hideCanvas(false); } - //console.log("Stage - set current document with value of " + value); this._currentDocument = value; if(this._currentDocument.currentView === "design") { @@ -188,8 +186,7 @@ exports.Stage = Montage.create(Component, { this.hideRulers(); this.hideCanvas(true); } - }, - enumerable : false + } }, _userPaddingLeft: { value: 0 }, @@ -287,8 +284,6 @@ exports.Stage = Montage.create(Component, { value: function(didSwitch) { var designView = this.application.ninja.currentDocument.model.views.design; - this.hideCanvas(false); - // Recalculate the canvas sizes because of splitter resizing 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; -- cgit v1.2.3 From 31b094ee21102f99a4021d505bc3a28527c9e23d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 30 May 2012 01:33:20 -0700 Subject: Fixing the close document. Signed-off-by: Valerio Virgillito --- js/stage/layout.js | 6 ++++-- js/stage/stage-deps.js | 7 +++++-- js/stage/stage.reel/stage.js | 14 +++++--------- 3 files changed, 14 insertions(+), 13 deletions(-) (limited to 'js/stage') diff --git a/js/stage/layout.js b/js/stage/layout.js index 8b66150d..284968e4 100755 --- a/js/stage/layout.js +++ b/js/stage/layout.js @@ -33,13 +33,15 @@ exports.Layout = Montage.create(Component, { return this._currentDocument; }, set : function(value) { - if (value === this._currentDocument || value.getProperty("currentView") !== "design") { + if (value === this._currentDocument) {// || value.getProperty("currentView") !== "design") { return; } this._currentDocument = value; - if(this._currentDocument) { + if(!value) { + + } else if(this._currentDocument.currentView === "design") { this.elementsToDraw = this._currentDocument.model.documentRoot.childNodes; } } diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js index 756844fd..f27254f9 100755 --- a/js/stage/stage-deps.js +++ b/js/stage/stage-deps.js @@ -25,13 +25,15 @@ exports.StageDeps = Montage.create(Component, { return this._currentDocument; }, set : function(value) { - if (value === this._currentDocument || value.getProperty("currentView") !== "design") { + if (value === this._currentDocument) {// || value.getProperty("currentView") !== "design") { return; } this._currentDocument = value; - if(this._currentDocument) { + if(!value) { + + } else if(this._currentDocument.currentView === "design") { workingPlane = [0,0,1,0]; snapManager._isCacheInvalid = true; @@ -39,6 +41,7 @@ exports.StageDeps = Montage.create(Component, { drawUtils.initializeFromDocument(); } + } }, diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 82c4d652..da5a4f76 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -164,27 +164,23 @@ exports.Stage = Montage.create(Component, { return this._currentDocument; }, set : function(value) { - // TODO: WRONG! Fails when going from design to code view - if (value === this._currentDocument || value.getProperty("currentView") !== "design") { - console.log("Stage - current document not set since the same value of " + this._currentDocument + " and value " + value); + if (value === this._currentDocument) { return; } - if(!this._currentDocument) { + if(!this._currentDocument && value.currentView === "design") { this.showRulers(); this.hideCanvas(false); } this._currentDocument = value; - if(this._currentDocument.currentView === "design") { - this.clearAllCanvas(); - this.initWithDocument(false); - } - if(!value) { this.hideRulers(); this.hideCanvas(true); + } else if(this._currentDocument.currentView === "design") { + this.clearAllCanvas(); + this.initWithDocument(false); } } }, -- cgit v1.2.3 From d4f2df2a7b3ec79fc54e17f09195dbc37331f051 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 30 May 2012 09:55:33 -0700 Subject: Fix for snap-align not working correctly after resizing the stage. Signed-off-by: Nivesh Rajbhandari --- js/stage/layout.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/stage') diff --git a/js/stage/layout.js b/js/stage/layout.js index 4eecd4d5..7b6e47e7 100755 --- a/js/stage/layout.js +++ b/js/stage/layout.js @@ -136,6 +136,7 @@ exports.Layout = Montage.create(Component, { value: function(updatePlanes) { if(updatePlanes) { drawUtils.updatePlanes(); + this.application.ninja.stage.stageDeps.snapManager._isCacheInvalid = true; } if(this.stage.appModel.show3dGrid) { -- cgit v1.2.3 From 169df50391a35e9c7865033dd089a37324bcfa47 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 30 May 2012 11:30:17 -0700 Subject: remove current document binding from the stage deps Signed-off-by: Valerio Virgillito --- js/stage/stage-deps.js | 30 ------------------------------ js/stage/stage.reel/stage.html | 3 --- 2 files changed, 33 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js index 709c0201..762c2529 100755 --- a/js/stage/stage-deps.js +++ b/js/stage/stage-deps.js @@ -15,36 +15,6 @@ var Montage = require("montage/core/core").Montage, exports.StageDeps = Montage.create(Component, { - _currentDocument: { - value : null, - enumerable : false - }, - - currentDocument : { - get : function() { - return this._currentDocument; - }, - set : function(value) { - if (value === this._currentDocument) { - return; - } - - this._currentDocument = value; - - if(!value) { - - } else if(this._currentDocument.currentView === "design") { - workingPlane = [0,0,1,0]; - - snapManager._isCacheInvalid = true; - snapManager.setupDragPlaneFromPlane (workingPlane); - - drawUtils.initializeFromDocument(); - } - - } - }, - viewUtils: { value: viewUtils }, diff --git a/js/stage/stage.reel/stage.html b/js/stage/stage.reel/stage.html index 1b5cec17..45667e06 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.currentDocument"} } }, -- cgit v1.2.3 From 0b830a8c6415e9cc255d1593a05ae3fa9d94c5e2 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 31 May 2012 14:31:00 -0700 Subject: Adding back the stage references in the 3d classes. Signed-off-by: Nivesh Rajbhandari --- js/stage/stage.reel/stage.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'js/stage') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 4505ff66..dc00eac2 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -1090,7 +1090,11 @@ exports.Stage = Montage.create(Component, { workingPlane = [0,0,1,0]; + this.viewUtils.setStageElement(this.application.ninja.currentDocument.model.documentRoot); + this.viewUtils.setRootElement(this.application.ninja.currentDocument.model.documentRoot.parentNode); + this.snapManager._isCacheInvalid = true; + this.snapManager.currentStage = this.application.ninja.currentDocument.model.documentRoot; this.snapManager.setupDragPlaneFromPlane (workingPlane); this.drawUtils.initializeFromDocument(); -- cgit v1.2.3 From 6307b0930f1a8452de954ae16e293da2f575db04 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 31 May 2012 14:49:41 -0700 Subject: removing the last closeDocument handler Signed-off-by: Valerio Virgillito --- js/stage/stage.reel/stage.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'js/stage') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index dc00eac2..4c4ba6c9 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -184,6 +184,8 @@ exports.Stage = Montage.create(Component, { if(!value) { this.hideRulers(); this.hideCanvas(true); + drawUtils._eltArray.length = 0; + drawUtils._planesArray.length = 0; } else if(this._currentDocument.currentView === "design") { this.clearAllCanvas(); this.initWithDocument(false); -- cgit v1.2.3 From ffe6c157279e115f4658d8c66622085f05cfbf43 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 31 May 2012 15:27:03 -0700 Subject: fixing the switching between various types of documents Signed-off-by: Valerio Virgillito --- js/stage/stage.reel/stage.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'js/stage') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 4c4ba6c9..cd08c55d 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -187,8 +187,18 @@ exports.Stage = Montage.create(Component, { drawUtils._eltArray.length = 0; drawUtils._planesArray.length = 0; } else if(this._currentDocument.currentView === "design") { + this.showCodeViewBar(false); + this.restoreAllPanels(); + this.hideCanvas(false); + this.showRulers(); + this.clearAllCanvas(); this.initWithDocument(false); + } else { + this.showCodeViewBar(true); + this.collapseAllPanels(); + this.hideCanvas(true); + this.hideRulers(); } } }, -- cgit v1.2.3 From 4b455d9bb1c3ff7a8199628dc66e158cdee936df Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 31 May 2012 15:34:55 -0700 Subject: Removing unused scroll model save/restore. Signed-off-by: Nivesh Rajbhandari --- js/stage/stage.reel/stage.js | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index cd08c55d..fd9db5ec 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -1040,22 +1040,6 @@ exports.Stage = Montage.create(Component, { } }, - saveScroll:{ - value: function(){ - this.application.ninja.documentController.activeDocument.savedLeftScroll = this._iframeContainer.scrollLeft; - this.application.ninja.documentController.activeDocument.savedTopScroll = this._iframeContainer.scrollTop; - } - }, - - restoreScroll:{ - value: function(){ - this._iframeContainer.scrollLeft = this.application.ninja.documentController.activeDocument.savedLeftScroll; - this._scrollLeft = this.application.ninja.documentController.activeDocument.savedLeftScroll; - this._iframeContainer.scrollTop = this.application.ninja.documentController.activeDocument.savedTopScroll; - this._scrollTop = this.application.ninja.documentController.activeDocument.savedTopScroll; - } - }, - showRulers:{ value:function(){ this.application.ninja.rulerTop.style.display = "block"; -- cgit v1.2.3 From 163e977e5819b4bf7029be0562ee7f31045f05c4 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 31 May 2012 15:53:45 -0700 Subject: removing the stage view component as it is not used anymore Signed-off-by: Valerio Virgillito --- js/stage/stage-view.reel/stage-view.css | 50 -------------------------- js/stage/stage-view.reel/stage-view.html | 30 ---------------- js/stage/stage-view.reel/stage-view.js | 62 -------------------------------- js/stage/stage.reel/stage.css | 47 +++++++++++++++++++++++- js/stage/stage.reel/stage.html | 10 +----- 5 files changed, 47 insertions(+), 152 deletions(-) delete mode 100755 js/stage/stage-view.reel/stage-view.css delete mode 100755 js/stage/stage-view.reel/stage-view.html delete mode 100755 js/stage/stage-view.reel/stage-view.js (limited to 'js/stage') diff --git a/js/stage/stage-view.reel/stage-view.css b/js/stage/stage-view.reel/stage-view.css deleted file mode 100755 index 8afb52a2..00000000 --- a/js/stage/stage-view.reel/stage-view.css +++ /dev/null @@ -1,50 +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. -
*/ - -.codeViewContainer { - position: absolute; - top: 0px; - left: 0px; - margin: 0px; - padding: 0px; - background-color: #ffffff; - width: 100%; - height: 100%; - overflow:auto; - cursor:text; -} - -.codeViewContainer .CodeMirror { - width: 100%; - height: 100%; - background: white; -} - -.codeViewContainer .CodeMirror-scroll { - height: 100%; - overflow: auto; -} - -.codeViewContainer>div{ - width:2500px;/*to prevent scrolling of editor container in the middle of the page for short files*/ -} - -span.CodeMirror-matchhighlight { background: #e9e9e9 } -.CodeMirror-focused span.CodeMirror-matchhighlight { background: #e7e4ff; !important } -div.CodeMirror span.CodeMirror-matchingbracket {color: #000 !important;background-color: #ffd500;} -.CodeMirror-completions select {background-color:#e8f2ff;border:1px solid #c1c1c1;box-shadow: 8px 8px 8px rgba(0, 0, 0, 0.8);} -.CodeMirror-completions {z-index:6001 !important;} - -.cm-s-default .activeline {background: #e8f2ff; !important} -.cm-s-eclipse .activeline {background: #e8f2ff; !important} -.cm-s-elegant .activeline {background: #e8f2ff; !important} -.cm-s-neat .activeline {background: #e8f2ff; !important} -.cm-s-night .activeline {background: #8da6ce; !important} -.cm-s-cobalt .activeline {background: #8da6ce; !important} -.cm-s-monokai .activeline {background: #8da6ce; !important} -.cm-s-rubyblue .activeline {background: #3E7087; !important} -.cm-s-lesser-dark .activeline {background: #8da6ce; !important} -.cm-s-xq-dark .activeline {background: #8da6ce; !important} \ No newline at end of file diff --git a/js/stage/stage-view.reel/stage-view.html b/js/stage/stage-view.reel/stage-view.html deleted file mode 100755 index 3680e8b5..00000000 --- a/js/stage/stage-view.reel/stage-view.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - -
- - - diff --git a/js/stage/stage-view.reel/stage-view.js b/js/stage/stage-view.reel/stage-view.js deleted file mode 100755 index 2c129ee2..00000000 --- a/js/stage/stage-view.reel/stage-view.js +++ /dev/null @@ -1,62 +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. -
*/ - -/** -@requires montage/core/core -@requires montage/ui/component -*/ -var Montage = require("montage/core/core").Montage, - Component = require("montage/ui/component").Component; - -exports.StageView = Montage.create(Component, { - _documents: { - value : [] - }, - - docs: { - get: function() { - return this._documents; - }, - set: function(value) { - //console.log(value); - } - }, - - didDraw:{ - value: function() { - if(!this.application.ninja.documentController._textHolder) this.application.ninja.documentController._textHolder = this.element; - } - }, - - /** - * Public method - * Switches between documents. Document state data is saved and restored whereever applicable - */ - switchDocument:{ - value: function(doc){ - - - //focus editor - if(!!this.application.ninja.documentController.activeDocument && !!this.application.ninja.documentController.activeDocument.editor){ - this.application.ninja.documentController.activeDocument.editor.focus(); - - this.showCodeViewBar(true); - this.application.ninja.codeEditorController.applySettings(); - this.collapseAllPanels(); - } - - 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.stage.stageDeps.reinitializeForSwitchDocument();//reinitialize draw-util, snapmanager and view-util - - this.showCodeViewBar(false); - this.restoreAllPanels(); - } - - NJevent("switchDocument"); - } - } -}); \ No newline at end of file diff --git a/js/stage/stage.reel/stage.css b/js/stage/stage.reel/stage.css index 54b9761b..13537ba1 100755 --- a/js/stage/stage.reel/stage.css +++ b/js/stage/stage.reel/stage.css @@ -10,4 +10,49 @@ box-flex: 1; position: relative; overflow: hidden; -} \ No newline at end of file +} + +.codeViewContainer { + position: absolute; + top: 0px; + left: 0px; + margin: 0px; + padding: 0px; + background-color: #ffffff; + width: 100%; + height: 100%; + overflow:auto; + cursor:text; +} + +.codeViewContainer .CodeMirror { + width: 100%; + height: 100%; + background: white; +} + +.codeViewContainer .CodeMirror-scroll { + height: 100%; + overflow: auto; +} + +.codeViewContainer>div{ + width:2500px;/*to prevent scrolling of editor container in the middle of the page for short files*/ +} + +span.CodeMirror-matchhighlight { background: #e9e9e9 } +.CodeMirror-focused span.CodeMirror-matchhighlight { background: #e7e4ff; !important } +div.CodeMirror span.CodeMirror-matchingbracket {color: #000 !important;background-color: #ffd500;} +.CodeMirror-completions select {background-color:#e8f2ff;border:1px solid #c1c1c1;box-shadow: 8px 8px 8px rgba(0, 0, 0, 0.8);} +.CodeMirror-completions {z-index:6001 !important;} + +.cm-s-default .activeline {background: #e8f2ff; !important} +.cm-s-eclipse .activeline {background: #e8f2ff; !important} +.cm-s-elegant .activeline {background: #e8f2ff; !important} +.cm-s-neat .activeline {background: #e8f2ff; !important} +.cm-s-night .activeline {background: #8da6ce; !important} +.cm-s-cobalt .activeline {background: #8da6ce; !important} +.cm-s-monokai .activeline {background: #8da6ce; !important} +.cm-s-rubyblue .activeline {background: #3E7087; !important} +.cm-s-lesser-dark .activeline {background: #8da6ce; !important} +.cm-s-xq-dark .activeline {background: #8da6ce; !important} \ No newline at end of file diff --git a/js/stage/stage.reel/stage.html b/js/stage/stage.reel/stage.html index 45667e06..7a9619cd 100755 --- a/js/stage/stage.reel/stage.html +++ b/js/stage/stage.reel/stage.html @@ -11,13 +11,6 @@