aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools')
-rwxr-xr-xjs/tools/FillTool.js20
-rwxr-xr-xjs/tools/InkBottleTool.js21
-rwxr-xr-xjs/tools/LineTool.js9
-rwxr-xr-xjs/tools/OvalTool.js15
-rwxr-xr-xjs/tools/RectTool.js15
-rwxr-xr-xjs/tools/SelectionTool.js1
-rwxr-xr-xjs/tools/ShapeTool.js13
-rwxr-xr-xjs/tools/modifier-tool-base.js8
8 files changed, 58 insertions, 44 deletions
diff --git a/js/tools/FillTool.js b/js/tools/FillTool.js
index 4b07ae83..746f20cf 100755
--- a/js/tools/FillTool.js
+++ b/js/tools/FillTool.js
@@ -17,11 +17,12 @@ var Montage = require("montage/core/core").Montage,
17exports.FillTool = Montage.create(ModifierToolBase, { 17exports.FillTool = Montage.create(ModifierToolBase, {
18 _canSnap: { value: false }, 18 _canSnap: { value: false },
19 _canColor: { value: true }, 19 _canColor: { value: true },
20 _targetedElement: { value: null },
20 21
21 HandleMouseMove: { 22 HandleMouseMove: {
22 value : function (event) 23 value : function (event)
23 { 24 {
24 var obj = this.application.ninja.stage.GetElement(event); 25 var obj = this.application.ninja.stage.GetSelectableElement(event);
25 var cursor = "url('images/cursors/fill.png') 14 14, default"; 26 var cursor = "url('images/cursors/fill.png') 14 14, default";
26 var canColor = true; 27 var canColor = true;
27 if (obj) 28 if (obj)
@@ -31,6 +32,23 @@ exports.FillTool = Montage.create(ModifierToolBase, {
31 { 32 {
32 cursor = "url('images/cursors/nofill.png') 14 14, default"; 33 cursor = "url('images/cursors/nofill.png') 14 14, default";
33 canColor = false; 34 canColor = false;
35 if(this._targetedElement)
36 {
37 this._targetedElement.classList.remove("active-element-outline");
38 this._targetedElement = null;
39 }
40 }
41 else
42 {
43 if (obj !== this._targetedElement)
44 {
45 if(this._targetedElement)
46 {
47 this._targetedElement.classList.remove("active-element-outline");
48 }
49 }
50 this._targetedElement = obj;
51 this._targetedElement.classList.add("active-element-outline");
34 } 52 }
35 } 53 }
36 this.application.ninja.stage.drawingCanvas.style.cursor = cursor; 54 this.application.ninja.stage.drawingCanvas.style.cursor = cursor;
diff --git a/js/tools/InkBottleTool.js b/js/tools/InkBottleTool.js
index 8340ef50..95c2e71d 100755
--- a/js/tools/InkBottleTool.js
+++ b/js/tools/InkBottleTool.js
@@ -11,11 +11,12 @@ var Montage = require("montage/core/core").Montage,
11exports.InkBottleTool = Montage.create(ModifierToolBase, { 11exports.InkBottleTool = Montage.create(ModifierToolBase, {
12 _canSnap: { value: false }, 12 _canSnap: { value: false },
13 _canColor: { value: true }, 13 _canColor: { value: true },
14 _targetedElement: { value: null },
14 15
15 HandleMouseMove: { 16 HandleMouseMove: {
16 value : function (event) 17 value : function (event)
17 { 18 {
18 var obj = this.application.ninja.stage.GetElement(event); 19 var obj = this.application.ninja.stage.GetSelectableElement(event);
19 var cursor = "url('images/cursors/ink.png') 6 11, default"; 20 var cursor = "url('images/cursors/ink.png') 6 11, default";
20 var canColor = true; 21 var canColor = true;
21 if (obj) 22 if (obj)
@@ -25,7 +26,25 @@ exports.InkBottleTool = Montage.create(ModifierToolBase, {
25 { 26 {
26 cursor = "url('images/cursors/ink_no.png') 6 11, default"; 27 cursor = "url('images/cursors/ink_no.png') 6 11, default";
27 canColor = false; 28 canColor = false;
29 if(this._targetedElement)
30 {
31 this._targetedElement.classList.remove("active-element-outline");
32 this._targetedElement = null;
33 }
28 } 34 }
35 else
36 {
37 if (obj !== this._targetedElement)
38 {
39 if(this._targetedElement)
40 {
41 this._targetedElement.classList.remove("active-element-outline");
42 }
43 }
44 this._targetedElement = obj;
45 this._targetedElement.classList.add("active-element-outline");
46 }
47
29 } 48 }
30 this.application.ninja.stage.drawingCanvas.style.cursor = cursor; 49 this.application.ninja.stage.drawingCanvas.style.cursor = cursor;
31 this._canColor = canColor; 50 this._canColor = canColor;
diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js
index a61f8f79..a43d4fb6 100755
--- a/js/tools/LineTool.js
+++ b/js/tools/LineTool.js
@@ -216,6 +216,7 @@ exports.LineTool = Montage.create(ShapeTool, {
216 { 216 {
217 strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM)); 217 strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM));
218 } 218 }
219 strokeColor = ShapesController.getMaterialColor(strokeM) || strokeColor;
219 } 220 }
220 221
221 var world = this.getGLWorld(canvas, this.options.use3D); 222 var world = this.getGLWorld(canvas, this.options.use3D);
@@ -234,19 +235,13 @@ exports.LineTool = Montage.create(ShapeTool, {
234 canvas.elementModel.selection = "Line"; 235 canvas.elementModel.selection = "Line";
235 canvas.elementModel.pi = "LinePi"; 236 canvas.elementModel.pi = "LinePi";
236 canvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units; 237 canvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units;
237 canvas.elementModel.shapeModel.stroke = strokeColor;
238 if(strokeColor)
239 {
240 canvas.elementModel.shapeModel.border = this.application.ninja.colorController.colorToolbar.stroke;
241 }
242
243 canvas.elementModel.shapeModel.strokeMaterial = strokeMaterial;
244 238
245 canvas.elementModel.shapeModel.strokeStyleIndex = strokeStyleIndex; 239 canvas.elementModel.shapeModel.strokeStyleIndex = strokeStyleIndex;
246 canvas.elementModel.shapeModel.strokeStyle = strokeStyle; 240 canvas.elementModel.shapeModel.strokeStyle = strokeStyle;
247 241
248 canvas.elementModel.shapeModel.GLGeomObj = line; 242 canvas.elementModel.shapeModel.GLGeomObj = line;
249 canvas.elementModel.shapeModel.useWebGl = this.options.use3D; 243 canvas.elementModel.shapeModel.useWebGl = this.options.use3D;
244 canvas.elementModel.shapeModel.slope = slope;
250 } 245 }
251 else 246 else
252 { 247 {
diff --git a/js/tools/OvalTool.js b/js/tools/OvalTool.js
index a10e0bb5..e8e88d1d 100755
--- a/js/tools/OvalTool.js
+++ b/js/tools/OvalTool.js
@@ -53,12 +53,14 @@ exports.OvalTool = Montage.create(ShapeTool, {
53 { 53 {
54 strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM)); 54 strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM));
55 } 55 }
56 strokeColor = ShapesController.getMaterialColor(strokeM) || strokeColor;
56 57
57 var fillM = this.options.fillMaterial; 58 var fillM = this.options.fillMaterial;
58 if(fillM) 59 if(fillM)
59 { 60 {
60 fillMaterial = Object.create(MaterialsModel.getMaterial(fillM)); 61 fillMaterial = Object.create(MaterialsModel.getMaterial(fillM));
61 } 62 }
63 fillColor = ShapesController.getMaterialColor(fillM) || fillColor;
62 } 64 }
63 65
64 var world = this.getGLWorld(canvas, this.options.use3D); 66 var world = this.getGLWorld(canvas, this.options.use3D);
@@ -78,22 +80,9 @@ exports.OvalTool = Montage.create(ShapeTool, {
78 canvas.elementModel.selection = "Oval"; 80 canvas.elementModel.selection = "Oval";
79 canvas.elementModel.pi = "OvalPi"; 81 canvas.elementModel.pi = "OvalPi";
80 canvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units; 82 canvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units;
81 canvas.elementModel.shapeModel.stroke = strokeColor;
82 canvas.elementModel.shapeModel.fill = fillColor;
83 if(strokeColor)
84 {
85 canvas.elementModel.shapeModel.border = this.application.ninja.colorController.colorToolbar.stroke;
86 }
87 if(fillColor)
88 {
89 canvas.elementModel.shapeModel.background = this.application.ninja.colorController.colorToolbar.fill;
90 }
91 83
92 canvas.elementModel.shapeModel.innerRadius = this.options.innerRadius.value + " " + this.options.innerRadius.units; 84 canvas.elementModel.shapeModel.innerRadius = this.options.innerRadius.value + " " + this.options.innerRadius.units;
93 85
94 canvas.elementModel.shapeModel.strokeMaterial = strokeMaterial;
95 canvas.elementModel.shapeModel.fillMaterial = fillMaterial;
96
97 canvas.elementModel.shapeModel.strokeStyleIndex = strokeStyleIndex; 86 canvas.elementModel.shapeModel.strokeStyleIndex = strokeStyleIndex;
98 canvas.elementModel.shapeModel.strokeStyle = strokeStyle; 87 canvas.elementModel.shapeModel.strokeStyle = strokeStyle;
99 88
diff --git a/js/tools/RectTool.js b/js/tools/RectTool.js
index 957afea9..0c14a559 100755
--- a/js/tools/RectTool.js
+++ b/js/tools/RectTool.js
@@ -72,12 +72,14 @@ exports.RectTool = Montage.create(ShapeTool, {
72 { 72 {
73 strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM)); 73 strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM));
74 } 74 }
75 strokeColor = ShapesController.getMaterialColor(strokeM) || strokeColor;
75 76
76 var fillM = this.options.fillMaterial; 77 var fillM = this.options.fillMaterial;
77 if(fillM) 78 if(fillM)
78 { 79 {
79 fillMaterial = Object.create(MaterialsModel.getMaterial(fillM)); 80 fillMaterial = Object.create(MaterialsModel.getMaterial(fillM));
80 } 81 }
82 fillColor = ShapesController.getMaterialColor(fillM) || fillColor;
81 } 83 }
82 84
83 var world = this.getGLWorld(canvas, this.options.use3D); 85 var world = this.getGLWorld(canvas, this.options.use3D);
@@ -98,25 +100,12 @@ exports.RectTool = Montage.create(ShapeTool, {
98 canvas.elementModel.selection = "Rectangle"; 100 canvas.elementModel.selection = "Rectangle";
99 canvas.elementModel.pi = "RectanglePi"; 101 canvas.elementModel.pi = "RectanglePi";
100 canvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units; 102 canvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units;
101 canvas.elementModel.shapeModel.stroke = strokeColor;
102 canvas.elementModel.shapeModel.fill = fillColor;
103 if(strokeColor)
104 {
105 canvas.elementModel.shapeModel.border = this.application.ninja.colorController.colorToolbar.stroke;
106 }
107 if(fillColor)
108 {
109 canvas.elementModel.shapeModel.background = this.application.ninja.colorController.colorToolbar.fill;
110 }
111 103
112 canvas.elementModel.shapeModel.tlRadius = this.options.TLRadiusControl.value + " " + this.options.TLRadiusControl.units;