aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools')
-rw-r--r--js/tools/BrushTool.js2
-rwxr-xr-x[-rw-r--r--]js/tools/EraserTool.js0
-rwxr-xr-x[-rw-r--r--]js/tools/EyedropperTool.js206
-rwxr-xr-x[-rw-r--r--]js/tools/FillTool.js3
-rwxr-xr-x[-rw-r--r--]js/tools/InkBottleTool.js35
-rwxr-xr-x[-rw-r--r--]js/tools/LineTool.js2
-rwxr-xr-x[-rw-r--r--]js/tools/OvalTool.js0
-rwxr-xr-x[-rw-r--r--]js/tools/PanTool.js0
-rwxr-xr-x[-rw-r--r--]js/tools/PenTool.js2
-rwxr-xr-x[-rw-r--r--]js/tools/PencilTool.js0
-rwxr-xr-x[-rw-r--r--]js/tools/RectTool.js0
-rwxr-xr-x[-rw-r--r--]js/tools/Rotate3DToolBase.js0
-rwxr-xr-x[-rw-r--r--]js/tools/RotateObject3DTool.js0
-rwxr-xr-x[-rw-r--r--]js/tools/RotateStage3DTool.js7
-rwxr-xr-x[-rw-r--r--]js/tools/SelectionTool.js36
-rwxr-xr-x[-rw-r--r--]js/tools/ShapeTool.js2
-rwxr-xr-x[-rw-r--r--]js/tools/SubSelectTool.js0
-rwxr-xr-x[-rw-r--r--]js/tools/TagTool.js0
-rwxr-xr-x[-rw-r--r--]js/tools/TextTool.js98
-rwxr-xr-x[-rw-r--r--]js/tools/ToolBase.js0
-rwxr-xr-x[-rw-r--r--]js/tools/Translate3DToolBase.js0
-rwxr-xr-x[-rw-r--r--]js/tools/TranslateObject3DTool.js0
-rwxr-xr-x[-rw-r--r--]js/tools/ZoomTool.js2
-rwxr-xr-x[-rw-r--r--]js/tools/drawing-tool-base.js0
-rwxr-xr-x[-rw-r--r--]js/tools/drawing-tool.js0
-rwxr-xr-x[-rw-r--r--]js/tools/modifier-tool-base.js5
26 files changed, 333 insertions, 67 deletions
diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js
index 97df84a0..9a0ad583 100644
--- a/js/tools/BrushTool.js
+++ b/js/tools/BrushTool.js
@@ -208,7 +208,7 @@ exports.BrushTool = Montage.create(ShapeTool, {
208 var top = Math.round(midPt[1] - 0.5 * h); 208 var top = Math.round(midPt[1] - 0.5 * h);
209 209
210 if (!canvas) { 210 if (!canvas) {
211 var newCanvas = NJUtils.makeNJElement("canvas", "Brushstroke", "shape", null, true); 211 var newCanvas = NJUtils.makeNJElement("canvas", "Brushstroke", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true);
212 var elementModel = TagTool.makeElement(w, h, planeMat, midPt, newCanvas); 212 var elementModel = TagTool.makeElement(w, h, planeMat, midPt, newCanvas);
213 ElementMediator.addElement(newCanvas, elementModel.data, true); 213 ElementMediator.addElement(newCanvas, elementModel.data, true);
214 214
diff --git a/js/tools/EraserTool.js b/js/tools/EraserTool.js
index c12a14b1..c12a14b1 100644..100755
--- a/js/tools/EraserTool.js
+++ b/js/tools/EraserTool.js
diff --git a/js/tools/EyedropperTool.js b/js/tools/EyedropperTool.js
index 795753d2..d007da39 100644..100755
--- a/js/tools/EyedropperTool.js
+++ b/js/tools/EyedropperTool.js
@@ -6,7 +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 9 drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils,
10 vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils,
10 toolBase = require("js/tools/ToolBase").toolBase; 11 toolBase = require("js/tools/ToolBase").toolBase;
11 12
12exports.EyedropperTool = Montage.create(toolBase, { 13exports.EyedropperTool = Montage.create(toolBase, {
@@ -14,6 +15,9 @@ exports.EyedropperTool = Montage.create(toolBase, {
14 _isMouseDown: { value: false }, 15 _isMouseDown: { value: false },
15 _previousColor: { value: null}, 16 _previousColor: { value: null},
16 _color: { value: null}, 17 _color: { value: null},
18 _elementUnderMouse: { value: null },
19 _imageDataCanvas: { value: null },
20 _imageDataContext: { value: null },
17 21
18 Configure: { 22 Configure: {
19 value: function ( doActivate ) 23 value: function ( doActivate )
@@ -46,6 +50,8 @@ exports.EyedropperTool = Montage.create(toolBase, {
46 { 50 {
47 this._isMouseDown = false; 51 this._isMouseDown = false;
48 this._escape = false; 52 this._escape = false;
53 this._elementUnderMouse = null;
54 this._deleteImageDataCanvas();
49 } 55 }
50 if(this._isMouseDown) 56 if(this._isMouseDown)
51 { 57 {
@@ -67,6 +73,9 @@ exports.EyedropperTool = Montage.create(toolBase, {
67 this._updateColor(this._color); 73 this._updateColor(this._color);
68 74
69 this._color = null; 75 this._color = null;
76
77 this._elementUnderMouse = null;
78 this._deleteImageDataCanvas();
70 } 79 }
71 } 80 }
72 }, 81 },
@@ -95,27 +104,70 @@ exports.EyedropperTool = Montage.create(toolBase, {
95 104
96 _updateColorFromPoint: { 105 _updateColorFromPoint: {
97 value : function (event) { 106 value : function (event) {
98 var obj = this.application.ninja.stage.GetElement(event); 107 var c,
108 color,
109 obj = this.application.ninja.stage.GetElement(event);
99 if (obj) 110 if (obj)
100 { 111 {
101 // TODO - figure out if user clicked on a border - for now, just get fill 112 if(this.application.ninja.currentDocument.inExclusion(obj) !== -1)
102 var c = ElementsMediator.getColor(obj, true);
103 if(c)
104 { 113 {
105 var color = this.application.ninja.colorController.getColorObjFromCss(c); 114 this._elementUnderMouse = null;
106 if (color && color.value) { 115 this._deleteImageDataCanvas();
107 color.value.wasSetByCode = true; 116 return;
108 color.value.type = 'changing'; 117 }
109 if (color.value.a) { 118 this._elementUnderMouse = obj;
110 this.application.ninja.colorController.colorModel.alpha = {value: color.value.a, 119 // Depending on the object type, we need to get different colors
111 wasSetByCode: true, 120 if(obj.elementModel.selection === "image")
112 type: 'changing'}; 121 {
113 } 122 c = this._getColorAtPoint(obj, event);
114 this.application.ninja.colorController.colorModel[color.mode] = color.value; 123 if(c)
115 this._color = color; 124 {
125 color = this.application.ninja.colorController.getColorObjFromCss(c);
126 }
127 }
128 else if (obj.elementModel.selection === "canvas")
129 {
130 this._deleteImageDataCanvas();
131
132 var pt = webkitConvertPointFromPageToNode(obj,
133 new WebKitPoint(event.pageX, event.pageY)),
134 ctx = obj.getContext("2d");
135
136 c = this._getColorFromCanvas(ctx, pt);
137 if(c)
138 {
139 color = this.application.ninja.colorController.getColorObjFromCss(c);
140 }
141 }
142 else
143 {
144 this._deleteImageDataCanvas();
145
146 c = ElementsMediator.getColor(obj, this._isOverBackground(obj, event));
147 if(c)
148 {
149 color = this.application.ninja.colorController.getColorObjFromCss(c.color.css);
150 }
151 }
152
153 if (color && color.value) {
154 color.value.wasSetByCode = true;
155 color.value.type = 'changing';
156 if (color.value.a) {
157 this.application.ninja.colorController.colorModel.alpha = {value: color.value.a,
158 wasSetByCode: true,
159 type: 'changing'};
116 } 160 }
161 this.application.ninja.colorController.colorModel[color.mode] = color.value;
162 this._color = color;
117 } 163 }
118 } 164 }
165 else
166 {
167 this._elementUnderMouse = null;
168 this._deleteImageDataCanvas();
169 }
170
119 } 171 }
120 }, 172 },
121 173
@@ -147,6 +199,128 @@ exports.EyedropperTool = Montage.create(toolBase, {
147 this._previousColor = color.value.css; 199 this._previousColor = color.value.css;
148 } 200 }
149 } 201 }
202 },
203
204 // TODO - We don't want to calculate this repeatedly
205 _isOverBackground: {
206 value: function(elt, event)
207 {
208 var border = ElementsMediator.getProperty(elt, "border", parseFloat);
209
210 if(border)
211 {
212 var bounds3D,
213 innerBounds = [],
214 pt = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)),
215 bt = ElementsMediator.getProperty(elt, "border-top", parseFloat),
216 br = ElementsMediator.getProperty(elt, "border-right", parseFloat),
217 bb = ElementsMediator.getProperty(elt, "border-bottom", parseFloat),
218 bl = ElementsMediator.getProperty(elt, "border-left", parseFloat);
219
220// this.application.ninja.stage.viewUtils.setViewportObj( elt );
221 bounds3D = this.application.ninja.stage.viewUtils.getElementViewBounds3D( elt );
222// console.log("bounds");
223// console.dir(bounds3D);
224
225 var xAdj = bl || border,
226 yAdj = bt || border;
227 innerBounds.push([bounds3D[0][0] + xAdj, bounds3D[0][1] + yAdj, 0]);
228
229 yAdj += bb || border;
230 innerBounds.push([bounds3D[1][0] + xAdj, bounds3D[1][1] - yAdj, 0]);
231
232 xAdj += br || border;
233 innerBounds.push([bounds3D[2][0] - xAdj, bounds3D[2][1] - yAdj, 0]);
234
235 yAdj = bt || border;
236 innerBounds.push([bounds3D[3][0] - xAdj, bounds3D[3][1] + yAdj, 0]);
237// console.log("innerBounds");
238// console.dir(innerBounds);
239
240 var tmpPt = this.application.ninja.stage.viewUtil