aboutsummaryrefslogtreecommitdiff
path: root/js/tools/ShapeTool.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools/ShapeTool.js')
-rwxr-xr-xjs/tools/ShapeTool.js178
1 files changed, 89 insertions, 89 deletions
diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js
index dc082303..623cbb97 100755
--- a/js/tools/ShapeTool.js
+++ b/js/tools/ShapeTool.js
@@ -40,29 +40,29 @@ var World = require("js/lib/drawing/world").World;
40exports.ShapeTool = Montage.create(DrawingTool, { 40exports.ShapeTool = Montage.create(DrawingTool, {
41 drawingFeedback: { value: { mode: "Draw3D", type: "rectangle" } }, 41 drawingFeedback: { value: { mode: "Draw3D", type: "rectangle" } },
42 42
43 _targetedElement: { value: null, writable: true }, 43 _targetedElement: { value: null, writable: true },
44 44
45 _mouseDownHitRec: { value: null, writable: true, enumerable: true, configurable: true }, 45 _mouseDownHitRec: { value: null, writable: true, enumerable: true, configurable: true },
46 _mouseUpHitRec: { value: null, writable: true, enumerable: true, configurable: true }, 46 _mouseUpHitRec: { value: null, writable: true, enumerable: true, configurable: true },
47 47
48 _canvasCounter: {value: 0, writable: true, enumerable: true, configurable: true }, 48 _canvasCounter: {value: 0, writable: true, enumerable: true, configurable: true },
49 49
50 HandleLeftButtonDown: 50 HandleLeftButtonDown:
51 { 51 {
52 value: function (event) 52 value: function (event)
53 { 53 {
54 if(this._canDraw) { 54 if(this._canDraw) {
55 this._isDrawing = true; 55 this._isDrawing = true;
56 } 56 }
57 57
58 this.startDraw(event); 58 this.startDraw(event);
59 } 59 }
60 }, 60 },
61 61
62 HandleMouseMove: 62 HandleMouseMove:
63 { 63 {
64 value: function (event) 64 value: function (event)
65 { 65 {
66 66
67 /* TAG */ 67 /* TAG */
68 if(this.isDrawing) { 68 if(this.isDrawing) {
@@ -77,7 +77,7 @@ exports.ShapeTool = Montage.create(DrawingTool, {
77 } 77 }
78 }, 78 },
79 79
80 HandleLeftButtonUp: { 80 HandleLeftButtonUp: {
81 value: function (event) { 81 value: function (event) {
82 var canvas, w, h; 82 var canvas, w, h;
83 this.drawData = this.getDrawingData(); 83 this.drawData = this.getDrawingData();
@@ -137,67 +137,67 @@ exports.ShapeTool = Montage.create(DrawingTool, {
137 } 137 }
138 }, 138 },
139 139
140 AddCustomFeedback: { 140 AddCustomFeedback: {
141 value: function (event) { 141 value: function (event) {
142 NJevent("enableStageMove"); 142 NJevent("enableStageMove");
143 143
144 this.application.ninja.stage.stageDeps.snapManager.setupDragPlaneFromPlane( workingPlane ); 144 this.application.ninja.stage.stageDeps.snapManager.setupDragPlaneFromPlane( workingPlane );
145 } 145 }
146 }, 146 },
147 147
148 RemoveCustomFeedback: { 148 RemoveCustomFeedback: {
149 value: function (event) { 149 value: function (event) {
150 if (this._targetedElement) { 150 if (this._targetedElement) {
151 this._targetedElement.classList.remove("active-element-outline"); 151 this._targetedElement.classList.remove("active-element-outline");
152 this._targetedElement = null; 152 this._targetedElement = null;
153 } 153 }
154 154
155 NJevent("disableStageMove"); 155 NJevent("disableStageMove");
156 156
157 this.application.ninja.stage.stageDeps.snapManager.clearDragPlane(); 157 this.application.ninja.stage.stageDeps.snapManager.clearDragPlane();
158 } 158 }
159 }, 159 },
160 160
161 /** Show a border when mousing 161 /** Show a border when mousing
162 * over existing canvas elements to signal to the user that 162 * over existing canvas elements to signal to the user that
163 * the drawing operation will act on the targeted canvas. 163 * the drawing operation will act on the targeted canvas.
164 **/ 164 **/
165 _showFeedbackOnMouseMove: { 165 _showFeedbackOnMouseMove: {
166 value: function (event) { 166 value: function (event) {
167 // TODO - This call is causing the canvas to redraw 3 times per mouse move 167 // TODO - This call is causing the canvas to redraw 3 times per mouse move
168 var targetedObject = this.application.ninja.stage.getElement(event, true); 168 var targetedObject = this.application.ninja.stage.getElement(event, true);
169 169
170 if (targetedObject) { 170 if (targetedObject) {
171 if((targetedObject.nodeName === "CANVAS") && !ShapesController.isElementAShape(targetedObject)) 171 if((targetedObject.nodeName === "CANVAS") && !ShapesController.isElementAShape(targetedObject))
172 { 172 {
173 if (targetedObject !== this._targetedElement) { 173 if (targetedObject !== this._targetedElement) {
174 if(this._targetedElement) 174 if(this._targetedElement)
175 { 175 {
176 this._targetedElement.classList.remove("active-element-outline"); 176 this._targetedElement.classList.remove("active-element-outline");
177 } 177 }
178 this._targetedElement = targetedObject; 178 this._targetedElement = targetedObject;
179 this._targetedElement.classList.add("active-element-outline"); 179 this._targetedElement.classList.add("active-element-outline");
180 } 180 }
181 } 181 }
182 else if (this._targetedElement) { 182 else if (this._targetedElement) {
183 this._targetedElement.classList.remove("active-element-outline"); 183 this._targetedElement.classList.remove("active-element-outline");
184 this._targetedElement = null; 184 this._targetedElement = null;
185 } 185 }
186 } 186 }
187 else if (this._targetedElement) { 187 else if (this._targetedElement) {
188 this._targetedElement.classList.remove("elem-red-outline"); 188 this._targetedElement.classList.remove("elem-red-outline");
189 this._targetedElement = null; 189 this._targetedElement = null;
190 } 190 }
191 } 191 }
192 }, 192 },
193 193
194 RenderShape: 194 RenderShape:
195 { 195 {
196 value: function (w, h, planeMat, midPt) 196 value: function (w, h, planeMat, midPt)
197 { 197 {
198 // Override in subclasses 198 // Override in subclasses
199 } 199 }
200 }, 200 },
201 201
202 getGLWorld: { 202 getGLWorld: {
203 value: function (canvas, use3D) 203 value: function (canvas, use3D)
@@ -214,26 +214,26 @@ exports.ShapeTool = Montage.create(DrawingTool, {
214 } 214 }
215 }, 215 },
216 216
217 // We can draw on an existing canvas unless it has only a single shape object 217 // We can draw on an existing canvas unless it has only a single shape object
218 _useExistingCanvas: { 218 _useExistingCanvas: {
219 value: function() 219 value: function()
220 { 220 {
221 var target; 221 var target;
222 if (this._targetedElement && (this._targetedElement.nodeName === "CANVAS") && !ShapesController.isElementAShape(this._targetedElement)) 222 if (this._targetedElement && (this._targetedElement.nodeName === "CANVAS") && !ShapesController.isElementAShape(this._targetedElement))
223 target = this._targetedElement; 223 target = this._targetedElement;
224 else 224 else
225 { 225 {
226 var container = this.application.ninja.currentDocument.model.domContainer; 226 var container = this.application.ninja.currentDocument.model.domContainer;
227 if (container && (container.nodeName === "CANVAS")) 227 if (container && (container.nodeName === "CANVAS"))
228 { 228 {
229 target = container; 229 target = container;
230 this._targetedElement = target; 230 this._targetedElement = target;
231 } 231 }
232 } 232 }
233 233
234 return target; 234 return target;
235 } 235 }
236 }, 236 },
237 237
238 setColor: { 238 setColor: {
239 value: function(canvas, color, isFill, toolId) 239 value: function(canvas, color, isFill, toolId)