From 8f1385d4aa12173fb4d9af695b8e5036f675b621 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 4 May 2012 14:39:33 -0700 Subject: Fixing selection and layout code to exclude SCRIPT and STYLE tags. Signed-off-by: Nivesh Rajbhandari --- js/tools/SelectionTool.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'js/tools') diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index 855c7b8c..d3e4ebf9 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js @@ -165,10 +165,11 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { box[3] = point.y; //selectionManagerModule.selectionManager.marqueeSelection(box); - var childNodes = this.application.ninja.currentDocument.documentRoot.childNodes; + var childNodes = this.application.ninja.currentDocument.documentRoot.childNodes, + selectionController = this.application.ninja.selectionController; childNodes = Array.prototype.slice.call(childNodes, 0); childNodes.forEach(function(item) { - if(item.nodeType == 1 && SelectionTool._complicatedCollisionDetection(item, box)) { + if(selectionController.isNodeTraversable(item) && SelectionTool._complicatedCollisionDetection(item, box)) { selectedItems.push(item); } }); -- cgit v1.2.3 From 8f8f7f9a36fb9abadea2a9f25aef0084946bebc9 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 4 May 2012 14:42:00 -0700 Subject: Removed special-casing for new template workflow. Instead, we will enforce a width and height on the body in order to do 3d. Signed-off-by: Nivesh Rajbhandari --- js/tools/RotateStage3DTool.js | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'js/tools') diff --git a/js/tools/RotateStage3DTool.js b/js/tools/RotateStage3DTool.js index 2a9c63db..90cbe95e 100755 --- a/js/tools/RotateStage3DTool.js +++ b/js/tools/RotateStage3DTool.js @@ -96,12 +96,6 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { viewUtils.pushViewportObj( stage ); var eltCtr = viewUtils.getCenterOfProjection(); viewUtils.popViewportObj(); -// if(this.application.ninja.documentController.webTemplate) - if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") - { - eltCtr[0] = stage.scrollWidth/2; - eltCtr[1] = stage.scrollHeight/2; - } var curMat = viewUtils.getMatrixFromElement(stage); var curMatInv = glmat4.inverse(curMat, []); @@ -118,17 +112,7 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { } this._origin = viewUtils.localToGlobal(eltCtr, stage); - -// if(this.application.ninja.documentController.webTemplate) - if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") - { - this._startOriginArray = []; - this._startOriginArray.push(this._origin.slice()); - } - else - { - this._setTransformOrigin(false); - } + this._setTransformOrigin(false); this.DrawHandles(); } }, -- cgit v1.2.3 From 27935436ad8cd0675311667f70b6a285eb126a94 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 4 May 2012 17:10:01 -0700 Subject: Fixing references to iframe's styles in new template. Signed-off-by: Nivesh Rajbhandari --- js/tools/RotateStage3DTool.js | 2 +- js/tools/ZoomTool.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'js/tools') diff --git a/js/tools/RotateStage3DTool.js b/js/tools/RotateStage3DTool.js index 90cbe95e..c8818021 100755 --- a/js/tools/RotateStage3DTool.js +++ b/js/tools/RotateStage3DTool.js @@ -139,7 +139,7 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { // let the document and stage manager know about the zoom change this.application.ninja.stage._firstDraw = true; this.application.ninja.documentBar.zoomFactor = 100; - this.application.ninja.currentDocument.iframe.style.zoom = 1.0; + this.application.ninja.currentDocument.model.views.design.iframe.style.zoom = 1.0; this.application.ninja.stage._firstDraw = false; // TODO - Any updates to the stage should redraw stage's children. Move this to mediator? diff --git a/js/tools/ZoomTool.js b/js/tools/ZoomTool.js index 93caf984..17301262 100755 --- a/js/tools/ZoomTool.js +++ b/js/tools/ZoomTool.js @@ -280,7 +280,9 @@ exports.ZoomTool = Montage.create(DrawingTool, { this.application.ninja.documentBar.zoomFactor = zoomFactor*100; //this.application.ninja.stage.zoomFactor = zoomFactor; if (zoomFactor >= 1) - this.application.ninja.currentDocument.iframe.style.zoom = zoomFactor; + { + this.application.ninja.currentDocument.model.views.design.iframe.style.zoom = zoomFactor; + } this.application.ninja.stage._firstDraw = false; //tmp3 = viewUtils.localToGlobal( localPt, userContent ); // DEBUG - remove this line -- cgit v1.2.3 From 4baed156932f5875755532939a411953fa41c59d Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 8 May 2012 09:43:32 -0700 Subject: Stage should update scroll offsets when scrolled. Note that this is not always correct because we don't get a scroll end event. Updating Pan Tool to update scroll bars. Signed-off-by: Nivesh Rajbhandari --- js/tools/PanTool.js | 66 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 19 deletions(-) (limited to 'js/tools') diff --git a/js/tools/PanTool.js b/js/tools/PanTool.js index ce7606a1..132ac0b1 100755 --- a/js/tools/PanTool.js +++ b/js/tools/PanTool.js @@ -21,6 +21,9 @@ exports.PanTool = Montage.create(toolBase, _lastGPt :{value: [0,0], writable:true}, _lastY :{value: 0, writable:true}, + _maxHorizontalScroll: {value: 0, writable:true}, + _maxVerticalScroll: {value: 0, writable:true}, + Configure: { value: function ( doActivate ) { @@ -43,10 +46,19 @@ exports.PanTool = Montage.create(toolBase, HandleLeftButtonDown: { value : function ( event ) { - this._isDrawing = true; - this.isDrawing = true; - - this.mouseDown( event ); + // Determine the maximum horizontal and vertical scroll values + this._maxHorizontalScroll = this.application.ninja.currentDocument.documentRoot.scrollWidth - this.application.ninja.stage._canvas.width - 11; + this._maxVerticalScroll = this.application.ninja.currentDocument.documentRoot.scrollHeight - this.application.ninja.stage._canvas.height - 11; + if((this._maxHorizontalScroll > 0) || (this._maxVerticalScroll > 0) || this._altKeyDown) + { + this._isDrawing = true; + this.isDrawing = true; + this.mouseDown( event ); + } +// else +// { +// console.log("nothing to scroll"); +// } } }, @@ -136,8 +148,8 @@ exports.PanTool = Montage.create(toolBase, delta = 10*event.wheelDelta/120; //console.log( "delta: " + delta ); - this.application.ninja.stage._iframeContainer.scrollLeft += delta; - this.application.ninja.stage._scrollLeft += delta; + this.application.ninja.currentDocument.documentRoot.scrollLeft += delta; +// this.application.ninja.stage._scrollLeft += delta; delta *= zoom; @@ -291,17 +303,19 @@ exports.PanTool = Montage.create(toolBase, if (this._isDrawing) { // get the global screen point - var gPt = [point.x, point.y, this._globalPt[2]]; + var gPt = [point.x, point.y, this._globalPt[2]], + dx, + dy; if (this._altKeyDown) { - var dy = 5*(point.y - this._lastY); + dy = 5*(point.y - this._lastY); this._globalPt[2] += dy; gPt = [this._lastGPt[0], this._lastGPt[1], this._globalPt[2]]; } else if (this._shiftKeyDown) { - var dx = Math.abs( this._shiftPt[0] - gPt[0] ), - dy = Math.abs( this._shiftPt[1] - gPt[1] ); + dx = Math.abs( this._shiftPt[0] - gPt[0] ); + dy = Math.abs( this._shiftPt[1] - gPt[1] ); if (dx >= dy) gPt[1] = this._shiftPt[1]; @@ -310,16 +324,28 @@ exports.PanTool = Montage.create(toolBase, } // update the scrollbars - var deltaGPt = VecUtils.vecSubtract(2, gPt, this._lastGPt); + var deltaGPt = vecUtils.vecSubtract(2, gPt, this._lastGPt); this._lastGPt = gPt.slice(); this._lastY = point.y; - - var oldLeft = this.application.ninja.stage._iframeContainer.scrollLeft, - oldTop = this.application.ninja.stage._iframeContainer.scrollTop; - this.application.ninja.stage._iframeContainer.scrollLeft -= deltaGPt[0]; - this.application.ninja.stage._iframeContainer.scrollTop -= deltaGPt[1]; - deltaGPt[0] = oldLeft - this.application.ninja.stage._iframeContainer.scrollLeft; - deltaGPt[1] = oldTop - this.application.ninja.stage._iframeContainer.scrollTop; + var limitX = false; + var limitY = false; + + var oldLeft = this.application.ninja.currentDocument.documentRoot.scrollLeft, + oldTop = this.application.ninja.currentDocument.documentRoot.scrollTop, + newLeft = oldLeft - deltaGPt[0], + newTop = oldTop - deltaGPt[1]; + if((newLeft < 0) || (newLeft > this._maxHorizontalScroll)) + { + limitX = true; + } + if((newTop < 0) || (newTop > this._maxVerticalScroll)) + { + limitY = true; + } + this.application.ninja.currentDocument.documentRoot.scrollLeft -= deltaGPt[0]; + this.application.ninja.currentDocument.documentRoot.scrollTop -= deltaGPt[1]; + deltaGPt[0] = oldLeft - this.application.ninja.currentDocument.documentRoot.scrollLeft; + deltaGPt[1] = oldTop - this.application.ninja.currentDocument.documentRoot.scrollTop; gPt[0] -= deltaGPt[0]; gPt[1] -= deltaGPt[1]; @@ -334,7 +360,7 @@ exports.PanTool = Montage.create(toolBase, // limit the change var ucMat = viewUtils.getMatrixFromElement(this.application.ninja.currentDocument.documentRoot); - var tooMuch = false + var tooMuch = false; if ((ucMat[12] > 12000) && (delta[0] > 0)) tooMuch = true; if ((ucMat[12] < -12000) && (delta[0] < 0)) tooMuch = true; if ((ucMat[13] > 12000) && (delta[1] > 0)) tooMuch = true; @@ -349,6 +375,8 @@ exports.PanTool = Montage.create(toolBase, else this._worldPt = wPt; + if(limitX) delta[0] = 0; + if(limitY) delta[1] = 0; // update everything var transMat = Matrix.Translation( delta ); this.applyDeltaMat( transMat ); -- cgit v1.2.3 From 253b8803c71c88a6f87fb1caccd42fa081fc6eca Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 15 May 2012 14:17:41 -0700 Subject: Fixing scrollbar syncing, including pan tool, for banner templates. Signed-off-by: Nivesh Rajbhandari --- js/tools/PanTool.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'js/tools') diff --git a/js/tools/PanTool.js b/js/tools/PanTool.js index 132ac0b1..5cfeec75 100755 --- a/js/tools/PanTool.js +++ b/js/tools/PanTool.js @@ -148,8 +148,7 @@ exports.PanTool = Montage.create(toolBase, delta = 10*event.wheelDelta/120; //console.log( "delta: " + delta ); - this.application.ninja.currentDocument.documentRoot.scrollLeft += delta; -// this.application.ninja.stage._scrollLeft += delta; + this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft += delta; delta *= zoom; @@ -330,8 +329,8 @@ exports.PanTool = Montage.create(toolBase, var limitX = false; var limitY = false; - var oldLeft = this.application.ninja.currentDocument.documentRoot.scrollLeft, - oldTop = this.application.ninja.currentDocument.documentRoot.scrollTop, + var oldLeft = this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft, + oldTop = this.application.ninja.currentDocument.model.views.design.document.body.scrollTop, newLeft = oldLeft - deltaGPt[0], newTop = oldTop - deltaGPt[1]; if((newLeft < 0) || (newLeft > this._maxHorizontalScroll)) @@ -342,10 +341,10 @@ exports.PanTool = Montage.create(toolBase, { limitY = true; } - this.application.ninja.currentDocument.documentRoot.scrollLeft -= deltaGPt[0]; - this.application.ninja.currentDocument.documentRoot.scrollTop -= deltaGPt[1]; - deltaGPt[0] = oldLeft - this.application.ninja.currentDocument.documentRoot.scrollLeft; - deltaGPt[1] = oldTop - this.application.ninja.currentDocument.documentRoot.scrollTop; + this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft -= deltaGPt[0]; + this.application.ninja.currentDocument.model.views.design.document.body.scrollTop -= deltaGPt[1]; + deltaGPt[0] = oldLeft - this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft; + deltaGPt[1] = oldTop - this.application.ninja.currentDocument.model.views.design.document.body.scrollTop; gPt[0] -= deltaGPt[0]; gPt[1] -= deltaGPt[1]; -- cgit v1.2.3 From f9f8fdc3000042ba5b4504d91870dc9a32ef25eb Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 16 May 2012 01:00:22 -0700 Subject: Squashed master into dom-architecture Signed-off-by: Valerio Virgillito --- js/tools/LineTool.js | 3 ++- js/tools/OvalTool.js | 2 +- js/tools/RectTool.js | 2 +- js/tools/TextTool.js | 40 ++++++++++++++-------------------------- 4 files changed, 18 insertions(+), 29 deletions(-) (limited to 'js/tools') diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js index 5941b464..198d7e69 100755 --- a/js/tools/LineTool.js +++ b/js/tools/LineTool.js @@ -234,7 +234,8 @@ exports.LineTool = Montage.create(ShapeTool, { var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2)); - var line = new Line(world, xOffset, yOffset, w, h, slope, strokeSize, strokeColor, strokeMaterial, strokeStyle, xAdj, yAdj); + var line = Object.create(Line, {}); + line.init(world, xOffset, yOffset, w, h, slope, strokeSize, strokeColor, strokeMaterial, strokeStyle, xAdj, yAdj); world.addObject(line); world.render(); diff --git a/js/tools/OvalTool.js b/js/tools/OvalTool.js index 6edec811..e9dc66bb 100755 --- a/js/tools/OvalTool.js +++ b/js/tools/OvalTool.js @@ -68,7 +68,7 @@ exports.OvalTool = Montage.create(ShapeTool, { var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); var yOffset = -(canvas.height/2 - (top - canvas.offsetTop + h/2)); - var oval = new Circle(); //GLCircle(); + var oval = Object.create(Circle, {}); oval.init(world, xOffset, yOffset, w, h, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle); world.addObject(oval); diff --git a/js/tools/RectTool.js b/js/tools/RectTool.js index 0c14a559..0a3c8200 100755 --- a/js/tools/RectTool.js +++ b/js/tools/RectTool.js @@ -87,7 +87,7 @@ exports.RectTool = Montage.create(ShapeTool, { var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2)); - var rect = new Rectangle(); + var rect = Object.create(Rectangle, {}); rect.init(world, xOffset, yOffset, w, h, strokeSize, strokeColor, fillColor, tlRadius, trRadius, blRadius, brRadius, strokeMaterial, fillMaterial, strokeStyle); diff --git a/js/tools/TextTool.js b/js/tools/TextTool.js index a58aacc6..024a92ce 100755 --- a/js/tools/TextTool.js +++ b/js/tools/TextTool.js @@ -5,13 +5,18 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot */ var Montage = require("montage/core/core").Montage, - DrawingTool = require("js/tools/drawing-tool").DrawingTool; + DrawingTool = require("js/tools/drawing-tool").DrawingTool, RichTextEditor = require("node_modules/labs/rich-text-editor.reel").RichTextEditor, ElementsMediator = require("js/mediators/element-mediator").ElementMediator; exports.TextTool = Montage.create(DrawingTool, { + drawingFeedback: { + value: { mode: "Draw3D", type: "rectangle" } + }, - _selectedElement: { value : null }, + _selectedElement: { + value : null + }, selectedElement: { get: function() { @@ -35,9 +40,6 @@ exports.TextTool = Montage.create(DrawingTool, { } } }, - - - drawingFeedback: { value: { mode: "Draw3D", type: "rectangle" } }, HandleLeftButtonDown: { value: function(event) { @@ -81,15 +83,7 @@ exports.TextTool = Montage.create(DrawingTool, { return; } - var drawData, selectedItem; - if(this._hasDraw) { - drawData = this.getDrawingData(); - - if(drawData) { - //this.insertElement(drawData); - } - this._hasDraw = false; this.endDraw(event); } else { @@ -113,6 +107,8 @@ exports.TextTool = Montage.create(DrawingTool, { drawTextTool: { value: function() { + var self = this; + this.application.ninja.stage.textTool.value = this.selectedElement.innerHTML; if(this.application.ninja.stage.textTool.value === "") { this.application.ninja.stage.textTool.value = " "; } this.selectedElement.innerHTML = ""; @@ -125,35 +121,27 @@ exports.TextTool = Montage.create(DrawingTool, { this.application.ninja.stage.textTool.element.style.width = this.selectedElement.offsetWidth + "px"; this.application.ninja.stage.textTool.element.style.height = this.selectedElement.offsetHeight + "px"; - // Set font styling (Size, Style, Weight) - - me = this; this.application.ninja.stage.textTool.didDraw = function() { - me.applyElementStyles(me.selectedElement, me.application.ninja.stage.textTool.element, ["overflow"]); - me.applyElementStyles(me.selectedElement, me.application.ninja.stage.textTool.element.firstChild, ["font","padding-left","padding-top","padding-right","padding-bottom", "color"]); + self.applyElementStyles(self.selectedElement, self.application.ninja.stage.textTool.element, ["overflow"]); + self.applyElementStyles(self.selectedElement, self.application.ninja.stage.textTool.element.firstChild, ["font","padding-left","padding-top","padding-right","padding-bottom", "color"]); var range = document.createRange(), sel = window.getSelection(); sel.removeAllRanges(); - range.selectNodeContents(this.application.ninja.stage.textTool.element.firstChild); + range.selectNodeContents(self.application.ninja.stage.textTool.element.firstChild); sel.addRange(range); this.didDraw = function() {}; } } }, + /* HandleDoubleClick: { value: function(e) { //this.application.ninja.selectedElements[0].setAttribute("contenteditable", true); - - //if (!this.application.ninja.textTool) { - - //} - - - } }, + */ Configure: { value: function(wasSelected) { -- cgit v1.2.3 From db749e10fdff655c2f3b8336a8cc58bf4f389e2c Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 17 May 2012 10:47:53 -0700 Subject: IKNinja-1628 - Can't draw shapes inside canvas after double-clicking into canvas. Signed-off-by: Nivesh Rajbhandari --- js/tools/ShapeTool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/tools') diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index 0562dbc2..367ab78d 100755 --- a/js/tools/ShapeTool.js +++ b/js/tools/ShapeTool.js @@ -72,7 +72,7 @@ exports.ShapeTool = Montage.create(DrawingTool, { if(!canvas.elementModel.shapeModel) { canvas.elementModel.shapeModel = Montage.create(ShapeModel); } - this.application.ninja.elementMediator.addElements(canvas, canvas.elementModel.data); + this.RenderShape(drawData.width, drawData.height, drawData.planeMat, drawData.midPt, canvas); } } -- cgit v1.2.3 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/tools/drawing-tool-base.js | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-) (limited to 'js/tools') diff --git a/js/tools/drawing-tool-base.js b/js/tools/drawing-tool-base.js index 84641754..0a3767b5 100755 --- a/js/tools/drawing-tool-base.js +++ b/js/tools/drawing-tool-base.js @@ -12,17 +12,7 @@ var viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils; var vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; var drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils; -exports.DrawingToolBase = Montage.create(Montage, { - - //!!!! HACK - // TODO: Need to find a better way to address this - stage: { - value: null - }, - - stageComponent: { - value: null - }, +exports.DrawingToolBase = Montage.create(Component, { dragPlane: { value: null @@ -164,9 +154,8 @@ exports.DrawingToolBase = Montage.create(Montage, { // get the hit rec. points in plane space var psPos = hitRec.getLocalPoint(); - var stage = this.stage; - var stageOffset = viewUtils.getElementOffset(stage); - viewUtils.setViewportObj(stage); + var stageOffset = viewUtils.getElementOffset(this.application.ninja.currentDocument.documentRoot); + viewUtils.setViewportObj(this.application.ninja.currentDocument.documentRoot); // get the matrix taking the local hit point in plane space // to world space of whatever element it is in. @@ -194,9 +183,8 @@ exports.DrawingToolBase = Montage.create(Montage, { var p0 = hitRec0.getLocalPoint(), p1 = hitRec1.getLocalPoint(); - var stage = this.stage; - var stageOffset = viewUtils.getElementOffset(stage); - viewUtils.setViewportObj(stage); + var stageOffset = viewUtils.getElementOffset(this.application.ninja.currentDocument.documentRoot); + viewUtils.setViewportObj(this.application.ninja.currentDocument.documentRoot); // get the matrix taking the local hit point in plane space // to world space of whatever element it is in. @@ -301,10 +289,10 @@ exports.DrawingToolBase = Montage.create(Montage, { draw2DRectangle: { value: function(x0, y0, x1, y1) { - var drawingContext = this.stageComponent.drawingContext, - drawingPrefs = this.stageComponent.drawingContextPreferences; + var drawingContext = this.application.ninja.stage.drawingContext, + drawingPrefs = this.application.ninja.stage.drawingContextPreferences; - this.stageComponent.clearDrawingCanvas(); + this.application.ninja.stage.clearDrawingCanvas(); //TODO Save and restore state drawingContext.strokeStyle = drawingPrefs.color; drawingContext.lineWidth = drawingPrefs.thickness; @@ -320,11 +308,10 @@ exports.DrawingToolBase = Montage.create(Montage, { var p0 = hitRec0.getLocalPoint(), p1 = hitRec1.getLocalPoint(); - var stage = this.stage; - var stageMat = viewUtils.getMatrixFromElement( stage ); + var stageMat = viewUtils.getMatrixFromElement(this.application.ninja.currentDocument.documentRoot); var elt = hitRec0.getElt(); if (!elt) { elt = hitRec1.getElt(); } - if (!elt) { elt = stage; } + if (!elt) { elt = this.application.ninja.currentDocument.documentRoot; } if (elt) { viewUtils.pushViewportObj(elt); @@ -420,11 +407,11 @@ exports.DrawingToolBase = Montage.create(Montage, { if ( isProjected) { var unprojPtArr = [s0, s1, s2, s3]; - this.stageComponent.draw3DProjectedAndUnprojectedRectangles( unprojPtArr, projPtArr ); + this.application.ninja.stage.draw3DProjectedAndUnprojectedRectangles( unprojPtArr, projPtArr ); } else { - this.stageComponent.draw3DSelectionRectangle(s0[0], s0[1], + this.application.ninja.stage.draw3DSelectionRectangle(s0[0], s0[1], s1[0], s1[1], s2[0], s2[1], s3[0], s3[1], @@ -440,7 +427,7 @@ exports.DrawingToolBase = Montage.create(Montage, { value: function (hitRec0, hitRec1, strokeSize, strokeColor) { var p0 = hitRec0.getScreenPoint(), p1 = hitRec1.getScreenPoint(); - this.stageComponent.drawLine(p0[0], p0[1], p1[0], p1[1], strokeSize, strokeColor); + this.application.ninja.stage.drawLine(p0[0], p0[1], p1[0], p1[1], strokeSize, strokeColor); } }, -- cgit v1.2.3 From 5914c5b2209c4b8daac4249bb76cda5c9314c4e6 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 24 May 2012 00:07:23 -0700 Subject: Cleaning up referencing to 'documentRoot' and '_document' Moved to reference new model in DOM architecture rework. This should not affect anything, just moving the references, and also the setting to the render methods in the design view. --- js/tools/PanTool.js | 16 ++++++++-------- js/tools/Rotate3DToolBase.js | 12 ++++++------ js/tools/RotateStage3DTool.js | 8 ++++---- js/tools/SelectionTool.js | 6 +++--- js/tools/Translate3DToolBase.js | 4 ++-- js/tools/ZoomTool.js | 2 +- js/tools/drawing-tool-base.js | 12 ++++++------ js/tools/modifier-tool-base.js | 8 ++++---- 8 files changed, 34 insertions(+), 34 deletions(-) (limited to 'js/tools') diff --git a/js/tools/PanTool.js b/js/tools/PanTool.js index 5cfeec75..39f89d17 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.documentRoot.scrollWidth - this.application.ninja.stage._canvas.width - 11; - this._maxVerticalScroll = this.application.ninja.currentDocument.documentRoot.scrollHeight - this.application.ninja.stage._canvas.height - 11; + 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; if((this._maxHorizontalScroll > 0) || (this._maxVerticalScroll > 0) || this._altKeyDown) { this._isDrawing = true; @@ -121,7 +121,7 @@ exports.PanTool = Montage.create(toolBase, { value: function () { - var uc = this.application.ninja.currentDocument.documentRoot; + var uc = this.application.ninja.currentDocument.model.documentRoot; //var uc = documentManagerModule.DocumentManager.activeDocument var ucMat = viewUtils.getMatrixFromElement(uc); @@ -152,7 +152,7 @@ exports.PanTool = Montage.create(toolBase, delta *= zoom; - var uc = this.application.ninja.currentDocument.documentRoot; + var uc = this.application.ninja.currentDocument.model.documentRoot; var ucMat = viewUtils.getMatrixFromElement(uc); var offset = viewUtils.getElementOffset( uc ); //console.log( "uc offset: " + offset[0] ); @@ -224,7 +224,7 @@ exports.PanTool = Montage.create(toolBase, if (elt) { // get the userContent object (stage) and its matrix - var userContent = this.application.ninja.currentDocument.documentRoot; + var userContent = this.application.ninja.currentDocument.model.documentRoot; var ucMat = viewUtils.getMatrixFromElement(userContent); var localToGlobalMat = viewUtils.getLocalToGlobalMatrix( elt ); @@ -358,7 +358,7 @@ exports.PanTool = Montage.create(toolBase, delta[2] = 0; // limit the change - var ucMat = viewUtils.getMatrixFromElement(this.application.ninja.currentDocument.documentRoot); + var ucMat = viewUtils.getMatrixFromElement(this.application.ninja.currentDocument.model.documentRoot); var tooMuch = false; if ((ucMat[12] > 12000) && (delta[0] > 0)) tooMuch = true; if ((ucMat[12] < -12000) && (delta[0] < 0)) tooMuch = true; @@ -397,7 +397,7 @@ exports.PanTool = Montage.create(toolBase, value: function( transMat ) { // update the user content matrix - var uc = this.application.ninja.currentDocument.documentRoot; + var uc = this.application.ninja.currentDocument.model.documentRoot; var ucMat = viewUtils.getMatrixFromElement(uc); var newUCMat = glmat4.multiply( transMat, ucMat, [] ); viewUtils.setMatrixForElement( uc, newUCMat ); @@ -412,7 +412,7 @@ exports.PanTool = Montage.create(toolBase, value: function() { // get the userContent object - var userContent = this.application.ninja.currentDocument.documentRoot; + var userContent = this.application.ninja.currentDocument.model.documentRoot; // get a matrix from user content world space to the screen viewUtils.pushViewportObj( userContent ); diff --git a/js/tools/Rotate3DToolBase.js b/js/tools/Rotate3DToolBase.js index 4fa8657e..bf9537dd 100755 --- a/js/tools/Rotate3DToolBase.js +++ b/js/tools/Rotate3DToolBase.js @@ -32,7 +32,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { var selectedElements = this.application.ninja.selectedElements; if(this.rotateStage) { - selectedElements = [this.application.ninja.currentDocument.documentRoot]; + selectedElements = [this.application.ninja.currentDocument.model.documentRoot]; } this._mouseDownHitRec = null; @@ -225,7 +225,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { var selectedElements = this.application.ninja.selectedElements; if(this.rotateStage) { - selectedElements = [this.application.ninja.currentDocument.documentRoot]; + selectedElements = [this.application.ninja.currentDocument.model.documentRoot]; } if(this._handleMode !== null) @@ -345,7 +345,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { var selectedElements = this.application.ninja.selectedElements; if(this.rotateStage) { - selectedElements = [this.application.ninja.currentDocument.documentRoot]; + selectedElements = [this.application.ninja.currentDocument.model.documentRoot]; } var len = selectedElements.length; for(var i = 0; i < len; i++) { @@ -481,7 +481,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { } else { - this.target = this.application.ninja.currentDocument.documentRoot; + this.target = this.application.ninja.currentDocument.model.documentRoot; //this._origin = drawUtils._selectionCtr.slice(0); //this._origin[0] += this.application.ninja.stage.userContentLeft; //this._origin[1] += this.application.ninja.stage.userContentTop; @@ -609,7 +609,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { if(this.rotateStage || (this.application.ninja.selectedElements.length === 1)) { if(this.rotateStage) { - element = this.application.ninja.currentDocument.documentRoot; + element = this.application.ninja.currentDocument.model.documentRoot; } else { element = this.application.ninja.selectedElements[0]; } @@ -851,7 +851,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { else { lMode = false; - viewUtils.pushViewportObj( this.application.ninja.currentDocument.documentRoot ); + viewUtils.pushViewportObj( this.application.ninja.currentDocument.model.documentRoot ); } var base = this._origin; //console.log( "Rotate3DToolBase.DrawHandles, base: " + base ); diff --git a/js/tools/RotateStage3DTool.js b/js/tools/RotateStage3DTool.js index c8818021..92ed40d2 100755 --- a/js/tools/RotateStage3DTool.js +++ b/js/tools/RotateStage3DTool.js @@ -90,7 +90,7 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { this._origin = null; this._startOriginArray = null; - var stage = this.application.ninja.currentDocument.documentRoot; + var stage = this.application.ninja.currentDocument.model.documentRoot; this.target = stage; viewUtils.pushViewportObj( stage ); @@ -119,7 +119,7 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { captureElementChange: { value: function(event) { - if(event._event.item === this.application.ninja.currentDocument.documentRoot) + if(event._event.item === this.application.ninja.currentDocument.model.documentRoot) { this.captureSelectionDrawn(null); } @@ -132,9 +132,9 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { // Reset stage to identity matrix var iMat = Matrix.I(4); - ElementsMediator.setMatrix(this.application.ninja.currentDocument.documentRoot, + ElementsMediator.setMatrix(this.application.ninja.currentDocument.model.documentRoot, iMat, false, "rotateStage3DTool"); - this.application.ninja.currentDocument.documentRoot.elementModel.props3D.m_transformCtr = null; + this.application.ninja.currentDocument.model.documentRoot.elementModel.props3D.m_transformCtr = null; // let the document and stage manager know about the zoom change this.application.ninja.stage._firstDraw = true; diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index 5c8b15ae..4bafa12a 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js @@ -165,7 +165,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { box[3] = point.y; //selectionManagerModule.selectionManager.marqueeSelection(box); - var childNodes = this.application.ninja.currentDocument.documentRoot.childNodes, + var childNodes = this.application.ninja.currentDocument.model.documentRoot.childNodes, selectionController = this.application.ninja.selectionController; childNodes = Array.prototype.slice.call(childNodes, 0); childNodes.forEach(function(item) { @@ -224,7 +224,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { if(this.application.ninja.selectedElements.length > 0) { this.application.ninja.currentSelectedContainer = this.application.ninja.selectedElements[0]; } else { - this.application.ninja.currentSelectedContainer = this.application.ninja.currentDocument.documentRoot; + this.application.ninja.currentSelectedContainer = this.application.ninja.currentDocument.model.documentRoot; } } }, @@ -690,7 +690,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { this.application.ninja.stage.clearDrawingCanvas(); var item = this._target; - if(!item || (item === this.application.ninja.currentDocument.documentRoot)) + if(!item || (item === this.application.ninja.currentDocument.model.documentRoot)) { return; } diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js index f81ce6d6..8437ec09 100755 --- a/js/tools/Translate3DToolBase.js +++ b/js/tools/Translate3DToolBase.js @@ -296,7 +296,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, //this._setTransformOrigin(false); } else { - this.target = this.application.ninja.currentDocument.documentRoot; + this.target = this.application.ninja.currentDocument.model.documentRoot; //this._origin = drawUtils._selectionCtr.slice(0); //this._origin[0] += this.application.ninja.stage.userContentLeft; //this._origin[1] += this.application.ninja.stage.userContentTop; @@ -407,7 +407,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, else { lMode = false; - viewUtils.pushViewportObj( this.application.ninja.currentDocument.documentRoot ); + viewUtils.pushViewportObj( this.application.ninja.currentDocument.model.documentRoot ); } if(this._handleMode !== null) diff --git a/js/tools/ZoomTool.js b/js/tools/ZoomTool.js index 17301262..dc096592 100755 --- a/js/tools/ZoomTool.js +++ b/js/tools/ZoomTool.js @@ -184,7 +184,7 @@ exports.ZoomTool = Montage.create(DrawingTool, { _setZoom:{ value:function(mode,zoomFactor) { - var userContent = this.application.ninja.currentDocument.documentRoot; + var userContent = this.application.ninja.currentDocument.model.documentRoot; this._oldValue = this.application.ninja.documentBar.zoomFactor; var globalPt; diff --git a/js/tools/drawing-tool-base.js b/js/tools/drawing-tool-base.js index 0a3767b5..3549de1c 100755 --- a/js/tools/drawing-tool-base.js +++ b/js/tools/drawing-tool-base.js @@ -154,8 +154,8 @@ exports.DrawingToolBase = Montage.create(Component, { // get the hit rec. points in plane space var psPos = hitRec.getLocalPoint(); - var stageOffset = viewUtils.getElementOffset(this.application.ninja.currentDocument.documentRoot); - viewUtils.setViewportObj(this.application.ninja.currentDocument.documentRoot); + var stageOffset = viewUtils.getElementOffset(this.application.ninja.currentDocument.model.documentRoot); + viewUtils.setViewportObj(this.application.ninja.currentDocument.model.documentRoot); // get the matrix taking the local hit point in plane space // to world space of whatever element it is in. @@ -183,8 +183,8 @@ exports.DrawingToolBase = Montage.create(Component, { var p0 = hitRec0.getLocalPoint(), p1 = hitRec1.getLocalPoint(); - var stageOffset = viewUtils.getElementOffset(this.application.ninja.currentDocument.documentRoot); - viewUtils.setViewportObj(this.application.ninja.currentDocument.documentRoot); + var stageOffset = viewUtils.getElementOffset(this.application.ninja.currentDocument.model.documentRoot); + viewUtils.setViewportObj(this.application.ninja.currentDocument.model.documentRoot); // get the matrix taking the local hit point in plane space // to world space of whatever element it is in. @@ -308,10 +308,10 @@ exports.DrawingToolBase = Montage.create(Component, { var p0 = hitRec0.getLocalPoint(), p1 = hitRec1.getLocalPoint(); - var stageMat = viewUtils.getMatrixFromElement(this.application.ninja.currentDocument.documentRoot); + var stageMat = viewUtils.getMatrixFromElement(this.application.ninja.currentDocument.model.documentRoot); var elt = hitRec0.getElt(); if (!elt) { elt = hitRec1.getElt(); } - if (!elt) { elt = this.application.ninja.currentDocument.documentRoot; } + if (!elt) { elt = this.application.ninja.currentDocument.model.documentRoot; } if (elt) { viewUtils.pushViewportObj(elt); diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js index d023206a..6aea77aa 100755 --- a/js/tools/modifier-tool-base.js +++ b/js/tools/modifier-tool-base.js @@ -39,7 +39,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { return this._clickedObject; }, set: function (value) { - if(value === this.application.ninja.currentDocument.documentRoot) + if(value === this.application.ninja.currentDocument.model.documentRoot) { this._clickedObject = this._target; } @@ -64,7 +64,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { value: function(hitRec) { var elt = hitRec.getElt(); - if(elt === this.application.ninja.currentDocument.documentRoot) + if(elt === this.application.ninja.currentDocument.model.documentRoot) { elt = this._target; } @@ -531,7 +531,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() ); if ( snapManager.snapAlignEnabled() && this._clickedObject && - (this._clickedObject !== this.application.ninja.currentDocument.documentRoot) ) + (this._clickedObject !== this.application.ninja.currentDocument.model.documentRoot) ) { var alignBounds = !hitRec || (hitRec.getType() == hitRec.SNAP_TYPE_STAGE) || hitRec.isSomeGridTypeSnap(); if (alignBounds) @@ -776,7 +776,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { } else { - this.target = this.application.ninja.currentDocument.documentRoot; + this.target = this.application.ninja.currentDocument.model.documentRoot; } // this._updateTargets(); } -- cgit v1.2.3 From de25d2b7d05476d4f0d385b5e910db189f682d21 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 24 May 2012 13:34:12 -0700 Subject: IKNinja-1621 - 3D stage does not reset correctly when the rotation point is set elsewhere on stage. Signed-off-by: Nivesh Rajbhandari --- js/tools/RotateStage3DTool.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'js/tools') diff --git a/js/tools/RotateStage3DTool.js b/js/tools/RotateStage3DTool.js index c8818021..a9346c8e 100755 --- a/js/tools/RotateStage3DTool.js +++ b/js/tools/RotateStage3DTool.js @@ -130,20 +130,22 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { value : function() { // Reset stage to identity matrix - var iMat = Matrix.I(4); + var iMat = Matrix.I(4), + stage = this.application.ninja.stage; ElementsMediator.setMatrix(this.application.ninja.currentDocument.documentRoot, iMat, false, "rotateStage3DTool"); this.application.ninja.currentDocument.documentRoot.elementModel.props3D.m_transformCtr = null; // let the document and stage manager know about the zoom change - this.application.ninja.stage._firstDraw = true; + stage._firstDraw = true; this.application.ninja.documentBar.zoomFactor = 100; this.application.ninja.currentDocument.model.views.design.iframe.style.zoom = 1.0; - this.application.ninja.stage._firstDraw = false; + stage._firstDraw = false; - // TODO - Any updates to the stage should redraw stage's children. Move this to mediator? - this.application.ninja.stage.updatedStage = true; + viewUtils.clearStageTranslation(); + stage.centerStage(); + stage.draw(); this.isDrawing = false; this.endDraw(event); -- cgit v1.2.3