From 806974142d44afdd23534bf2d18eff0a8e701e0c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 8 Jun 2012 16:59:59 -0700 Subject: rewrite: currentSelectedContainer -> domContainer Fixed the currentSelectedContainer by removing bindings and using property change on the current document added the red outline back. Signed-off-by: Valerio Virgillito --- js/tools/Rotate3DToolBase.js | 2 +- js/tools/SelectionTool.js | 4 ++-- js/tools/ShapeTool.js | 6 +++--- js/tools/TranslateObject3DTool.js | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'js/tools') diff --git a/js/tools/Rotate3DToolBase.js b/js/tools/Rotate3DToolBase.js index bf9537dd..f0fe83fa 100755 --- a/js/tools/Rotate3DToolBase.js +++ b/js/tools/Rotate3DToolBase.js @@ -98,7 +98,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { // { // hitRec = snapManager.findHitRecordForElement(elt); // } -// if(elt === this.application.ninja.currentSelectedContainer) +// if(elt === this.application.ninja.currentDocument.model.domContainer) // { // this._clickedOnStage = true; // } diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index ed92b893..493f4aa2 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js @@ -224,9 +224,9 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { HandleDoubleClick: { value: function(event) { if(this.application.ninja.selectedElements.length > 0) { - this.application.ninja.currentSelectedContainer = this.application.ninja.selectedElements[0]; + this.application.ninja.currentDocument.model.domContainer = this.application.ninja.selectedElements[0]; } else { - this.application.ninja.currentSelectedContainer = this.application.ninja.currentDocument.model.documentRoot; + this.application.ninja.currentDocument.model.domContainer = this.application.ninja.currentDocument.model.documentRoot; } } }, diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index 03ddc391..8d381711 100755 --- a/js/tools/ShapeTool.js +++ b/js/tools/ShapeTool.js @@ -103,8 +103,8 @@ exports.ShapeTool = Montage.create(DrawingTool, { if(wasSelected) { this.AddCustomFeedback(); this.application.ninja.elementMediator.addDelegate = this; - if(this.application.ninja.currentSelectedContainer.nodeName === "CANVAS") { - this._targetedElement = this.application.ninja.currentSelectedContainer; + if(this.application.ninja.currentDocument.model.domContainer.nodeName === "CANVAS") { + this._targetedElement = this.application.ninja.currentDocument.model.domContainer; } } else { this.RemoveCustomFeedback(); @@ -199,7 +199,7 @@ exports.ShapeTool = Montage.create(DrawingTool, { target = this._targetedElement; else { - var container = this.application.ninja.currentSelectedContainer; + var container = this.application.ninja.currentDocument.model.domContainer; if (container && (container.nodeName === "CANVAS")) { target = container; diff --git a/js/tools/TranslateObject3DTool.js b/js/tools/TranslateObject3DTool.js index f8b32d23..d9e558a4 100755 --- a/js/tools/TranslateObject3DTool.js +++ b/js/tools/TranslateObject3DTool.js @@ -89,7 +89,7 @@ exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, { var otherSnap = snapManager.findHitRecordForElement(elt); if (otherSnap) hitRec = otherSnap; } - if(elt === this.application.ninja.currentSelectedContainer) + if(elt === this.application.ninja.currentDocument.model.domContainer) { this._clickedOnStage = true; } -- cgit v1.2.3 From e170a58eb8905d98fcdad3d61d652dad45443019 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Tue, 12 Jun 2012 09:14:32 -0700 Subject: allow the addition of anchor points to a closed path (the mouse move cursor still needs to be updated) --- js/tools/PenTool.js | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) (limited to 'js/tools') diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index e296d0e5..52af294a 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js @@ -288,16 +288,35 @@ exports.PenTool = Montage.create(ShapeTool, { //assume we are not starting a new path as we will set this to true if we create a new Subpath() this._isNewPath = false; - - //if we had closed the selected subpath previously, or if we have not yet started anything, create a subpath - if (this._entryEditMode !== this.ENTRY_SELECT_PATH && this._selectedSubpath && this._selectedSubpath.getIsClosed() && this._makeMultipleSubpaths) { - this._selectedSubpath = null; - } if (this._subtool !== this.SUBTOOL_NONE && this._selectedSubpath===null) { //do nothing because the pen plus and pen minus subtools need a selected subpath return; } + + //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); + var globalMousePos=null, localMousePos=null, stageWorldMousePos = null, drawingCanvas=null; + if (this._selectedSubpathCanvas){ + globalMousePos = hitRec.getScreenPoint(); + localMousePos = ViewUtils.globalToLocal(globalMousePos, this._selectedSubpathCanvas); + } + + //if we have a selected subpath and canvas, check if the current click location hits the path + // todo optimize this...currently pickPath is called twice (see later in this function) + var hitPath = false; + if (this._selectedSubpath && this._selectedSubpathCanvas ) { + var tempSelAnchorAndParamAndCode = this._selectedSubpath.pickPath(localMousePos[0], localMousePos[1], localMousePos[2], this._PICK_POINT_RADIUS, true); + if (tempSelAnchorAndParamAndCode[2] !== this._selectedSubpath.SEL_NONE){ // ******* if we hit the path anywhere ********* + hitPath = true; + } + } + + //if we had closed the selected subpath previously, or if we have not yet started anything, create a subpath + if (this._entryEditMode !== this.ENTRY_SELECT_PATH && this._selectedSubpath && this._selectedSubpath.getIsClosed() && this._makeMultipleSubpaths && !hitPath) { + this._selectedSubpath = null; + } + if (this._selectedSubpath === null) { this._selectedSubpath = new SubPath(); this._selectedSubpathCanvas = null; @@ -335,9 +354,7 @@ exports.PenTool = Montage.create(ShapeTool, { this._selectedSubpath.setFillColor(colorArray); } //if the selectedSubpath was null and needed to be constructed - //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); - var globalMousePos=null, localMousePos=null, stageWorldMousePos = null, drawingCanvas=null; + //build the current mouse position in stage world space in case we don't already have a canvas if (!this._selectedSubpathCanvas){ drawingCanvas = this.application.ninja.currentDocument.model.documentRoot;//ViewUtils.getStageElement(); stageWorldMousePos = hitRec.calculateStageWorldPoint(); @@ -345,10 +362,7 @@ exports.PenTool = Montage.create(ShapeTool, { 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 @@ -358,7 +372,6 @@ exports.PenTool = Montage.create(ShapeTool, { if (this._selectedSubpath.getNumAnchors()===0) { this._selectedSubpathPlaneMat = hitRec.getPlaneMatrix(); } - //check if the mouse click location is close to the existing anchor var indexAndCode = this._selectedSubpath.pickAnchor(stageWorldMousePos[0], stageWorldMousePos[1], stageWorldMousePos[2], this._PICK_POINT_RADIUS); if (indexAndCode[0]>=0){ @@ -853,9 +866,9 @@ exports.PenTool = Montage.create(ShapeTool, { 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 - if (this._selectedSubpath && this._selectedSubpath.getIsClosed() && this._entryEditMode !== this.ENTRY_SELECT_PATH){ - this._selectedSubpath = null; - } + //if (this._selectedSubpath && this._selectedSubpath.getIsClosed() && this._entryEditMode !== this.ENTRY_SELECT_PATH){ + // this._selectedSubpath = null; + //} if (this._selectedSubpath){ this.DrawSubpathAnchors(this._selectedSubpath);//render the subpath anchors on canvas -- cgit v1.2.3 From 0dd995834865202de1c51b1b4635f6515f54b1ea Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Tue, 12 Jun 2012 09:57:13 -0700 Subject: correct mouse cursor on mousemove --- js/tools/PenTool.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'js/tools') diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index 52af294a..33ca5c71 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js @@ -539,7 +539,9 @@ 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._subtool===this.SUBTOOL_NONE){ - if (this._selectedSubpath && this._selectedSubpath.getNumAnchors()>0){ + if ((this._selectedSubpath && this._selectedSubpath.getNumAnchors()>0 && !this._selectedSubpath.getIsClosed()) + || + this._entryEditMode === this.ENTRY_SELECT_PATH){ this.application.ninja.stage.drawingCanvas.style.cursor = //"auto"; "url('images/cursors/penCursors/Pen_.png') 5 1, default"; } -- cgit v1.2.3 From a75947d69f571d723552f926f94d195514a01cbd Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 12 Jun 2012 23:04:07 -0700 Subject: fixed document switching issues Signed-off-by: Valerio Virgillito --- js/tools/SelectionTool.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/tools') diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index 493f4aa2..8b644d4a 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js @@ -228,6 +228,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { } else { this.application.ninja.currentDocument.model.domContainer = this.application.ninja.currentDocument.model.documentRoot; } + this.application.ninja.selectionController.executeSelectElement(); } }, -- cgit v1.2.3 From 75df16b937bb420e7d93a411e73f7b59578b1b7e Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Wed, 13 Jun 2012 13:41:12 -0700 Subject: fix bug #1718 (trying to delete a non-existent canvas) --- js/tools/PenTool.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'js/tools') diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index 33ca5c71..2cffb44d 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js @@ -204,10 +204,12 @@ exports.PenTool = Montage.create(ShapeTool, { this.application.ninja.stage.clearDrawingCanvas();//stageManagerModule.stageManager.clearDrawingCanvas(); //undo/redo...go through ElementController and NJEvent - var els = []; - ElementController.removeElement(this._selectedSubpathCanvas); - els.push(this._selectedSubpathCanvas); - NJevent( "elementsRemoved", els ); + if (this._selectedSubpathCanvas) { + var els = []; + ElementController.removeElement(this._selectedSubpathCanvas); + els.push(this._selectedSubpathCanvas); + NJevent( "elementsRemoved", els ); + } this._selectedSubpathCanvas = null; } }, -- cgit v1.2.3 From fbd9d2492aeaef392ad59792825b8757d6c363fc Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 15 Jun 2012 15:14:34 -0700 Subject: Fixing apply 'no color' This should fix canvas and standard DOM elements including the root (body or template wrapper). --- js/tools/EyedropperTool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/tools') diff --git a/js/tools/EyedropperTool.js b/js/tools/EyedropperTool.js index 6a56004d..30a6a48b 100755 --- a/js/tools/EyedropperTool.js +++ b/js/tools/EyedropperTool.js @@ -240,7 +240,7 @@ exports.EyedropperTool = Montage.create(toolBase, { else { this.application.ninja.colorController.colorModel.alpha = {value: 1, wasSetByCode: true, type: eventType}; - this.application.ninja.colorController.colorModel.applyNoColor(); + this.application.ninja.colorController.colorModel.applyNoColor(true); if(updateColorToolBar) { this._previousColor = "none"; -- cgit v1.2.3