diff options
author | Eric Guzman | 2012-06-19 01:20:36 -0700 |
---|---|---|
committer | Eric Guzman | 2012-06-19 01:20:36 -0700 |
commit | 2ef72cdf0e59fb3623a2c13251ac707522f3dc5a (patch) | |
tree | f69f4e3de7e4441311ef2b38770e0ce26067aac4 /js/tools | |
parent | 5260d3dfd99d79924c4aaa3ab798e90c7d328d7d (diff) | |
parent | 1007cbf983ad0f2460a4122a492a96023fdb4439 (diff) | |
download | ninja-2ef72cdf0e59fb3623a2c13251ac707522f3dc5a.tar.gz |
Merge branch 'binding' of github.com:dhg637/ninja-internal into binding
Conflicts:
js/stage/binding-view.reel/binding-view.js
Diffstat (limited to 'js/tools')
-rwxr-xr-x | js/tools/EyedropperTool.js | 2 | ||||
-rwxr-xr-x | js/tools/PenTool.js | 59 | ||||
-rwxr-xr-x | js/tools/Rotate3DToolBase.js | 2 | ||||
-rwxr-xr-x | js/tools/SelectionTool.js | 5 | ||||
-rwxr-xr-x | js/tools/ShapeTool.js | 6 | ||||
-rwxr-xr-x | js/tools/TranslateObject3DTool.js | 2 |
6 files changed, 47 insertions, 29 deletions
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, { | |||
240 | else | 240 | else |
241 | { | 241 | { |
242 | this.application.ninja.colorController.colorModel.alpha = {value: 1, wasSetByCode: true, type: eventType}; | 242 | this.application.ninja.colorController.colorModel.alpha = {value: 1, wasSetByCode: true, type: eventType}; |
243 | this.application.ninja.colorController.colorModel.applyNoColor(); | 243 | this.application.ninja.colorController.colorModel.applyNoColor(true); |
244 | if(updateColorToolBar) | 244 | if(updateColorToolBar) |
245 | { | 245 | { |
246 | this._previousColor = "none"; | 246 | this._previousColor = "none"; |
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index e296d0e5..2cffb44d 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js | |||
@@ -204,10 +204,12 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
204 | this.application.ninja.stage.clearDrawingCanvas();//stageManagerModule.stageManager.clearDrawingCanvas(); | 204 | this.application.ninja.stage.clearDrawingCanvas();//stageManagerModule.stageManager.clearDrawingCanvas(); |
205 | 205 | ||
206 | //undo/redo...go through ElementController and NJEvent | 206 | //undo/redo...go through ElementController and NJEvent |
207 | var els = []; | 207 | if (this._selectedSubpathCanvas) { |
208 | ElementController.removeElement(this._selectedSubpathCanvas); | 208 | var els = []; |
209 | els.push(this._selectedSubpathCanvas); | 209 | ElementController.removeElement(this._selectedSubpathCanvas); |
210 | NJevent( "elementsRemoved", els ); | 210 | els.push(this._selectedSubpathCanvas); |
211 | NJevent( "elementsRemoved", els ); | ||
212 | } | ||
211 | this._selectedSubpathCanvas = null; | 213 | this._selectedSubpathCanvas = null; |
212 | } | 214 | } |
213 | }, | 215 | }, |
@@ -288,16 +290,35 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
288 | 290 | ||
289 | //assume we are not starting a new path as we will set this to true if we create a new Subpath() | 291 | //assume we are not starting a new path as we will set this to true if we create a new Subpath() |
290 | this._isNewPath = false; | 292 | this._isNewPath = false; |
291 | |||
292 | //if we had closed the selected subpath previously, or if we have not yet started anything, create a subpath | ||
293 | if (this._entryEditMode !== this.ENTRY_SELECT_PATH && this._selectedSubpath && this._selectedSubpath.getIsClosed() && this._makeMultipleSubpaths) { | ||
294 | this._selectedSubpath = null; | ||
295 | } | ||
296 | 293 | ||
297 | if (this._subtool !== this.SUBTOOL_NONE && this._selectedSubpath===null) { | 294 | if (this._subtool !== this.SUBTOOL_NONE && this._selectedSubpath===null) { |
298 | //do nothing because the pen plus and pen minus subtools need a selected subpath | 295 | //do nothing because the pen plus and pen minus subtools need a selected subpath |
299 | return; | 296 | return; |
300 | } | 297 | } |
298 | |||
299 | //build the hit record for the current mouse position (on the stage or the plane of the path canvas) | ||
300 | var hitRec = this.getHitRecord(event.pageX, event.pageY, false); | ||
301 | var globalMousePos=null, localMousePos=null, stageWorldMousePos = null, drawingCanvas=null; | ||
302 | if (this._selectedSubpathCanvas){ | ||
303 | globalMousePos = hitRec.getScreenPoint(); | ||
304 | localMousePos = ViewUtils.globalToLocal(globalMousePos, this._selectedSubpathCanvas); | ||
305 | } | ||
306 | |||
307 | //if we have a selected subpath and canvas, check if the current click location hits the path | ||
308 | // todo optimize this...currently pickPath is called twice (see later in this function) | ||
309 | var hitPath = false; | ||
310 | if (this._selectedSubpath && this._selectedSubpathCanvas ) { | ||
311 | var tempSelAnchorAndParamAndCode = this._selectedSubpath.pickPath(localMousePos[0], localMousePos[1], localMousePos[2], this._PICK_POINT_RADIUS, true); | ||
312 | if (tempSelAnchorAndParamAndCode[2] !== this._selectedSubpath.SEL_NONE){ // ******* if we hit the path anywhere ********* | ||
313 | hitPath = true; | ||
314 | } | ||
315 | } | ||
316 | |||
317 | //if we had closed the selected subpath previously, or if we have not yet started anything, create a subpath | ||
318 | if (this._entryEditMode !== this.ENTRY_SELECT_PATH && this._selectedSubpath && this._selectedSubpath.getIsClosed() && this._makeMultipleSubpaths && !hitPath) { | ||
319 | this._selectedSubpath = null; | ||
320 | } | ||
321 | |||
301 | if (this._selectedSubpath === null) { | 322 | if (this._selectedSubpath === null) { |
302 | this._selectedSubpath = new SubPath(); | 323 | this._selectedSubpath = new SubPath(); |
303 | this._selectedSubpathCanvas = null; | 324 | this._selectedSubpathCanvas = null; |
@@ -335,9 +356,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
335 | this._selectedSubpath.setFillColor(colorArray); | 356 | this._selectedSubpath.setFillColor(colorArray); |
336 | } //if the selectedSubpath was null and needed to be constructed | 357 | } //if the selectedSubpath was null and needed to be constructed |
337 | 358 | ||
338 | //build the hit record for the current mouse position (on the stage or the plane of the path canvas) | 359 | //build the current mouse position in stage world space in case we don't already have a canvas |
339 | var hitRec = this.getHitRecord(event.pageX, event.pageY, false); | ||
340 | var globalMousePos=null, localMousePos=null, stageWorldMousePos = null, drawingCanvas=null; | ||
341 | if (!this._selectedSubpathCanvas){ | 360 | if (!this._selectedSubpathCanvas){ |
342 | drawingCanvas = this.application.ninja.currentDocument.model.documentRoot;//ViewUtils.getStageElement(); | 361 | drawingCanvas = this.application.ninja.currentDocument.model.documentRoot;//ViewUtils.getStageElement(); |
343 | stageWorldMousePos = hitRec.calculateStageWorldPoint(); | 362 | stageWorldMousePos = hitRec.calculateStageWorldPoint(); |
@@ -345,10 +364,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
345 | stageWorldMousePos[1]+= snapManager.getStageHeight()*0.5; | 364 | stageWorldMousePos[1]+= snapManager.getStageHeight()*0.5; |
346 | localMousePos = stageWorldMousePos; //since the subpath points are in stage world space, set the 'localMousePos' to be stage world as well | 365 | localMousePos = stageWorldMousePos; //since the subpath points are in stage world space, set the 'localMousePos' to be stage world as well |
347 | } | 366 | } |
348 | else { | 367 | |
349 | globalMousePos = hitRec.getScreenPoint(); | ||
350 | localMousePos = ViewUtils.globalToLocal(globalMousePos, this._selectedSubpathCanvas); | ||
351 | } | ||
352 | 368 | ||
353 | if (this._selectedSubpathCanvas === null && this._subtool===this.SUBTOOL_NONE){ | 369 | if (this._selectedSubpathCanvas === null && this._subtool===this.SUBTOOL_NONE){ |
354 | //IF this is the first anchor point of the selected subpath | 370 | //IF this is the first anchor point of the selected subpath |
@@ -358,7 +374,6 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
358 | if (this._selectedSubpath.getNumAnchors()===0) { | 374 | if (this._selectedSubpath.getNumAnchors()===0) { |
359 | this._selectedSubpathPlaneMat = hitRec.getPlaneMatrix(); | 375 | this._selectedSubpathPlaneMat = hitRec.getPlaneMatrix(); |
360 | } | 376 | } |
361 | |||
362 | //check if the mouse click location is close to the existing anchor | 377 | //check if the mouse click location is close to the existing anchor |
363 | var indexAndCode = this._selectedSubpath.pickAnchor(stageWorldMousePos[0], stageWorldMousePos[1], stageWorldMousePos[2], this._PICK_POINT_RADIUS); | 378 | var indexAndCode = this._selectedSubpath.pickAnchor(stageWorldMousePos[0], stageWorldMousePos[1], stageWorldMousePos[2], this._PICK_POINT_RADIUS); |
364 | if (indexAndCode[0]>=0){ | 379 | if (indexAndCode[0]>=0){ |
@@ -526,7 +541,9 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
526 | 541 | ||
527 | //set the cursor to be the default cursor (depending on whether the selected subpath has any points yet) | 542 | //set the cursor to be the default cursor (depending on whether the selected subpath has any points yet) |
528 | if (this._subtool===this.SUBTOOL_NONE){ | 543 | if (this._subtool===this.SUBTOOL_NONE){ |
529 | if (this._selectedSubpath && this._selectedSubpath.getNumAnchors()>0){ | 544 | if ((this._selectedSubpath && this._selectedSubpath.getNumAnchors()>0 && !this._selectedSubpath.getIsClosed()) |
545 | || | ||
546 | this._entryEditMode === this.ENTRY_SELECT_PATH){ | ||
530 | this.application.ninja.stage.drawingCanvas.style.cursor = //"auto"; | 547 | this.application.ninja.stage.drawingCanvas.style.cursor = //"auto"; |
531 | "url('images/cursors/penCursors/Pen_.png') 5 1, default"; | 548 | "url('images/cursors/penCursors/Pen_.png') 5 1, default"; |
532 | } | 549 | } |
@@ -853,9 +870,9 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
853 | this._editMode = this.EDIT_NONE; | 870 | this._editMode = this.EDIT_NONE; |
854 | 871 | ||
855 | //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 | 872 | //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 |
856 | if (this._selectedSubpath && this._selectedSubpath.getIsClosed() && this._entryEditMode !== this.ENTRY_SELECT_PATH){ | 873 | //if (this._selectedSubpath && this._selectedSubpath.getIsClosed() && this._entryEditMode !== this.ENTRY_SELECT_PATH){ |
857 | this._selectedSubpath = null; | 874 | // this._selectedSubpath = null; |
858 | } | 875 | //} |
859 | 876 | ||
860 | if (this._selectedSubpath){ | 877 | if (this._selectedSubpath){ |
861 | this.DrawSubpathAnchors(this._selectedSubpath);//render the subpath anchors on canvas | 878 | this.DrawSubpathAnchors(this._selectedSubpath);//render the subpath anchors on canvas |
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, { | |||
98 | // { | 98 | // { |
99 | // hitRec = snapManager.findHitRecordForElement(elt); | 99 | // hitRec = snapManager.findHitRecordForElement(elt); |
100 | // } | 100 | // } |
101 | // if(elt === this.application.ninja.currentSelectedContainer) | 101 | // if(elt === this.application.ninja.currentDocument.model.domContainer) |
102 | // { | 102 | // { |
103 | // this._clickedOnStage = true; | 103 | // this._clickedOnStage = true; |
104 | // } | 104 | // } |
diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index ed92b893..8b644d4a 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js | |||
@@ -224,10 +224,11 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { | |||
224 | HandleDoubleClick: { | 224 | HandleDoubleClick: { |
225 | value: function(event) { | 225 | value: function(event) { |
226 | if(this.application.ninja.selectedElements.length > 0) { | 226 | if(this.application.ninja.selectedElements.length > 0) { |
227 | this.application.ninja.currentSelectedContainer = this.application.ninja.selectedElements[0]; | 227 | this.application.ninja.currentDocument.model.domContainer = this.application.ninja.selectedElements[0]; |
228 | } else { | 228 | } else { |
229 | this.application.ninja.currentSelectedContainer = this.application.ninja.currentDocument.model.documentRoot; | 229 | this.application.ninja.currentDocument.model.domContainer = this.application.ninja.currentDocument.model.documentRoot; |
230 | } | 230 | } |
231 | this.application.ninja.selectionController.executeSelectElement(); | ||
231 | } | 232 | } |
232 | }, | 233 | }, |
233 | 234 | ||
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, { | |||
103 | if(wasSelected) { | 103 | if(wasSelected) { |
104 | this.AddCustomFeedback(); | 104 | this.AddCustomFeedback(); |
105 | this.application.ninja.elementMediator.addDelegate = this; | 105 | this.application.ninja.elementMediator.addDelegate = this; |
106 | if(this.application.ninja.currentSelectedContainer.nodeName === "CANVAS") { | 106 | if(this.application.ninja.currentDocument.model.domContainer.nodeName === "CANVAS") { |
107 | this._targetedElement = this.application.ninja.currentSelectedContainer; | 107 | this._targetedElement = this.application.ninja.currentDocument.model.domContainer; |
108 | } | 108 | } |
109 | } else { | 109 | } else { |
110 | this.RemoveCustomFeedback(); | 110 | this.RemoveCustomFeedback(); |
@@ -199,7 +199,7 @@ exports.ShapeTool = Montage.create(DrawingTool, { | |||
199 | target = this._targetedElement; | 199 | target = this._targetedElement; |
200 | else | 200 | else |
201 | { | 201 | { |
202 | var container = this.application.ninja.currentSelectedContainer; | 202 | var container = this.application.ninja.currentDocument.model.domContainer; |
203 | if (container && (container.nodeName === "CANVAS")) | 203 | if (container && (container.nodeName === "CANVAS")) |
204 | { | 204 | { |
205 | target = container; | 205 | 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, { | |||
89 | var otherSnap = snapManager.findHitRecordForElement(elt); | 89 | var otherSnap = snapManager.findHitRecordForElement(elt); |