aboutsummaryrefslogtreecommitdiff
path: root/js/tools/ShapeTool.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools/ShapeTool.js')
-rwxr-xr-xjs/tools/ShapeTool.js43
1 files changed, 10 insertions, 33 deletions
diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js
index 8f45891d..0562dbc2 100755
--- a/js/tools/ShapeTool.js
+++ b/js/tools/ShapeTool.js
@@ -53,23 +53,17 @@ exports.ShapeTool = Montage.create(DrawingTool, {
53 } 53 }
54 }, 54 },
55 55
56 HandleLeftButtonUp: 56 HandleLeftButtonUp: {
57 { 57 value: function (event) {
58 value: function (event) 58 var canvas, drawData = this.getDrawingData();
59 {
60 var drawData;
61
62 drawData = this.getDrawingData();
63 59
64 if(drawData) { 60 if(drawData) {
65 var canvas;
66 if(!this._useExistingCanvas()) { 61 if(!this._useExistingCanvas()) {
67 canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); 62 canvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument);
68 var elementModel = TagTool.makeElement(~~drawData.width, ~~drawData.height, 63 document.application.njUtils.createModelWithShape(canvas);
69 drawData.planeMat, drawData.midPt, canvas, true);
70 64
71 canvas.elementModel.isShape = true; 65 var styles = document.application.njUtils.stylesFromDraw(canvas, ~~drawData.width, ~~drawData.height, drawData);
72 this.application.ninja.elementMediator.addElements(canvas, elementModel.data); 66 this.application.ninja.elementMediator.addElements(canvas, styles);
73 } else { 67 } else {
74 canvas = this._targetedElement; 68 canvas = this._targetedElement;
75 if (!canvas.getAttribute( "data-RDGE-id" )) 69 if (!canvas.getAttribute( "data-RDGE-id" ))
@@ -106,6 +100,9 @@ exports.ShapeTool = Montage.create(DrawingTool, {
106 if(wasSelected) { 100 if(wasSelected) {
107 this.AddCustomFeedback(); 101 this.AddCustomFeedback();
108 this.application.ninja.elementMediator.addDelegate = this; 102 this.application.ninja.elementMediator.addDelegate = this;
103 if(this.application.ninja.currentSelectedContainer.nodeName === "CANVAS") {
104 this._targetedElement = this.application.ninja.currentSelectedContainer;
105 }
109 } else { 106 } else {
110 this.RemoveCustomFeedback(); 107 this.RemoveCustomFeedback();
111 this.application.ninja.elementMediator.addDelegate = null; 108 this.application.ninja.elementMediator.addDelegate = null;
@@ -190,26 +187,6 @@ exports.ShapeTool = Montage.create(DrawingTool, {
190 } 187 }
191 }, 188 },
192 189
193 createCanvas: {
194 value: function (left, top, w, h)
195 {
196 //var tmpDiv = document.createElement("canvas");
197 var tmpDiv = NJUtils.makeNJElement("canvas", "Canvas", "block");
198 var rules = {
199 'position': 'absolute',
200 'top' : top + 'px',
201 'left' : left + 'px',
202 '-webkit-transform-style' : 'preserve-3d',
203 '-webkit-transform' : 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
204 };
205
206 tmpDiv.width = w;
207 tmpDiv.height = h;
208
209 return {el: tmpDiv, rules: rules};
210 }
211 },
212
213 // We can draw on an existing canvas unless it has only a single shape object 190 // We can draw on an existing canvas unless it has only a single shape object
214 _useExistingCanvas: { 191 _useExistingCanvas: {
215 value: function() 192 value: function()