diff options
author | Ananya Sen | 2012-05-01 13:39:30 -0700 |
---|---|---|
committer | Ananya Sen | 2012-05-01 13:39:30 -0700 |
commit | c360d1a5cfe894591ae65f892ead11d0ca537b18 (patch) | |
tree | 13964f810d3516dbc02e27ab5bb576fe62366f26 /js/tools/ShapeTool.js | |
parent | 3137d919e6b4ccbb2fb68c5920f4376acde3f1f5 (diff) | |
parent | e3fa4c7db57b63c5ac604c9420062de5d0fe413a (diff) | |
download | ninja-c360d1a5cfe894591ae65f892ead11d0ca537b18.tar.gz |
Merge branch 'refs/heads/ninja-internal-master' into Codeview-improvements
Diffstat (limited to 'js/tools/ShapeTool.js')
-rwxr-xr-x | js/tools/ShapeTool.js | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index f3b5e92d..8f45891d 100755 --- a/js/tools/ShapeTool.js +++ b/js/tools/ShapeTool.js | |||
@@ -54,9 +54,9 @@ exports.ShapeTool = Montage.create(DrawingTool, { | |||
54 | }, | 54 | }, |
55 | 55 | ||
56 | HandleLeftButtonUp: | 56 | HandleLeftButtonUp: |
57 | { | 57 | { |
58 | value: function (event) | 58 | value: function (event) |
59 | { | 59 | { |
60 | var drawData; | 60 | var drawData; |
61 | 61 | ||
62 | drawData = this.getDrawingData(); | 62 | drawData = this.getDrawingData(); |
@@ -69,24 +69,27 @@ exports.ShapeTool = Montage.create(DrawingTool, { | |||
69 | drawData.planeMat, drawData.midPt, canvas, true); | 69 | drawData.planeMat, drawData.midPt, canvas, true); |
70 | 70 | ||
71 | canvas.elementModel.isShape = true; | 71 | canvas.elementModel.isShape = true; |
72 | this.application.ninja.elementMediator.addElements(canvas, elementModel.data); | 72 | this.application.ninja.elementMediator.addElements(canvas, elementModel.data); |
73 | } else { | 73 | } else { |
74 | canvas = this._targetedElement; | 74 | canvas = this._targetedElement; |
75 | if (!canvas.getAttribute( "data-RDGE-id" )) | ||
76 | canvas.setAttribute( "data-RDGE-id", NJUtils.generateRandom() ); | ||
75 | canvas.elementModel.controller = ShapesController; | 77 | canvas.elementModel.controller = ShapesController; |
76 | if(!canvas.elementModel.shapeModel) { | 78 | if(!canvas.elementModel.shapeModel) { |
77 | canvas.elementModel.shapeModel = Montage.create(ShapeModel); | 79 | canvas.elementModel.shapeModel = Montage.create(ShapeModel); |
78 | } | 80 | } |
81 | this.application.ninja.elementMediator.addElements(canvas, canvas.elementModel.data); | ||
79 | } | 82 | } |
80 | } | 83 | } |
81 | 84 | ||
82 | this.endDraw(event); | 85 | this.endDraw(event); |
83 | 86 | ||
84 | this._isDrawing = false; | 87 | this._isDrawing = false; |
85 | this._hasDraw=false; | 88 | this._hasDraw=false; |
86 | 89 | ||
87 | this.DrawHandles(); | 90 | this.DrawHandles(); |
88 | } | 91 | } |
89 | }, | 92 | }, |
90 | 93 | ||
91 | onAddElements: { | 94 | onAddElements: { |
92 | value: function(el) { | 95 | value: function(el) { |
@@ -138,7 +141,7 @@ exports.ShapeTool = Montage.create(DrawingTool, { | |||
138 | _showFeedbackOnMouseMove: { | 141 | _showFeedbackOnMouseMove: { |
139 | value: function (event) { | 142 | value: function (event) { |
140 | // TODO - This call is causing the canvas to redraw 3 times per mouse move | 143 | // TODO - This call is causing the canvas to redraw 3 times per mouse move |
141 | var targetedObject = this.application.ninja.stage.GetSelectableElement(event); | 144 | var targetedObject = this.application.ninja.stage.getElement(event, true); |
142 | 145 | ||
143 | if (targetedObject) { | 146 | if (targetedObject) { |
144 | if((targetedObject.nodeName === "CANVAS") && !ShapesController.isElementAShape(targetedObject)) | 147 | if((targetedObject.nodeName === "CANVAS") && !ShapesController.isElementAShape(targetedObject)) |
@@ -211,7 +214,20 @@ exports.ShapeTool = Montage.create(DrawingTool, { | |||
211 | _useExistingCanvas: { | 214 | _useExistingCanvas: { |
212 | value: function() | 215 | value: function() |
213 | { | 216 | { |
214 | return (this._targetedElement && !ShapesController.isElementAShape(this._targetedElement)); | 217 | var target; |
218 | if (this._targetedElement && (this._targetedElement.nodeName === "CANVAS") && !ShapesController.isElementAShape(this._targetedElement)) | ||
219 | target = this._targetedElement; | ||
220 | else | ||
221 | { | ||
222 | var container = this.application.ninja.currentSelectedContainer; | ||
223 | if (container && (container.nodeName === "CANVAS")) | ||
224 | { | ||
225 | target = container; | ||
226 | this._targetedElement = target; | ||
227 | } | ||
228 | } | ||
229 | |||
230 | return target; | ||
215 | } | 231 | } |
216 | } | 232 | } |
217 | 233 | ||