aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools')
-rwxr-xr-xjs/tools/EyedropperTool.js59
-rwxr-xr-xjs/tools/SelectionTool.js23
-rwxr-xr-xjs/tools/Translate3DToolBase.js1
-rwxr-xr-xjs/tools/TranslateObject3DTool.js2
-rwxr-xr-xjs/tools/modifier-tool-base.js12
5 files changed, 75 insertions, 22 deletions
diff --git a/js/tools/EyedropperTool.js b/js/tools/EyedropperTool.js
index 11c15158..d6a162cd 100755
--- a/js/tools/EyedropperTool.js
+++ b/js/tools/EyedropperTool.js
@@ -6,9 +6,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
6 6
7var Montage = require("montage/core/core").Montage, 7var Montage = require("montage/core/core").Montage,
8 ElementsMediator = require("js/mediators/element-mediator").ElementMediator, 8 ElementsMediator = require("js/mediators/element-mediator").ElementMediator,
9 drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, 9 toolBase = require("js/tools/ToolBase").toolBase,
10 vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils, 10 ShapesController = require("js/controllers/elements/shapes-controller").ShapesController;
11 toolBase = require("js/tools/ToolBase").toolBase;
12 11
13exports.EyedropperTool = Montage.create(toolBase, { 12exports.EyedropperTool = Montage.create(toolBase, {
14 13
@@ -133,7 +132,15 @@ exports.EyedropperTool = Montage.create(toolBase, {
133 { 132 {
134 this._deleteImageDataCanvas(); 133 this._deleteImageDataCanvas();
135 134
136 c = this._getColorFromElement(obj, event); 135 if(ShapesController.isElementAShape(obj))
136 {
137 c = this._getColorFromShape(obj, event);
138 }
139 else
140 {
141 c = this._getColorFromElement(obj, event);
142 }
143
137 if(typeof(c) === "string") 144 if(typeof(c) === "string")
138 { 145 {
139 color = this.application.ninja.colorController.getColorObjFromCss(c); 146 color = this.application.ninja.colorController.getColorObjFromCss(c);
@@ -289,6 +296,50 @@ exports.EyedropperTool = Montage.create(toolBase, {
289 } 296 }
290 }, 297 },
291 298
299 // TODO - We don't want to calculate this repeatedly
300 _getColorFromShape: {
301 value: function(elt, event)
302 {
303 var strokeWidth = ShapesController.getShapeProperty(elt, "strokeSize"),
304 bounds3D,
305 innerBounds,
306 pt,
307 tmpPt,
308 x,
309 y;
310 if(strokeWidth)
311 {
312 strokeWidth = parseFloat(strokeWidth);
313 bounds3D = this.application.ninja.stage.viewUtils.getElementViewBounds3D( elt );
314 innerBounds = [];
315 pt = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas,
316 new WebKitPoint(event.pageX, event.pageY));
317
318 innerBounds.push([bounds3D[0][0] + strokeWidth, bounds3D[0][1] + strokeWidth, 0]);
319
320 innerBounds.push([bounds3D[1][0] + strokeWidth, bounds3D[1][1] - strokeWidth, 0]);
321
322 innerBounds.push([bounds3D[2][0] - strokeWidth, bounds3D[2][1] - strokeWidth, 0]);
323
324 innerBounds.push([bounds3D[3][0] - strokeWidth, bounds3D[3][1] + strokeWidth, 0]);
325
326 tmpPt = this.application.ninja.stage.viewUtils.globalToLocal([pt.x, pt.y], elt);
327 x = tmpPt[0];
328 y = tmpPt[1];
329
330 if( (x < innerBounds[0][0]) ||
331 (x > innerBounds[2][0]) ||
332 (y < innerBounds[0][1]) ||
333 (y > innerBounds[1][1]) )
334 {
335 return ShapesController.getColor(elt, false);
336 }
337 }
338
339 return ShapesController.getColor(elt, true);
340 }
341 },
342
292 _getColorAtPoint: { 343 _getColorAtPoint: {
293 value: function(elt, event) 344 value: function(elt, event)
294 { 345 {
diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js
index 6d8ff175..13a04944 100755
--- a/js/tools/SelectionTool.js
+++ b/js/tools/SelectionTool.js
@@ -16,6 +16,7 @@ var Montage = require("montage/core/core").Montage,
16var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { 16var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
17 drawingFeedback: { value: { mode: "Draw2D", type: "" } }, 17 drawingFeedback: { value: { mode: "Draw2D", type: "" } },
18 18
19 _inLocalMode: { value: false}, // This tool should always use global mode for translations
19 _canOperateOnStage: { value: true}, 20 _canOperateOnStage: { value: true},
20 _isSelecting: {value: false, writable:true}, 21 _isSelecting: {value: false, writable:true},
21 _shiftMove: { value: 10}, 22 _shiftMove: { value: 10},
@@ -34,14 +35,12 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
34 value: function () { 35 value: function () {
35 if(this._targets && this._targets.length) 36 if(this._targets && this._targets.length)
36 { 37 {
37 // TODO - drawUtils's elementPlanes check in drawSelectionBounds doesn't seem to work,
38 // so temporary workaround to simply check if all elements have identity matrix
39 // TODO - Eventually, this should instead check if all the selected items are on the view plane
40 var len = this._targets.length; 38 var len = this._targets.length;
39 var plane = this.application.ninja.stage.stageDeps.snapManager.getDragPlane();
41 for(var i = 0; i < len; i++) 40 for(var i = 0; i < len; i++)
42 { 41 {
43 var mat = this._targets[i].mat; 42 var elt = this._targets[i].elt;
44 if(!MathUtils.isIdentityMatrix(mat)) 43 if(!this.application.ninja.stage.stageDeps.snapManager.elementIsOnPlane(elt, plane))
45 { 44 {
46 return false; 45 return false;
47 } 46 }
@@ -123,14 +122,14 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
123 this.doDraw(event); 122 this.doDraw(event);
124 } else { 123 } else {
125 this._showFeedbackOnMouseMove(event); 124 this._showFeedbackOnMouseMove(event);
126 // if(this._canSnap) 125 if(this._canSnap)
127 // { 126 {
128 // this.doSnap(event); 127 this.doSnap(event);
129 // } 128 }
130 } 129 }
131 130
132 this.DrawHandles(this._delta); 131 this.DrawHandles(this._delta);
133 if(this._canSnap && this._isDrawing) 132 if(this._canSnap)
134 { 133 {
135 this.application.ninja.stage.stageDeps.snapManager.drawLastHit(); 134 this.application.ninja.stage.stageDeps.snapManager.drawLastHit();
136 } 135 }
@@ -704,6 +703,10 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
704 */ 703 */
705 _showFeedbackOnMouseMove : { 704 _showFeedbackOnMouseMove : {
706 value: function (event) { 705 value: function (event) {
706 if(!this._showTransformHandles)
707 {
708 return;
709 }
707 if(this._target && this._handles) 710 if(this._target && this._handles)
708 { 711 {
709 var len = this._handles.length; 712 var len = this._handles.length;
diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js
index 3d9191da..24a68ad1 100755
--- a/js/tools/Translate3DToolBase.js
+++ b/js/tools/Translate3DToolBase.js
@@ -10,7 +10,6 @@ Subclass TranslateObject3DTool will translate the object that was clicked.
10var Montage = require("montage/core/core").Montage, 10var Montage = require("montage/core/core").Montage,
11 ModifierToolBase = require("js/tools/modifier-tool-base").ModifierToolBase, 11 ModifierToolBase = require("js/tools/modifier-tool-base").ModifierToolBase,
12 toolHandleModule = require("js/stage/tool-handle"), 12 toolHandleModule = require("js/stage/tool-handle"),
13 snapManager = require("js/helper-classes/3D/snap-manager").SnapManager,
14 viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, 13 viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils,
15 vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils, 14 vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils,
16 drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, 15 drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils,
diff --git a/js/tools/TranslateObject3DTool.js b/js/tools/TranslateObject3DTool.js
index 5157e39c..92b9b2f7 100755
--- a/js/tools/TranslateObject3DTool.js
+++ b/js/tools/TranslateObject3DTool.js
@@ -103,7 +103,7 @@ exports.TranslateObject3DTool = Object.create(Translate3DToolBase, {
103 } 103 }
104 else 104 else
105 { 105 {
106 this._dragPlane = snapManager.setupDragPlanes( hitRec ); 106 this._dragPlane = snapManager.setupDragPlanes( hitRec, true );
107 } 107 }
108 108
109 } 109 }
diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js
index 7892d015..80f7d758 100755
--- a/js/tools/modifier-tool-base.js
+++ b/js/tools/modifier-tool-base.js
@@ -171,7 +171,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
171// } 171// }
172// else 172// else
173// { 173// {
174 this._dragPlane = snapManager.setupDragPlanes( hitRec ); 174 this._dragPlane = snapManager.setupDragPlanes( hitRec, true );
175// } 175// }
176 } 176 }
177 177
@@ -828,14 +828,14 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
828 this.doDraw(event); 828 this.doDraw(event);
829 } else { 829 } else {
830 this._showFeedbackOnMouseMove(event); 830 this._showFeedbackOnMouseMove(event);
831// if(this._canSnap) 831 if(this._canSnap)
832// { 832 {
833// this.doSnap(event); 833 this.doSnap(event);
834// } 834 }
835 } 835 }
836 836
837 this.DrawHandles(this._delta); 837 this.DrawHandles(this._delta);
838 if(this._canSnap && this._isDrawing) 838 if(this._canSnap)
839 { 839 {
840 snapManager.drawLastHit(); 840 snapManager.drawLastHit();
841 } 841 }