aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
authorJonathan Duran2012-06-06 11:22:43 -0700
committerJonathan Duran2012-06-06 11:22:43 -0700
commit020a8147088f09547b7e84db2ada7c48f25c089f (patch)
tree5ec53061c4437d7a7cd8c983ef8a17aa6cfe0e19 /js/tools
parentb73cc6e348f3eb4cd57b5afeb7a6f5d3633b7e6b (diff)
parent18e212dca48066d1ddaca96875a3f40adcc859b6 (diff)
downloadninja-020a8147088f09547b7e84db2ada7c48f25c089f.tar.gz
Merge branch 'refs/heads/NINJAmaster' into TimelineUber
Diffstat (limited to 'js/tools')
-rwxr-xr-xjs/tools/FillTool.js32
-rwxr-xr-xjs/tools/InkBottleTool.js49
-rwxr-xr-xjs/tools/SelectionTool.js112
3 files changed, 124 insertions, 69 deletions
diff --git a/js/tools/FillTool.js b/js/tools/FillTool.js
index 66dd9305..69807bc3 100755
--- a/js/tools/FillTool.js
+++ b/js/tools/FillTool.js
@@ -73,22 +73,28 @@ exports.FillTool = Montage.create(ModifierToolBase, {
73 this.isDrawing = true; 73 this.isDrawing = true;
74 74
75 if(this._canColor && this.application.ninja.selectedElements.length) { 75 if(this._canColor && this.application.ninja.selectedElements.length) {
76 var fillInfo = {},
77 color;
78 if(this.options.useFillColor.checked) {
79 fillInfo.colorInfo = {};
80 color = this.options.fill;
81 if(color && color.color)
82 {
83 fillInfo.colorInfo.mode = color.colorMode;
84 fillInfo.colorInfo.color = color.color;
85 } else {
86 fillInfo.colorInfo.mode = "nocolor";
87 fillInfo.colorInfo.color = null;
88 }
89 }
76 90
77 var color = this.options.fill, 91 if(this.options.useWebGL.checked) {
78 colorInfo; 92 fillInfo.webGLInfo = {};
79 if(color && color.color) 93 fillInfo.webGLInfo.material = this.options.fillMaterial.value;
80 {
81 colorInfo = { mode:color.colorMode,
82 color:color.color
83 };
84 } 94 }
85 else 95 if(fillInfo.colorInfo || fillInfo.webGLInfo) {
86 { 96 ElementsMediator.setFill(this.application.ninja.selectedElements, fillInfo, "Change", "fillTool");
87 colorInfo = { mode:"nocolor",
88 color:color.color
89 };
90 } 97 }
91 ElementsMediator.setColor(this.application.ninja.selectedElements, colorInfo, true, "Change", "fillTool");
92 } 98 }
93 } 99 }
94 } 100 }
diff --git a/js/tools/InkBottleTool.js b/js/tools/InkBottleTool.js
index 2c03d133..dff0b0fa 100755
--- a/js/tools/InkBottleTool.js
+++ b/js/tools/InkBottleTool.js
@@ -69,39 +69,46 @@ exports.InkBottleTool = Montage.create(ModifierToolBase, {
69 69
70 if(this._canColor && this.application.ninja.selectedElements.length) 70 if(this._canColor && this.application.ninja.selectedElements.length)
71 { 71 {
72 var color = this.options.stroke, 72 var strokeInfo = {},
73 colorInfo; 73 color;
74 if(color && color.color) 74 if(this.options.useStrokeColor.checked) {
75 { 75 strokeInfo.colorInfo = {};
76 colorInfo = { mode:color.colorMode, 76 color = this.options.stroke;
77 color:color.color 77 if(color && color.color)
78 }; 78 {
79 } 79 strokeInfo.colorInfo.mode = color.colorMode;
80 else 80 strokeInfo.colorInfo.color = color.color;
81 { 81 } else {
82 colorInfo = { mode:"nocolor", 82 strokeInfo.colorInfo.mode = "nocolor";
83 color:color.color 83 strokeInfo.colorInfo.color = null;
84 }; 84 }
85 } 85 }
86 86
87 if(this.options.useBorderWidth.checked || this.options.useBorderStyle.checked) { 87 if(this.options.useBorderWidth.checked || this.options.useBorderStyle.checked) {
88 colorInfo.borderInfo = {}; 88 strokeInfo.borderInfo = {};
89 if(this.options.useBorderWidth.checked) { 89 if(this.options.useBorderWidth.checked) {
90 colorInfo.borderInfo.borderWidth = this.options._borderWidth.value; 90 strokeInfo.borderInfo.borderWidth = this.options.borderWidth.value;
91 colorInfo.borderInfo.borderUnits = this.options._borderWidth.units; 91 strokeInfo.borderInfo.borderUnits = this.options.borderWidth.units;
92 } 92 }
93 if(this.options.useBorderStyle.checked) { 93 if(this.options.useBorderStyle.checked) {
94 colorInfo.borderInfo.borderStyle = this.options._borderStyle.value; 94 strokeInfo.borderInfo.borderStyle = this.options.borderStyle.value;
95 } 95 }
96 } 96 }
97 97
98 if(this.options.useStrokeSize.checked) { 98 if(this.options.useStrokeSize.checked) {
99 colorInfo.strokeInfo = {}; 99 strokeInfo.shapeInfo = {};
100 colorInfo.strokeInfo.strokeSize = this.options._strokeSize.value; 100 strokeInfo.shapeInfo.strokeSize = this.options.strokeSize.value;
101 colorInfo.strokeInfo.strokeUnits = this.options._strokeSize.units; 101 strokeInfo.shapeInfo.strokeUnits = this.options.strokeSize.units;
102 }
103
104 if(this.options.useWebGL.checked) {
105 strokeInfo.webGLInfo = {};
106 strokeInfo.webGLInfo.material = this.options.strokeMaterial.value;
102 } 107 }
103 108
104 ElementsMediator.setColor(this.application.ninja.selectedElements, colorInfo, false, "Change", "inkBottleTool"); 109 if(strokeInfo.colorInfo || strokeInfo.borderInfo || strokeInfo.shapeInfo || strokeInfo.webGLInfo) {
110 ElementsMediator.setStroke(this.application.ninja.selectedElements, strokeInfo, "Change", "inkBottleTool");
111 }
105 } 112 }
106 } 113 }
107 } 114 }
diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js
index 4bafa12a..7b72a857 100755
--- a/js/tools/SelectionTool.js
+++ b/js/tools/SelectionTool.js
@@ -399,7 +399,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
399 //Routines to modify the selected objects 399 //Routines to modify the selected objects
400 modifyElements : { 400 modifyElements : {
401 value : function(data, event) { 401 value : function(data, event) {
402 var delta, deltaH = [], deltaW = [], modObject = []; 402 var delta, modObject = [], left, top, width, height;
403 403
404 if(this._handleMode !== null) { 404 if(this._handleMode !== null) {
405 // 0 7 6 405 // 0 7 6
@@ -411,92 +411,134 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
411 // Resize North-West 411 // Resize North-West
412 this.application.ninja.selectedElements.forEach(function(element) { 412 this.application.ninja.selectedElements.forEach(function(element) {
413 delta = ~~(data.pt1[0] - data.pt0[0]); 413 delta = ~~(data.pt1[0] - data.pt0[0]);
414 var width = parseInt(element.elementModel.getProperty("w")) - delta + "px"; 414 width = parseInt(element.elementModel.getProperty("w")) - delta;
415 var left = parseInt(element.elementModel.getProperty("x")) + delta + "px"; 415 if(width <= 0) {
416 width = 1;
417 left = parseInt(element.elementModel.getProperty("x")) + parseInt(element.elementModel.getProperty("w")) - 1;
418 } else {
419 left = parseInt(element.elementModel.getProperty("x")) + delta;
420 }
421
416 delta = ~~(data.pt1[1] - data.pt0[1]); 422 delta = ~~(data.pt1[1] - data.pt0[1]);
417 var height = parseInt(element.elementModel.getProperty("h")) - delta + "px"; 423 height = parseInt(element.elementModel.getProperty("h")) - delta;
418 var top = parseInt(element.elementModel.getProperty("y")) + delta + "px"; 424 if(height <= 0) {
419 modObject.push({element:element, properties:{width: width, height: height, left: left, top: top}}); 425 height = 1;
426 top = parseInt(element.elementModel.getProperty("y")) + parseInt(element.elementModel.getProperty("h")) - 1;
427 } else {
428 top = parseInt(element.elementModel.getProperty("y")) + delta;
429 }
430 modObject.push({element:element, properties:{width: width + "px", height: height + "px", left: left + "px", top: top + "px"}});
420 }); 431 });
421 ElementsMediator.setProperties(modObject, "Changing", "SelectionTool" );
422 break; 432 break;
423 case 1: 433 case 1:
424 // Resize West 434 // Resize West
425 this.application.ninja.selectedElements.forEach(function(element) { 435 this.application.ninja.selectedElements.forEach(function(element) {
426 delta = ~~(data.pt1[0] - data.pt0[0]); 436 delta = ~~(data.pt1[0] - data.pt0[0]);
427 var width = parseInt(element.elementModel.getProperty("w")) - delta + "px"; 437 width = parseInt(element.elementModel.getProperty("w")) - delta;
428 var left = parseInt(element.elementModel.getProperty("x")) + delta + "px"; 438 if(width <= 0) {
429 modObject.push({element:element, properties:{left: left, width: width}}); 439 width = 1;
440 left = parseInt(element.elementModel.getProperty("x")) + parseInt(element.elementModel.getProperty("w")) - 1;
441 } else {
442 left = parseInt(element.elementModel.getProperty("x")) + delta;
443 }
444 modObject.push({element:element, properties:{left: left + "px", width: width + "px"}});
430 }); 445 });
431 ElementsMediator.setProperties(modObject, "Changing", "SelectionTool");
432 break; 446 break;
433 case 2: 447 case 2:
434 // Resize South-West 448 // Resize South-West
435 this.application.ninja.selectedElements.forEach(function(element) { 449 this.application.ninja.selectedElements.forEach(function(element) {
436 delta = ~~(data.pt1[0] - data.pt0[0]); 450 delta = ~~(data.pt1[0] - data.pt0[0]);
437 var width = parseInt(element.elementModel.getProperty("w")) - delta + "px"; 451 width = parseInt(element.elementModel.getProperty("w")) - delta;
438 var left = parseInt(element.elementModel.getProperty("x")) + delta + "px"; 452 if(width <= 0) {
453 width = 1;
454 left = parseInt(element.elementModel.getProperty("x")) + parseInt(element.elementModel.getProperty("w")) - 1;
455 } else {
456 left = parseInt(element.elementModel.getProperty("x")) + delta;
457 }
439 delta = ~~(data.pt1[1] - data.pt0[1]); 458 delta = ~~(data.pt1[1] - data.pt0[1]);
440 var height = parseInt(element.elementModel.getProperty("h")) + delta + "px"; 459 height = parseInt(element.elementModel.getProperty("h")) + delta;
441 modObject.push({element:element, properties:{width: width, height: height, left: left}}); 460 if(height <= 0) {
461 height = 1;
462 }
463 modObject.push({element:element, properties:{width: width + "px", height: height + "px", left: left + "px"}});
442 }); 464 });
443 ElementsMediator.setProperties(modObject, "Changing", "SelectionTool" );
444 break; 465 break;
445 case 3: 466 case 3:
446 // Resize South 467 // Resize South
447 this.application.ninja.selectedElements.forEach(function(element) { 468 this.application.ninja.selectedElements.forEach(function(element) {