diff options
author | Valerio Virgillito | 2012-07-09 14:35:44 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-07-09 14:35:44 -0700 |
commit | 84b3327bd92faafab7954b5eb64c7abe24a3fe13 (patch) | |
tree | 3f56cbed2f08c5a81ea79eaf0bcb9bd031d8a627 /js/tools/PenTool.js | |
parent | c0a42c56f768a873ba637f5b86d5f6a84d4a3312 (diff) | |
parent | 40c6eb2c06b34f65a74d59ef9687251952858bab (diff) | |
download | ninja-84b3327bd92faafab7954b5eb64c7abe24a3fe13.tar.gz |
Merge branch 'normalize' of https://github.com/kriskowal/ninja-internal
Conflicts:
js/components/gradientpicker.reel/gradientpicker.js
js/components/tools-properties/text-properties.reel/text-properties.js
js/document/views/base.js
js/document/views/design.js
js/helper-classes/3D/StageLine.js
js/helper-classes/3D/draw-utils.js
js/lib/drawing/world.js
js/lib/geom/circle.js
js/lib/geom/line.js
js/lib/geom/rectangle.js
js/lib/geom/shape-primitive.js
js/lib/rdge/materials/bump-metal-material.js
js/lib/rdge/materials/flag-material.js
js/lib/rdge/materials/fly-material.js
js/lib/rdge/materials/julia-material.js
js/lib/rdge/materials/keleidoscope-material.js
js/lib/rdge/materials/mandel-material.js
js/lib/rdge/materials/material.js
js/lib/rdge/materials/plasma-material.js
js/lib/rdge/materials/pulse-material.js
js/lib/rdge/materials/radial-gradient-material.js
js/lib/rdge/materials/taper-material.js
js/lib/rdge/materials/twist-vert-material.js
js/lib/rdge/materials/water-material.js
js/panels/Materials/materials-library-panel.reel/materials-library-panel.html
js/panels/Materials/materials-library-panel.reel/materials-library-panel.js
js/panels/Materials/materials-popup.reel/materials-popup.html
js/panels/Materials/materials-popup.reel/materials-popup.js
js/tools/LineTool.js
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/tools/PenTool.js')
-rwxr-xr-x | js/tools/PenTool.js | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index 25423f76..7e07680d 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js | |||
@@ -29,7 +29,7 @@ POSSIBILITY OF SUCH DAMAGE. | |||
29 | </copyright> */ | 29 | </copyright> */ |
30 | 30 | ||
31 | var ShapeTool = require("js/tools/ShapeTool").ShapeTool; | 31 | var ShapeTool = require("js/tools/ShapeTool").ShapeTool; |
32 | var ShapesController = require("js/controllers/elements/shapes-controller").ShapesController; | 32 | var ShapesController = require("js/controllers/elements/shapes-controller").ShapesController; |
33 | var DrawingToolBase = require("js/tools/drawing-tool-base").DrawingToolBase; | 33 | var DrawingToolBase = require("js/tools/drawing-tool-base").DrawingToolBase; |
34 | var defaultEventManager = require("montage/core/event/event-manager").defaultEventManager; | 34 | var defaultEventManager = require("montage/core/event/event-manager").defaultEventManager; |
35 | var Montage = require("montage/core/core").Montage; | 35 | var Montage = require("montage/core/core").Montage; |
@@ -148,7 +148,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
148 | var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(x,y)); | 148 | var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(x,y)); |
149 | var pos; | 149 | var pos; |
150 | if (getStageWorld){ | 150 | if (getStageWorld){ |
151 | pos = (snapManager.snap(point.x, point.y, false)).calculateStageWorldPoint(); | 151 | pos = (snapManager.snap(point.x, point.y, false)).calculateStageWorldPoint(); |
152 | } else { | 152 | } else { |
153 | pos = (snapManager.snap(point.x, point.y, false)).getScreenPoint(); | 153 | pos = (snapManager.snap(point.x, point.y, false)).getScreenPoint(); |
154 | } | 154 | } |
@@ -306,7 +306,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
306 | //todo NOTE: this will work on Webkit only...IE has different codes (left: 1, middle: 4, right: 2) | 306 | //todo NOTE: this will work on Webkit only...IE has different codes (left: 1, middle: 4, right: 2) |
307 | return; | 307 | return; |
308 | } | 308 | } |
309 | 309 | ||
310 | //set the drawing flags (see the drawing-tool.js base class) | 310 | //set the drawing flags (see the drawing-tool.js base class) |
311 | if (this._canDraw) { | 311 | if (this._canDraw) { |
312 | this._isDrawing = true; | 312 | this._isDrawing = true; |
@@ -423,7 +423,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
423 | console.log("WARNING picked anchor point with incorrect mode"); | 423 | console.log("WARNING picked anchor point with incorrect mode"); |
424 | break; | 424 | break; |
425 | } | 425 | } |
426 | 426 | ||
427 | } else { | 427 | } else { |
428 | this._selectedSubpath.addAnchor(new AnchorPoint()); | 428 | this._selectedSubpath.addAnchor(new AnchorPoint()); |
429 | var newAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()); | 429 | var newAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()); |
@@ -568,7 +568,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
568 | //NOTE: this will work on Webkit only...IE has different codes (left: 1, middle: 4, right: 2) | 568 | //NOTE: this will work on Webkit only...IE has different codes (left: 1, middle: 4, right: 2) |
569 | return; | 569 | return; |
570 | } | 570 | } |
571 | 571 | ||
572 | //set the cursor to be the default cursor (depending on whether the selected subpath has any points yet) | 572 | //set the cursor to be the default cursor (depending on whether the selected subpath has any points yet) |
573 | if (this._subtool===this.SUBTOOL_NONE){ | 573 | if (this._subtool===this.SUBTOOL_NONE){ |
574 | if ((this._selectedSubpath && this._selectedSubpath.getNumAnchors()>0 && !this._selectedSubpath.getIsClosed()) | 574 | if ((this._selectedSubpath && this._selectedSubpath.getNumAnchors()>0 && !this._selectedSubpath.getIsClosed()) |
@@ -618,7 +618,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
618 | var selAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()); | 618 | var selAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()); |
619 | var selAnchorPos = selAnchor.getAllPos(); | 619 | var selAnchorPos = selAnchor.getAllPos(); |
620 | var localTranslation = VecUtils.vecSubtract(3, localMousePos, selAnchorPos[1]); | 620 | var localTranslation = VecUtils.vecSubtract(3, localMousePos, selAnchorPos[1]); |
621 | 621 | ||
622 | if (this._editMode & this.EDIT_ANCHOR) { | 622 | if (this._editMode & this.EDIT_ANCHOR) { |
623 | selAnchor.translateAll(localTranslation[0], localTranslation[1], localTranslation[2]); | 623 | selAnchor.translateAll(localTranslation[0], localTranslation[1], localTranslation[2]); |
624 | } | 624 | } |
@@ -691,7 +691,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
691 | } //if path is not closed | 691 | } //if path is not closed |
692 | } else if (this._subtool === this.SUBTOOL_PENMINUS && selAnchorAndParamAndCode[2] & this._selectedSubpath.SEL_ANCHOR){ | 692 | } else if (this._subtool === this.SUBTOOL_PENMINUS && selAnchorAndParamAndCode[2] & this._selectedSubpath.SEL_ANCHOR){ |
693 | cursor = "url('images/cursors/penCursors/Pen_minus.png') 5 1, default"; | 693 | cursor = "url('images/cursors/penCursors/Pen_minus.png') 5 1, default"; |
694 | } | 694 | } |
695 | this.application.ninja.stage.drawingCanvas.style.cursor = cursor; | 695 | this.application.ninja.stage.drawingCanvas.style.cursor = cursor; |
696 | } else if (selAnchorAndParamAndCode[2] & this._selectedSubpath.SEL_PATH) { | 696 | } else if (selAnchorAndParamAndCode[2] & this._selectedSubpath.SEL_PATH) { |
697 | //change the cursor only if we're not in pen-minus subtool | 697 | //change the cursor only if we're not in pen-minus subtool |
@@ -825,7 +825,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
825 | //TODO this will not work if there are multiple shapes in the same canvas | 825 | //TODO this will not work if there are multiple shapes in the same canvas |
826 | canvas.elementModel.shapeModel.GLGeomObj = subpath; | 826 | canvas.elementModel.shapeModel.GLGeomObj = subpath; |
827 | 827 | ||
828 | if(canvas.elementModel.isShape) | 828 | if(canvas.elementModel.isShape) |
829 | { | 829 | { |
830 | this._doesSelectionChangeNeedHandling = false; //this will ignore the selection change event triggered by the canvas | 830 | this._doesSelectionChangeNeedHandling = false; //this will ignore the selection change event triggered by the canvas |
831 | this.application.ninja.selectionController.selectElement(canvas); | 831 | this.application.ninja.selectionController.selectElement(canvas); |
@@ -841,7 +841,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
841 | // Check if the selected anchor point of the selected subpath should be snapped to another anchor point | 841 | // Check if the selected anchor point of the selected subpath should be snapped to another anchor point |
842 | // (also sets open subpaths closed if appropriate) | 842 | // (also sets open subpaths closed if appropriate) |
843 | // IF the selected subpath does not have a canvas | 843 | // IF the selected subpath does not have a canvas |
844 | // | 844 | // |
845 | // Draw the selected subpath anchors and the selected subpath itself in the stage's context | 845 | // Draw the selected subpath anchors and the selected subpath itself in the stage's context |
846 | // ********************************************************************************************************** | 846 | // ********************************************************************************************************** |
847 | HandleLeftButtonUp: { | 847 | HandleLeftButtonUp: { |
@@ -851,7 +851,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
851 | if (this._subtool===this.SUBTOOL_PENMINUS){ | 851 | if (this._subtool===this.SUBTOOL_PENMINUS){ |
852 | return; | 852 | return; |
853 | } | 853 | } |
854 | 854 | ||
855 | // ******************** snapping *********************** | 855 | // ******************** snapping *********************** |
856 | // if there was a snapTarget and a selected anchor, move the anchor to the snap target | 856 | // if there was a snapTarget and a selected anchor, move the anchor to the snap target |
857 | if (this._snapTargetIndex !== -1 && this._selectedSubpath && this._selectedSubpath.getSelectedAnchorIndex() !== -1) { | 857 | if (this._snapTargetIndex !== -1 && this._selectedSubpath && this._selectedSubpath.getSelectedAnchorIndex() !== -1) { |
@@ -903,7 +903,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
903 | //if (this._selectedSubpath && this._selectedSubpath.getIsClosed() && this._entryEditMode !== this.ENTRY_SELECT_PATH){ | 903 | //if (this._selectedSubpath && this._selectedSubpath.getIsClosed() && this._entryEditMode !== this.ENTRY_SELECT_PATH){ |
904 | // this._selectedSubpath = null; | 904 | // this._selectedSubpath = null; |
905 | //} | 905 | //} |
906 | 906 | ||
907 | if (this._selectedSubpath){ | 907 | if (this._selectedSubpath){ |
908 | this.DrawSubpathAnchors(this._selectedSubpath);//render the subpath anchors on canvas | 908 | this.DrawSubpathAnchors(this._selectedSubpath);//render the subpath anchors on canvas |
909 | }else{ | 909 | }else{ |
@@ -937,7 +937,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
937 | return;//nothing to do | 937 | return;//nothing to do |
938 | } | 938 | } |
939 | this._selectedSubpath.makeDirty(); | 939 | this._selectedSubpath.makeDirty(); |
940 | 940 | ||
941 | var bboxMin=null, bboxMax=null; | 941 | var bboxMin=null, bboxMax=null; |
942 | if (this._selectedSubpathCanvas) { | 942 | if (this._selectedSubpathCanvas) { |
943 | //if there already is a subpath canvas, it means the anchor points are in local space | 943 | //if there already is a subpath canvas, it means the anchor points are in local space |
@@ -980,7 +980,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
980 | glmat4.multiply( newMat, tMat, newMat); | 980 | glmat4.multiply( newMat, tMat, newMat); |
981 | this._selectedSubpathPlaneMat = newMat; | 981 | this._selectedSubpathPlaneMat = newMat; |
982 | ViewUtils.setMatrixForElement(this._selectedSubpathCanvas, newMat, true); | 982 | ViewUtils.setMatrixForElement(this._selectedSubpathCanvas, newMat, true); |
983 | 983 | ||
984 | //now set the center of the canvas as the center of the bounding box expressed in stage world coordinates | 984 | //now set the center of the canvas as the center of the bounding box expressed in stage world coordinates |
985 | var localToStageWorldMat = ViewUtils.getLocalToStageWorldMatrix(this._selectedSubpathCanvas, false, false); | 985 | var localToStageWorldMat = ViewUtils.getLocalToStageWorldMatrix(this._selectedSubpathCanvas, false, false); |
986 | this._selectedSubpathCanvasCenter = MathUtils.transformAndDivideHomogeneousPoint(bboxMid, localToStageWorldMat); | 986 | this._selectedSubpathCanvasCenter = MathUtils.transformAndDivideHomogeneousPoint(bboxMid, localToStageWorldMat); |
@@ -1009,7 +1009,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
1009 | currAnchor.setNextPos(localNext[0],localNext[1],localNext[2]); | 1009 | currAnchor.setNextPos(localNext[0],localNext[1],localNext[2]); |
1010 | } | 1010 | } |
1011 | } | 1011 | } |
1012 | 1012 | ||
1013 | this._selectedSubpath.makeDirty(); | 1013 | this._selectedSubpath.makeDirty(); |
1014 | this._selectedSubpath.createSamples(false); | 1014 | this._selectedSubpath.createSamples(false); |
1015 | this._selectedSubpath.offsetPerBBoxMin(); | 1015 | this._selectedSubpath.offsetPerBBoxMin(); |
@@ -1104,10 +1104,10 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
1104 | handleScroll: { | 1104 | handleScroll: { |
1105 | value: function(event) { | 1105 | value: function(event) { |
1106 | this.application.ninja.stage.clearDrawingCanvas();//stageManagerModule.stageManager.clearDrawingCanvas(); | 1106 | this.application.ninja.stage.clearDrawingCanvas();//stageManagerModule.stageManager.clearDrawingCanvas(); |
1107 | this.DrawSubpathAnchors(this._selectedSubpath); | 1107 | this.DrawSubpathAnchors(this._selectedSubpath); |
1108 | } | 1108 | } |
1109 | }, | 1109 | }, |
1110 | 1110 | ||
1111 | BuildSecondCtrlPoint:{ | 1111 | BuildSecondCtrlPoint:{ |
1112 | value: function(p0, p2, p3) { | 1112 | value: function(p0, p2, p3) { |
1113 | var baselineOrig = VecUtils.vecSubtract(3, p3, p0); | 1113 | var baselineOrig = VecUtils.vecSubtract(3, p3, p0); |
@@ -1199,7 +1199,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
1199 | this.application.ninja.stage.clearDrawingCanvas();//stageManagerModule.stageManager.clearDrawingCanvas(); | 1199 | this.application.ninja.stage.clearDrawingCanvas();//stageManagerModule.stageManager.clearDrawingCanvas(); |
1200 | 1200 | ||
1201 | this.DrawSubpathAnchors(this._selectedSubpath); | 1201 | this.DrawSubpathAnchors(this._selectedSubpath); |
1202 | } //if (this._selectedSubpath && this._selectedSubpath.getSelectedAnchorIndex() !== -1) | 1202 | } //if (this._selectedSubpath && this._selectedSubpath.getSelectedAnchorIndex() !== -1) |
1203 | 1203 | ||
1204 | } //value: function () { | 1204 | } //value: function () { |
1205 | }, //HandleDoubleClick: { | 1205 | }, //HandleDoubleClick: { |
@@ -1503,7 +1503,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
1503 | /*if (this.application.ninja.selectedElements.length === 0){ | 1503 | /*if (this.application.ninja.selectedElements.length === 0){ |
1504 | this._entryEditMode = this.ENTRY_SELECT_NONE; | 1504 | this._entryEditMode = this.ENTRY_SELECT_NONE; |
1505 | } | 1505 | } |
1506 | 1506 | ||
1507 | else{ | 1507 | else{ |
1508 | for (var i=0;i<this.application.ninja.selectedElements.length;i++){ | 1508 | for (var i=0;i<this.application.ninja.selectedElements.length;i++){ |
1509 | var element = this.application.ninja.selectedElements[i]; | 1509 | var element = this.application.ninja.selectedElements[i]; |
@@ -1549,7 +1549,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
1549 | 1549 | ||
1550 | this.handlePenSubToolChange(); | 1550 | this.handlePenSubToolChange(); |
1551 | //this._subtool = this.SUBTOOL_NONE; //this.SUBTOOL_PENMINUS; | 1551 | //this._subtool = this.SUBTOOL_NONE; //this.SUBTOOL_PENMINUS; |
1552 | 1552 | ||
1553 | if (this._trackMouseMoveWhenUp){ | 1553 | if (this._trackMouseMoveWhenUp){ |
1554 | NJevent("enableStageMove"); | 1554 | NJevent("enableStageMove"); |
1555 | } | 1555 | } |
@@ -1558,7 +1558,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
1558 | this.eventManager.addEventListener("closeDocument", this, false); | 1558 | this.eventManager.addEventListener("closeDocument", this, false); |
1559 | this.eventManager.addEventListener("penSubToolChange", this, false); | 1559 | this.eventManager.addEventListener("penSubToolChange", this, false); |
1560 | this.eventManager.addEventListener("selectionChange", this, false); | 1560 |