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 From c385a1d2d8154e2c5b005c0caca5a46318f6928f Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Tue, 29 May 2012 08:26:55 -0700 Subject: rename dragging plane to dragPlane (for consistency with ShapeTool) --- js/tools/BrushTool.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'js/tools') diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js index 03edef79..f85978ad 100644 --- a/js/tools/BrushTool.js +++ b/js/tools/BrushTool.js @@ -39,7 +39,7 @@ exports.BrushTool = Montage.create(ShapeTool, { //view options _brushStrokeCanvas: {value: null, writable: true}, _brushStrokePlaneMat: {value: null, writable: true}, - _draggingPlane: {value: null, writable: true}, + dragPlane: {value: null, writable: true}, //the current brush stroke _selectedBrushStroke: {value: null, writable: true}, @@ -67,7 +67,7 @@ exports.BrushTool = Montage.create(ShapeTool, { var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(x,y)); var unsnappedpos = DrawingToolBase.getHitRecPos(snapManager.snap(point.x, point.y, false)); - this._draggingPlane = snapManager.getDragPlane(); + this.dragPlane = snapManager.getDragPlane(); snapManager.enableElementSnap(elemSnap); snapManager.enableGridSnap(gridSnap); @@ -100,7 +100,7 @@ exports.BrushTool = Montage.create(ShapeTool, { } var tmpPoint = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(x,y)); var hitRec = snapManager.snap(tmpPoint.x, tmpPoint.y, false); - this._draggingPlane = snapManager.getDragPlane(); + this.dragPlane = snapManager.getDragPlane(); if (this._selectedSubpathCanvas){ snapManager.popWorkingPlane(); } @@ -228,7 +228,7 @@ exports.BrushTool = Montage.create(ShapeTool, { if (this._selectedBrushStroke){ this._selectedBrushStroke.setPlaneMatrix(this._brushStrokePlaneMat); this._selectedBrushStroke.setPlaneMatrixInverse(glmat4.inverse(this._brushStrokePlaneMat,[])); - this._selectedBrushStroke.setDragPlane(this._draggingPlane); + this._selectedBrushStroke.setDragPlane(this.dragPlane); } //display the previously drawn stroke in a separate canvas -- cgit v1.2.3 From e2ae637582b8e02125086201a64ee85761b01093 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Tue, 29 May 2012 14:24:47 -0700 Subject: More consistent local and global mouse coords which solves a bug with the Pen minus subtool not removing 1 anchor paths --- js/tools/PenTool.js | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'js/tools') diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index bbde7374..14ea3563 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js @@ -334,8 +334,20 @@ exports.PenTool = Montage.create(ShapeTool, { //build the hit record for the current mouse position (on the stage or the plane of the path canvas) var hitRec = this.getHitRecord(event.pageX, event.pageY, false); - - if (this._selectedSubpathCanvas === null){ + var globalMousePos=null, localMousePos=null, stageWorldMousePos = null, drawingCanvas=null; + if (!this._selectedSubpathCanvas){ + drawingCanvas = ViewUtils.getStageElement(); + stageWorldMousePos = hitRec.calculateStageWorldPoint(); + stageWorldMousePos[0]+= snapManager.getStageWidth()*0.5; + stageWorldMousePos[1]+= snapManager.getStageHeight()*0.5; + localMousePos = stageWorldMousePos; //since the subpath points are in stage world space, set the 'localMousePos' to be stage world as well + } + else { + globalMousePos = hitRec.getScreenPoint(); + localMousePos = ViewUtils.globalToLocal(globalMousePos, this._selectedSubpathCanvas); + } + + if (this._selectedSubpathCanvas === null && this._subtool===this.SUBTOOL_NONE){ //IF this is the first anchor point of the selected subpath // Store the plane mat and drag plane of this hit record (will be used for creating a canvas) // Add the mouse position (in stage world space) as an anchor point @@ -344,12 +356,8 @@ exports.PenTool = Montage.create(ShapeTool, { this._selectedSubpathPlaneMat = hitRec.getPlaneMatrix(); } - //calculate the stage world position from the hit record - var swMousePos = hitRec.calculateStageWorldPoint(); - swMousePos[0]+= snapManager.getStageWidth()*0.5; swMousePos[1]+= snapManager.getStageHeight()*0.5; - //check if the mouse click location is close to the existing anchor - var indexAndCode = this._selectedSubpath.pickAnchor(swMousePos[0], swMousePos[1], swMousePos[2], this._PICK_POINT_RADIUS); + var indexAndCode = this._selectedSubpath.pickAnchor(stageWorldMousePos[0], stageWorldMousePos[1], stageWorldMousePos[2], this._PICK_POINT_RADIUS); if (indexAndCode[0]>=0){ //the anchor point was hit, so we do not add another anchor switch(indexAndCode[1]){ @@ -371,9 +379,9 @@ exports.PenTool = Montage.create(ShapeTool, { } else { this._selectedSubpath.addAnchor(new AnchorPoint()); var newAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()); - newAnchor.setPos(swMousePos[0], swMousePos[1], swMousePos[2]); - newAnchor.setPrevPos(swMousePos[0], swMousePos[1], swMousePos[2]); - newAnchor.setNextPos(swMousePos[0], swMousePos[1], swMousePos[2]); + newAnchor.setPos(stageWorldMousePos[0], stageWorldMousePos[1], stageWorldMousePos[2]); + newAnchor.setPrevPos(stageWorldMousePos[0], stageWorldMousePos[1], stageWorldMousePos[2]); + newAnchor.setNextPos(stageWorldMousePos[0], stageWorldMousePos[1], stageWorldMousePos[2]); //set the mode so that dragging will update the next and previous locations this._editMode = this.EDIT_PREV_NEXT; } @@ -392,10 +400,6 @@ exports.PenTool = Montage.create(ShapeTool, { // Create a new subpath // Add the mouse position (in selected subpath's local space) as an anchor point (call global to local) - // Compute the mouse position in local (selected subpath canvas) space - var globalPos = hitRec.getScreenPoint(); - var localMousePos = ViewUtils.globalToLocal(globalPos, this._selectedSubpathCanvas); - //now perform the hit testing var prevSelectedAnchorIndex = this._selectedSubpath.getSelectedAnchorIndex(); var selAnchorAndParamAndCode = this._selectedSubpath.pickPath(localMousePos[0], localMousePos[1], localMousePos[2], this._PICK_POINT_RADIUS, false); @@ -776,6 +780,7 @@ exports.PenTool = Montage.create(ShapeTool, { // ********************************************************************************************************** HandleLeftButtonUp: { value: function (event) { + this._isDrawing = false; //do nothing in case of pen minus tool if (this._subtool===this.SUBTOOL_PENMINUS){ return; @@ -825,7 +830,6 @@ exports.PenTool = Montage.create(ShapeTool, { //always assume that we're not starting a new path anymore this._isNewPath = false; - this._isDrawing = false; this._editMode = this.EDIT_NONE; //if we're not in edit_path mode and we closed the selected subpath, then we are going to start a new subpath, so we nullify the selected subpath @@ -1500,21 +1504,17 @@ exports.PenTool = Montage.create(ShapeTool, { switch (this.options.selectedSubtool){ case "pen": this._subtool = this.SUBTOOL_NONE; - console.log("Setting pen tool subtool to NONE"); break; case "penPlus": - console.log("Setting pen tool subtool to PLUS"); this._subtool = this.SUBTOOL_PENPLUS; break; case "penMinus": - console.log("Setting pen tool subtool to MINUS"); this._subtool = this.SUBTOOL_PENMINUS; break; default: - console.log("Setting pen tool subtool to NONE"); this._subtool = this.SUBTOOL_NONE; break; } -- cgit v1.2.3 From 4e3eeb3dbe12f9bbf370d178423a1cd2560e709d Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Wed, 30 May 2012 09:21:36 -0700 Subject: working version of Pen minus subtool --- js/tools/PenTool.js | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) (limited to 'js/tools') diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index 14ea3563..2974d37b 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js @@ -190,10 +190,11 @@ exports.PenTool = Montage.create(ShapeTool, { if (removeSelectedSubpath){ this._selectedSubpath.clearAllAnchors(); //perhaps unnecessary this._selectedSubpath = null; - if (this._entryEditMode === this.ENTRY_SELECT_PATH){ - this._entryEditMode = this.ENTRY_SELECT_NONE; + if (this._subtool === this.SUBTOOL_NONE){ + if (this._entryEditMode === this.ENTRY_SELECT_PATH){ + this._entryEditMode = this.ENTRY_SELECT_NONE; + } } - this._subtool = this.SUBTOOL_NONE; } else { this._selectedSubpath.setCanvas(null); } @@ -274,7 +275,7 @@ exports.PenTool = Montage.create(ShapeTool, { value: function (event) { //ignore any right or middle clicks if (event.button !== 0) { - //NOTE: this will work on Webkit only...IE has different codes (left: 1, middle: 4, right: 2) + //todo NOTE: this will work on Webkit only...IE has different codes (left: 1, middle: 4, right: 2) return; } @@ -448,22 +449,24 @@ exports.PenTool = Montage.create(ShapeTool, { } //if we hit the prev handle - else if (whichPoint & this._selectedSubpath.SEL_PREV){ + else if (whichPoint & this._selectedSubpath.SEL_PREV && this._subtool===this.SUBTOOL_NONE){ this._editMode = this.EDIT_PREV; } //if we hit the next handle - else if (whichPoint & this._selectedSubpath.SEL_NEXT){ + else if (whichPoint & this._selectedSubpath.SEL_NEXT && this._subtool===this.SUBTOOL_NONE){ this._editMode = this.EDIT_NEXT; } //if no anchor or handles else if (whichPoint & this._selectedSubpath.SEL_PATH) { //the click point is close enough to insert point in bezier segment after selected anchor at selParam - if (selParam > 0 && selParam < 1) { + if ((selParam > 0 && selParam < 1) && this._subtool!==this.SUBTOOL_PENMINUS) { this._selectedSubpath.insertAnchorAtParameter(this._selectedSubpath.getSelectedAnchorIndex(), selParam); //set the mode so that dragging will update anchor point positions //this._editMode = this.EDIT_ANCHOR; + } else { + this._selectedSubpath.deselectAnchorPoint(); //set that no anchor is selected since the path was not hit anywhere useful } } @@ -473,7 +476,10 @@ exports.PenTool = Montage.create(ShapeTool, { else { //add an anchor point to end of the open selected subpath (in local space), and make it the selected anchor point // ONLY if we were not in SELECT_PATH entry mode or we are in SELECT_PATH entry mode and we have picked one of the endpoints - if (this._entryEditMode !== this.ENTRY_SELECT_PATH || (this._entryEditMode === this.ENTRY_SELECT_PATH && this._isPickedEndPointInSelectPathMode)) { + if (this._subtool===this.SUBTOOL_NONE && + (this._entryEditMode !== this.ENTRY_SELECT_PATH || + (this._entryEditMode === this.ENTRY_SELECT_PATH && this._isPickedEndPointInSelectPathMode)) + ) { if (!this._selectedSubpath.getIsClosed()) { //todo this test is probably unnecessary, but doing it to be safe this._selectedSubpath.addAnchor(new AnchorPoint()); var newAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()); @@ -513,16 +519,21 @@ exports.PenTool = Montage.create(ShapeTool, { } //set the cursor to be the default cursor (depending on whether the selected subpath has any points yet) - if (this._selectedSubpath && this._selectedSubpath.getNumAnchors()>0){ - this.application.ninja.stage.drawingCanvas.style.cursor = //"auto"; - "url('images/cursors/penCursors/Pen_.png') 5 1, default"; - } - else { + if (this._subtool===this.SUBTOOL_NONE){ + if (this._selectedSubpath && this._selectedSubpath.getNumAnchors()>0){ + this.application.ninja.stage.drawingCanvas.style.cursor = //"auto"; + "url('images/cursors/penCursors/Pen_.png') 5 1, default"; + } + else { + this.application.ninja.stage.drawingCanvas.style.cursor = //"auto"; + "url('images/cursors/penCursors/Pen_newPath.png') 5 1, default"; + } + } else { + //use the standard pen cursor for Pen Plus and Pen Minus this.application.ninja.stage.drawingCanvas.style.cursor = //"auto"; - "url('images/cursors/penCursors/Pen_newPath.png') 5 1, default"; + "url('images/cursors/penCursors/Pen_.png') 5 1, default"; } - if (!this._selectedSubpath ){ return; //nothing to do in case no subpath is selected } @@ -625,7 +636,7 @@ exports.PenTool = Montage.create(ShapeTool, { cursor = "url('images/cursors/penCursors/Pen_closePath.png') 5 1, default"; } } //if path is not closed - } else if (this._subtool === this.SUBTOOL_PENMINUS){ + } else if (this._subtool === this.SUBTOOL_PENMINUS && selAnchorAndParamAndCode[2] & this._selectedSubpath.SEL_ANCHOR){ cursor = "url('images/cursors/penCursors/Pen_minus.png') 5 1, default"; } this.application.ninja.stage.drawingCanvas.style.cursor = cursor; -- cgit v1.2.3 From 209ad51fc6efd86d1f472a1814a98fee7e75bb6c Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Wed, 30 May 2012 09:49:57 -0700 Subject: working version of the pen plus subtool --- js/tools/PenTool.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'js/tools') diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index 2974d37b..0532bdb3 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js @@ -418,6 +418,10 @@ exports.PenTool = Montage.create(ShapeTool, { this._removeSelectedAnchorPoint(); return; } + if (this._subtool === this.SUBTOOL_PENPLUS){ + //nothing to do for the pen plus subtool + return; + } //if we're in ENTRY_SELECT_PATH mode AND we have not yet clicked on the endpoint AND if we have now clicked on the endpoint if (this._entryEditMode === this.ENTRY_SELECT_PATH && this._isPickedEndPointInSelectPathMode === false){ var selAnchorIndex = this._selectedSubpath.getSelectedAnchorIndex(); -- cgit v1.2.3 From 0a7357bad4e646177b0420848844f503e0b64161 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Thu, 31 May 2012 14:34:21 -0700 Subject: somewhat working version of the canvas runtime for pen paths (the runtime renders properly if we go through debugger)...also removed calls to getStageElement from pen tool --- js/tools/PenTool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/tools') diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index 0532bdb3..bb163202 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js @@ -337,7 +337,7 @@ exports.PenTool = Montage.create(ShapeTool, { var hitRec = this.getHitRecord(event.pageX, event.pageY, false); var globalMousePos=null, localMousePos=null, stageWorldMousePos = null, drawingCanvas=null; if (!this._selectedSubpathCanvas){ - drawingCanvas = ViewUtils.getStageElement(); + drawingCanvas = this.application.ninja.currentDocument.model.documentRoot;//ViewUtils.getStageElement(); stageWorldMousePos = hitRec.calculateStageWorldPoint(); stageWorldMousePos[0]+= snapManager.getStageWidth()*0.5; stageWorldMousePos[1]+= snapManager.getStageHeight()*0.5; @@ -550,7 +550,7 @@ exports.PenTool = Montage.create(ShapeTool, { var globalMousePos=null, localMousePos=null, stageWorldMousePos = null; var drawingCanvas = this._selectedSubpath.getCanvas(); if (!drawingCanvas){ - drawingCanvas = ViewUtils.getStageElement(); + drawingCanvas = this.application.ninja.currentDocument.model.documentRoot; //ViewUtils.getStageElement(); stageWorldMousePos = hitRec.calculateStageWorldPoint(); stageWorldMousePos[0]+= snapManager.getStageWidth()*0.5; stageWorldMousePos[1]+= snapManager.getStageHeight()*0.5; -- cgit v1.2.3 From 06b609df1ff7833592faddbd8d7abb5b9f15a74d Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Thu, 31 May 2012 17:09:37 -0700 Subject: change the behavior of what happens when alt is pressed while moving anchor handles (the behavior now matches the design) --- js/tools/PenTool.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'js/tools') diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index bb163202..1536a334 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js @@ -577,8 +577,8 @@ exports.PenTool = Montage.create(ShapeTool, { localTranslation = VecUtils.vecSubtract(3, localMousePos, selAnchorPos[0]); selAnchor.translatePrev(localTranslation[0], localTranslation[1], localTranslation[2]); if (!this._isAltDown){ - //selAnchor.translateNextFromPrev(localTranslation[0], localTranslation[1], localTranslatio