diff options
author | Jose Antonio Marquez | 2012-04-26 11:43:00 -0700 |
---|---|---|
committer | Jose Antonio Marquez | 2012-04-26 11:43:00 -0700 |
commit | 820d3eae09df1871f5abc295e7e659e8cc6b7ee3 (patch) | |
tree | c27588b9db2d61826e85b53f2ed4d352337e2a59 /js/tools | |
parent | 4c15e77bdb7f4e0558f3749994a8a37b207b97ae (diff) | |
parent | 902dc18296fc78f3b8e67d952c42981d926bb2fc (diff) | |
download | ninja-820d3eae09df1871f5abc295e7e659e8cc6b7ee3.tar.gz |
Merge branch 'refs/heads/Ninja-Internal' into Document
Diffstat (limited to 'js/tools')
-rw-r--r-- | js/tools/BrushTool.js | 1 | ||||
-rwxr-xr-x | js/tools/InkBottleTool.js | 22 | ||||
-rwxr-xr-x | js/tools/PenTool.js | 1256 | ||||
-rwxr-xr-x | js/tools/ToolBase.js | 12 | ||||
-rwxr-xr-x | js/tools/drawing-tool-base.js | 2 |
5 files changed, 802 insertions, 491 deletions
diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js index 4347658a..6cd6858c 100644 --- a/js/tools/BrushTool.js +++ b/js/tools/BrushTool.js | |||
@@ -134,7 +134,6 @@ exports.BrushTool = Montage.create(ShapeTool, { | |||
134 | snapManager.enableSnapAlign(false); | 134 | snapManager.enableSnapAlign(false); |
135 | 135 | ||
136 | var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(x,y)); | 136 | var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(x,y)); |
137 | //todo fix this function to allow us to get the correct location (in 3D) for the mouse position | ||
138 | var unsnappedpos = DrawingToolBase.getHitRecPos(snapManager.snap(point.x, point.y, false)); | 137 | var unsnappedpos = DrawingToolBase.getHitRecPos(snapManager.snap(point.x, point.y, false)); |
139 | this._draggingPlane = snapManager.getDragPlane(); | 138 | this._draggingPlane = snapManager.getDragPlane(); |
140 | 139 | ||
diff --git a/js/tools/InkBottleTool.js b/js/tools/InkBottleTool.js index 95c2e71d..960c19fa 100755 --- a/js/tools/InkBottleTool.js +++ b/js/tools/InkBottleTool.js | |||
@@ -84,14 +84,22 @@ exports.InkBottleTool = Montage.create(ModifierToolBase, { | |||
84 | }; | 84 | }; |
85 | } | 85 | } |
86 | 86 | ||
87 | colorInfo.borderInfo = { borderStyle:this.options._borderStyle.value, | 87 | if(this.options.useBorderWidth.checked || this.options.useBorderStyle.checked) { |
88 | borderWidth:this.options._borderWidth.value, | 88 | colorInfo.borderInfo = {}; |
89 | borderUnits:this.options._borderWidth.units | 89 | if(this.options.useBorderWidth.checked) { |
90 | }; | 90 | colorInfo.borderInfo.borderWidth = this.options._borderWidth.value; |
91 | colorInfo.borderInfo.borderUnits = this.options._borderWidth.units; | ||
92 | } | ||
93 | if(this.options.useBorderStyle.checked) { | ||
94 | colorInfo.borderInfo.borderStyle = this.options._borderStyle.value; | ||
95 | } | ||
96 | } | ||
91 | 97 | ||
92 | colorInfo.strokeInfo = { strokeSize:this.options._strokeSize.value, | 98 | if(this.options.useStrokeSize.checked) { |
93 | strokeUnits:this.options._strokeSize.units | 99 | colorInfo.strokeInfo = {}; |
94 | }; | 100 | colorInfo.strokeInfo.strokeSize = this.options._strokeSize.value; |
101 | colorInfo.strokeInfo.strokeUnits = this.options._strokeSize.units; | ||
102 | } | ||
95 | 103 | ||
96 | ElementsMediator.setColor(this.application.ninja.selectedElements, colorInfo, false, "Change", "inkBottleTool"); | 104 | ElementsMediator.setColor(this.application.ninja.selectedElements, colorInfo, false, "Change", "inkBottleTool"); |
97 | } | 105 | } |
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index 7fc8dd95..8ecc9f79 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js | |||
@@ -14,12 +14,10 @@ var ElementMediator = require("js/mediators/element-mediator").ElementMediator; | |||
14 | var TagTool = require("js/tools/TagTool").TagTool; | 14 | var TagTool = require("js/tools/TagTool").TagTool; |
15 | var ElementController = require("js/controllers/elements/element-controller").ElementController; | 15 | var ElementController = require("js/controllers/elements/element-controller").ElementController; |
16 | var snapManager = require("js/helper-classes/3D/snap-manager").SnapManager; | 16 | var snapManager = require("js/helper-classes/3D/snap-manager").SnapManager; |
17 | 17 | var ViewUtils = require("js/helper-classes/3D/view-utils").ViewUtils; | |
18 | var AnchorPoint = require("js/lib/geom/anchor-point").AnchorPoint; | 18 | var AnchorPoint = require("js/lib/geom/anchor-point").AnchorPoint; |
19 | var SubPath = require("js/lib/geom/sub-path").SubPath; | 19 | var SubPath = require("js/lib/geom/sub-path").SubPath; |
20 | 20 | ||
21 | //todo remove this global var | ||
22 | var g_DoPenToolMouseMove = true; | ||
23 | 21 | ||
24 | exports.PenTool = Montage.create(ShapeTool, { | 22 | exports.PenTool = Montage.create(ShapeTool, { |
25 | 23 | ||
@@ -35,14 +33,11 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
35 | _parentNode: { enumerable: false, value: null, writable: true }, | 33 | _parentNode: { enumerable: false, value: null, writable: true }, |
36 | _toolsPropertiesContainer: { enumerable: false, value: null, writable: true }, | 34 | _toolsPropertiesContainer: { enumerable: false, value: null, writable: true }, |
37 | 35 | ||
38 | // Need to keep track of current mouse position for KEY modifiers event which do not have mouse coordinates | 36 | //set this to true if you want to keep making subpaths after closing current subpath (debugging only) |
39 | _currentX: { value: 0, writable: true }, | 37 | _makeMultipleSubpaths: { value: true, writable: true }, |
40 | _currentY: { value: 0, writable: true }, | ||
41 | |||
42 | //the subpaths are what is displayed on the screen currently, with _selectedSubpath being the active one currently being edited | ||
43 | _selectedSubpath: { value: null, writable: true }, | ||
44 | _makeMultipleSubpaths: { value: true, writable: true }, //set this to true if you want to keep making subpaths after closing current subpath | ||
45 | 38 | ||
39 | //set this to false if you don't want the mouse move handler being called when the mouse is not down (debugging only) | ||
40 | _trackMouseMoveWhenUp: {value: true, writable: false}, | ||
46 | 41 | ||
47 | //whether the user has held down the Alt key | 42 | //whether the user has held down the Alt key |
48 | _isAltDown: { value: false, writable: true }, | 43 | _isAltDown: { value: false, writable: true }, |
@@ -50,29 +45,37 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
50 | //whether the user has held down the Esc key | 45 | //whether the user has held down the Esc key |
51 | _isEscapeDown: {value: false, writable: true }, | 46 | _isEscapeDown: {value: false, writable: true }, |
52 | 47 | ||
53 | //whether we have just started a new path (set true in mousedown, and set false in mouse up | 48 | //whether we have just started a new path (may set true in mousedown, and always set false in mouse up |
49 | //todo this seems to be unnecessary | ||
54 | _isNewPath: {value: false, writable: true}, | 50 | _isNewPath: {value: false, writable: true}, |
55 | 51 | ||
56 | //whether we have clicked one of the endpoints after entering the pen tool in ENTRY_SELECT_PATH edit mode | 52 | //whether we have clicked one of the endpoints after entering the pen tool in ENTRY_SELECT_PATH edit mode |
57 | _isPickedEndPointInSelectPathMode: {value: false, writable: true}, | 53 | _isPickedEndPointInSelectPathMode: {value: false, writable: true}, |
58 | 54 | ||
59 | //when the user wants to place a selected anchor point on top of another point, this is the target where the point will be placed | 55 | //when the user wants to place a selected anchor point on top of another point, this is the target where the point will be placed |
60 | _snapTarget: { value: null, writable: true }, | 56 | _snapTargetIndex: { value: -1, writable: true }, |
57 | |||
58 | //index of the anchor point that the user has hovered over | ||
59 | _hoveredAnchorIndex: {value: -1, writable: true}, | ||
61 | 60 | ||
62 | //whether or not we're using webgl for drawing | 61 | //whether or not we're using webgl for drawing (set to false until we have webgl-ready stroke and fill regions) |
63 | _useWebGL: {value: false, writable: false }, | 62 | _useWebGL: {value: false, writable: false }, |
64 | 63 | ||
65 | //the canvas created by the pen tool...this is grown or shrunk with the path (if the canvas was not already provided) | 64 | //the _selectedSubpath is the active subpath currently being edited |
66 | _penCanvas: { value: null, writable: true }, | 65 | _selectedSubpath: { value: null, writable: true }, |
67 | 66 | ||
68 | //the plane matrix for the first click...so the entire path is on the same plane | 67 | //the canvas for the selected subpath...this is grown or shrunk by the pen tool with the subpath (if the canvas was not already provided) |
69 | _penPlaneMat: { value: null, writable: true }, | 68 | _selectedSubpathCanvas: { value: null, writable: true }, |
70 | 69 | ||
71 | //index of the anchor point that the user has hovered over | 70 | //the plane matrix for the first click...so the entire path is on the same plane |
72 | _hoveredAnchorIndex: {value: -1, writable: true}, | 71 | // todo this might be unnecessary as we can get this from element mediator (but that may be slow) |
72 | _selectedSubpathPlaneMat: { value: null, writable: true }, | ||
73 | 73 | ||
74 | //constants used for picking points --- NOTE: these should be user-settable parameters | 74 | //the center of the subpath center in stageworld space |
75 | _PICK_POINT_RADIUS: { value: 10, writable: false }, | 75 | _selectedSubpathCanvasCenter: {value: null, writable: true}, |
76 | |||
77 | //constants used for picking points --- todo: these should be user-settable parameters | ||
78 | _PICK_POINT_RADIUS: { value: 4, writable: false }, | ||
76 | _DISPLAY_ANCHOR_RADIUS: { value: 5, writable: false }, | 79 | _DISPLAY_ANCHOR_RADIUS: { value: 5, writable: false }, |
77 | _DISPLAY_SELECTED_ANCHOR_RADIUS: { value: 10, writable: false }, | 80 | _DISPLAY_SELECTED_ANCHOR_RADIUS: { value: 10, writable: false }, |
78 | _DISPLAY_SELECTED_ANCHOR_PREV_RADIUS: { value: 2, writable: false }, | 81 | _DISPLAY_SELECTED_ANCHOR_PREV_RADIUS: { value: 2, writable: false }, |
@@ -86,34 +89,49 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
86 | EDIT_PREV_NEXT: { value: 8, writable: false }, | 89 | EDIT_PREV_NEXT: { value: 8, writable: false }, |
87 | _editMode: { value: this.EDIT_NONE, writable: true }, | 90 | _editMode: { value: this.EDIT_NONE, writable: true }, |
88 | 91 | ||
89 | //constants used for selection modes on entry to pen tool (mutually exclusive) | 92 | //constants used for selection modes on entry to pen tool (mutually exclusive i.e. cannot be OR-ed) |
90 | ENTRY_SELECT_NONE: { value: 0, writable: false}, | 93 | ENTRY_SELECT_NONE: { value: 0, writable: false}, |
91 | ENTRY_SELECT_CANVAS: { value: 1, writable: false}, | 94 | ENTRY_SELECT_CANVAS: { value: 1, writable: false}, |
92 | ENTRY_SELECT_PATH: { value: 2, writable: false}, | 95 | ENTRY_SELECT_PATH: { value: 2, writable: false}, |
93 | _entryEditMode: {value: this.ENTRY_SELECT_NONE, writable: true}, | 96 | _entryEditMode: {value: this.ENTRY_SELECT_NONE, writable: true}, |
94 | |||
95 | 97 | ||
98 | //constants used for limiting size of the subpath canvas | ||
99 | _MAX_CANVAS_DIMENSION: {value: 3000, writable: false}, | ||
96 | 100 | ||
97 | _getUnsnappedPosition: { | 101 | /* |
98 | value: function(x,y){ | 102 | // get the stage world position corresponding to the (x,y) mouse event position by querying the snap manager |
103 | // but temporarily turning off all snapping | ||
104 | _getMouseEventPosition : { | ||
105 | value: function(x,y, getStageWorld, doSnap){ | ||
99 | var elemSnap = snapManager.elementSnapEnabled(); | 106 | var elemSnap = snapManager.elementSnapEnabled(); |
100 | var gridSnap = snapManager.gridSnapEnabled(); | 107 | var gridSnap = snapManager.gridSnapEnabled(); |
101 | var alignSnap = snapManager.snapAlignEnabled(); | 108 | var alignSnap = snapManager.snapAlignEnabled(); |
102 | 109 | ||
103 | snapManager.enableElementSnap(false); | 110 | if (!doSnap){ |
104 | snapManager.enableGridSnap(false); | 111 | snapManager.enableElementSnap(false); |
105 | snapManager.enableSnapAlign(false); | 112 | snapManager.enableGridSnap(false); |
113 | snapManager.enableSnapAlign(false); | ||
114 | } | ||
106 | 115 | ||
107 | var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(x,y)); | 116 | var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(x,y)); |
108 | var unsnappedpos = DrawingToolBase.getHitRecPos(snapManager.snap(point.x, point.y, false)); | 117 | var pos; |
118 | if (getStageWorld){ | ||
119 | pos = (snapManager.snap(point.x, point.y, false)).calculateStageWorldPoint(); | ||
120 | } else { | ||
121 | pos = (snapManager.snap(point.x, point.y, false)).getScreenPoint(); | ||
122 | } | ||
123 | var dragPlane = snapManager.getDragPlane(); | ||
109 | 124 | ||
110 | snapManager.enableElementSnap(elemSnap); | 125 | if (!doSnap){ |
111 | snapManager.enableGridSnap(gridSnap); | 126 | snapManager.enableElementSnap(elemSnap); |
112 | snapManager.enableSnapAlign(alignSnap); | 127 | snapManager.enableGridSnap(gridSnap); |
128 | snapManager.enableSnapAlign(alignSnap); | ||
129 | } | ||
113 | 130 | ||
114 | return unsnappedpos; | 131 | return [pos, dragPlane]; |
115 | } | 132 | } |
116 | }, | 133 | }, |
134 | */ | ||
117 | 135 | ||
118 | ShowToolProperties: { | 136 | ShowToolProperties: { |
119 | value: function () { | 137 | value: function () { |
@@ -126,6 +144,61 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
126 | 144 | ||
127 | }, | 145 | }, |
128 | 146 | ||
147 | //use the snap manager to build a hit record corresponding to the screen X, Y position | ||
148 | // will use the plane of the selected path as the working plane if available, else use stage | ||
149 | getHitRecord:{ | ||
150 | value: function(x,y, doSnap){ | ||
151 | var elemSnap = snapManager.elementSnapEnabled(); | ||
152 | var gridSnap = snapManager.gridSnapEnabled(); | ||
153 |