aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
authorhwc4872012-04-27 13:52:40 -0700
committerhwc4872012-04-27 13:52:40 -0700
commite73fba18b095f0c270f5d954e5993c155b488c73 (patch)
treeda18c6c0117fec3652b823bddc198add47632fc8 /js/tools
parent4b83774cdbfbf30add9a8fa2f11b1c4ff35179fa (diff)
downloadninja-e73fba18b095f0c270f5d954e5993c155b488c73.tar.gz
Creating shapes in a container
Diffstat (limited to 'js/tools')
-rwxr-xr-xjs/tools/SelectionTool.js2
-rwxr-xr-xjs/tools/ShapeTool.js2
-rwxr-xr-xjs/tools/drawing-tool-base.js13
3 files changed, 15 insertions, 2 deletions
diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js
index 7033ee3d..9c9aee93 100755
--- a/js/tools/SelectionTool.js
+++ b/js/tools/SelectionTool.js
@@ -222,8 +222,10 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
222 value: function(event) { 222 value: function(event) {
223 if(this.application.ninja.selectedElements.length > 0) { 223 if(this.application.ninja.selectedElements.length > 0) {
224 this.application.ninja.currentSelectedContainer = this.application.ninja.selectedElements[0]; 224 this.application.ninja.currentSelectedContainer = this.application.ninja.selectedElements[0];
225 console.log( "setting container to selected element" );
225 } else { 226 } else {
226 this.application.ninja.currentSelectedContainer = this.application.ninja.currentDocument.documentRoot; 227 this.application.ninja.currentSelectedContainer = this.application.ninja.currentDocument.documentRoot;
228 console.log( "setting container to stage" );
227 } 229 }
228 } 230 }
229 }, 231 },
diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js
index 74e692b6..90b403a4 100755
--- a/js/tools/ShapeTool.js
+++ b/js/tools/ShapeTool.js
@@ -64,6 +64,7 @@ exports.ShapeTool = Montage.create(DrawingTool, {
64 if(drawData) { 64 if(drawData) {
65 var canvas; 65 var canvas;
66 if(!this._useExistingCanvas()) { 66 if(!this._useExistingCanvas()) {
67 console.log( "creating a new canvas" );
67 canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); 68 canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true);
68 var elementModel = TagTool.makeElement(~~drawData.width, ~~drawData.height, 69 var elementModel = TagTool.makeElement(~~drawData.width, ~~drawData.height,
69 drawData.planeMat, drawData.midPt, canvas, true); 70 drawData.planeMat, drawData.midPt, canvas, true);
@@ -71,6 +72,7 @@ exports.ShapeTool = Montage.create(DrawingTool, {
71 canvas.elementModel.isShape = true; 72 canvas.elementModel.isShape = true;
72 this.application.ninja.elementMediator.addElements(canvas, elementModel.data); 73 this.application.ninja.elementMediator.addElements(canvas, elementModel.data);
73 } else { 74 } else {
75 console.log( "inserting shape into container" );
74 canvas = this._targetedElement; 76 canvas = this._targetedElement;
75 if (!canvas.getAttribute( "data-RDGE-id" )) 77 if (!canvas.getAttribute( "data-RDGE-id" ))
76 canvas.setAttribute( "data-RDGE-id", NJUtils.generateRandom() ); 78 canvas.setAttribute( "data-RDGE-id", NJUtils.generateRandom() );
diff --git a/js/tools/drawing-tool-base.js b/js/tools/drawing-tool-base.js
index 2283dfab..0b51aa28 100755
--- a/js/tools/drawing-tool-base.js
+++ b/js/tools/drawing-tool-base.js
@@ -41,11 +41,20 @@ exports.DrawingToolBase = Montage.create(Montage, {
41 41
42 // do the snap 42 // do the snap
43 var hitRec = snapManager.snap(x, y, true); 43 var hitRec = snapManager.snap(x, y, true);
44 var dragPlane;
44 if (hitRec) { 45 if (hitRec) {
45 // set up the working plane and convert the hit record to be working plane relative 46 // set up the working plane and convert the hit record to be working plane relative
46 var dragPlane = snapManager.setupDragPlanes( hitRec ); 47 if (hitRec.getElement() === snapManager.application.ninja.currentSelectedContainer)
47 var wpHitRec = hitRec.convertToWorkingPlane( dragPlane ); 48 {
49 dragPlane = viewUtils.getUnprojectedElementPlane( hitRec.getElement() );
50 snapManager.setupDragPlaneFromPlane( dragPlane );
51 }
52 else
53 {
54 dragPlane = snapManager.setupDragPlanes( hitRec );
55 }
48 56
57 var wpHitRec = hitRec.convertToWorkingPlane( dragPlane );
49 var pt = hitRec.getScreenPoint(); 58 var pt = hitRec.getScreenPoint();
50 59
51 return( [wpHitRec, pt[0], pt[1]] ); 60 return( [wpHitRec, pt[0], pt[1]] );