aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorValerio Virgillito2012-06-06 17:04:34 -0700
committerValerio Virgillito2012-06-06 17:04:34 -0700
commit6442dcc0cc4088d28558a9c121c6a91cba3ff078 (patch)
tree8f2f2db6097104e44c8d87e11466d1f3124c7f3a /js
parent488ae8d98deb30009cb8b5b2da464fe52940050b (diff)
parent47e0e1f047e83b71c3f86812a45d33904201cc7a (diff)
downloadninja-6442dcc0cc4088d28558a9c121c6a91cba3ff078.tar.gz
Merge branch 'refs/heads/master' into element-model-fixes
Conflicts: js/tools/LineTool.js js/tools/ShapeTool.js Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js')
-rw-r--r--js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js5
-rwxr-xr-xjs/stage/stage.reel/stage.js2
-rwxr-xr-xjs/tools/FillTool.js1
-rwxr-xr-xjs/tools/InkBottleTool.js1
-rwxr-xr-xjs/tools/LineTool.js108
-rwxr-xr-xjs/tools/SelectionTool.js2
-rwxr-xr-xjs/tools/ShapeTool.js44
-rwxr-xr-xjs/tools/TagTool.js12
-rwxr-xr-xjs/tools/drawing-tool.js3
-rwxr-xr-xjs/tools/modifier-tool-base.js2
10 files changed, 102 insertions, 78 deletions
diff --git a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js
index ebe2df61..7227d532 100644
--- a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js
+++ b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js
@@ -195,11 +195,6 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C
195 } 195 }
196 } 196 }
197 197
198 //disable ok
199 if(!this.okButton.hasAttribute("disabled")){
200 this.okButton.setAttribute("disabled", "true");
201 }
202
203 //save project type selection 198 //save project type selection
204 this.selectedProjectType = {"uri":evt.uri, "element":evt.target}; 199 this.selectedProjectType = {"uri":evt.uri, "element":evt.target};
205 200
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js
index 8d1c087d..30ee1e40 100755
--- a/js/stage/stage.reel/stage.js
+++ b/js/stage/stage.reel/stage.js
@@ -242,7 +242,7 @@ exports.Stage = Montage.create(Component, {
242 242
243 // Hack for now until a full component 243 // Hack for now until a full component
244 this.layout.draw(); 244 this.layout.draw();
245 if(this.currentDocument) { 245 if(this.currentDocument && (this.currentDocument.currentView === "design")) {
246 this.layout.draw3DInfo(true); 246 this.layout.draw3DInfo(true);
247 } 247 }
248 } else if(this.updatedStage) { 248 } else if(this.updatedStage) {
diff --git a/js/tools/FillTool.js b/js/tools/FillTool.js
index 69807bc3..e08ec1da 100755
--- a/js/tools/FillTool.js
+++ b/js/tools/FillTool.js
@@ -70,6 +70,7 @@ exports.FillTool = Montage.create(ModifierToolBase, {
70 // Called by modifier tool base's HandleLeftButtonDown after updating selection (if needed) 70 // Called by modifier tool base's HandleLeftButtonDown after updating selection (if needed)
71 startDraw: { 71 startDraw: {
72 value: function(event) { 72 value: function(event) {
73 this.drawData = null;
73 this.isDrawing = true; 74 this.isDrawing = true;
74 75
75 if(this._canColor && this.application.ninja.selectedElements.length) { 76 if(this._canColor && this.application.ninja.selectedElements.length) {
diff --git a/js/tools/InkBottleTool.js b/js/tools/InkBottleTool.js
index dff0b0fa..c5640b10 100755
--- a/js/tools/InkBottleTool.js
+++ b/js/tools/InkBottleTool.js
@@ -65,6 +65,7 @@ exports.InkBottleTool = Montage.create(ModifierToolBase, {
65 // Called by modifier tool base's HandleLeftButtonDown after updating selection (if needed) 65 // Called by modifier tool base's HandleLeftButtonDown after updating selection (if needed)
66 startDraw: { 66 startDraw: {
67 value: function(event) { 67 value: function(event) {
68 this.drawData = null;
68 this.isDrawing = true; 69 this.isDrawing = true;
69 70
70 if(this._canColor && this.application.ninja.selectedElements.length) 71 if(this._canColor && this.application.ninja.selectedElements.length)
diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js
index 56d03e81..40475908 100755
--- a/js/tools/LineTool.js
+++ b/js/tools/LineTool.js
@@ -54,38 +54,45 @@ exports.LineTool = Montage.create(ShapeTool, {
54 54
55 HandleLeftButtonUp: { 55 HandleLeftButtonUp: {
56 value: function (event) { 56 value: function (event) {
57 var slope = this._getSlope(), drawData = this.getDrawingData(); 57 var slope = this._getSlope(),
58 58 canvas,
59 if(drawData) { 59 xAdj = 0,
60 var canvas, xAdj = 0, yAdj = 0, w, h; 60 yAdj = 0,
61 if(!this._useExistingCanvas()) { 61 w,
62 if(drawData = this.getDrawingData()) { 62 h;
63 // set the dimensions 63
64 w = ~~drawData.width; 64 if(slope) {
65 h = ~~drawData.height; 65 this.drawData = this.getDrawingData();
66 if(slope === "horizontal") { 66 if(this.drawData) {
67 h = Math.max(this._strokeSize, 1); 67 w = Math.floor(this.drawData.width);
68 } else if(slope === "vertical") { 68 h = Math.floor(this.drawData.height);
69 w = Math.max(this._strokeSize, 1); 69 if(!this._useExistingCanvas()) {
70 // set the dimensions
71 if(slope === "horizontal") {
72 h = Math.max(this._strokeSize, 1);
73 w = Math.max(w, 1);
74 } else if(slope === "vertical") {
75 w = Math.max(this._strokeSize, 1);
76 h = Math.max(h, 1);
77 } else {
78 // else make the line's stroke fit inside the canvas by growing the canvas
79 var theta = Math.atan(slope);
80 xAdj = Math.abs((this._strokeSize/2)*Math.sin(theta));
81 yAdj = Math.abs((this._strokeSize/2)*Math.cos(theta));
82
83 w += ~~(xAdj*2);
84 h += ~~(yAdj*2);
85 }
86
87 canvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument);
88
89 var styles = document.application.njUtils.stylesFromDraw(canvas, w, h, this.drawData);
90 this.application.ninja.elementMediator.addElements(canvas, styles);
70 } else { 91 } else {
71 // else make the line's stroke fit inside the canvas by growing the canvas 92 canvas = this._targetedElement;
72 var theta = Math.atan(slope); 93 canvas.elementModel.controller = ShapesController;
73 xAdj = Math.abs((this._strokeSize/2)*Math.sin(theta)); 94 if(!canvas.elementModel.shapeModel) {
74 yAdj = Math.abs((this._strokeSize/2)*Math.cos(theta)); 95 canvas.elementModel.shapeModel = Montage.create(ShapeModel);
75
76 w += ~~(xAdj*2);
77 h += ~~(yAdj*2);
78 }
79
80 canvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument);
81
82 var styles = document.application.njUtils.stylesFromDraw(canvas, w, h, drawData);
83 this.application.ninja.elementMediator.addElements(canvas, styles);
84 } else {
85 canvas = this._targetedElement;
86 canvas.elementModel.controller = ShapesController;
87 if(!canvas.elementModel.shapeModel) {
88 canvas.elementModel.shapeModel = Montage.create(ShapeModel);
89 } 96 }
90 } 97 }
91 } 98 }
@@ -102,16 +109,18 @@ exports.LineTool = Montage.create(ShapeTool, {
102 109
103 onAddElements: { 110 onAddElements: {
104 value: function(el) { 111 value: function(el) {
105 var drawData, xAdj = 0, yAdj = 0, w, h, slope = this._getSlope(); 112 var xAdj = 0, yAdj = 0, w, h, slope = this._getSlope();
106 113
107 if(drawData = this.getDrawingData()) { 114 if(this.drawData) {
108 // set the dimensions 115 // set the dimensions
109 w = ~~drawData.width; 116 w = Math.floor(this.drawData.width);
110 h = ~~drawData.height; 117 h = Math.floor(this.drawData.height);
111 if(slope === "horizontal") { 118 if(slope === "horizontal") {
112 h = Math.max(this._strokeSize, 1); 119 h = Math.max(this._strokeSize, 1);
120 w = Math.max(w, 1);
113 } else if(slope === "vertical") { 121 } else if(slope === "vertical") {
114 w = Math.max(this._strokeSize, 1); 122 w = Math.max(this._strokeSize, 1);
123 h = Math.max(h, 1);
115 } else { 124 } else {
116 // else make the line's stroke fit inside the canvas by growing the canvas 125 // else make the line's stroke fit inside the canvas by growing the canvas
117 var theta = Math.atan(slope); 126 var theta = Math.atan(slope);
@@ -122,7 +131,7 @@ exports.LineTool = Montage.create(ShapeTool, {
122 h += ~~(yAdj*2); 131 h += ~~(yAdj*2);
123 } 132 }
124 133
125 this.RenderShape(w, h, drawData.planeMat, drawData.midPt, el, slope, xAdj, yAdj); 134 this.RenderShape(w, h, this.drawData.planeMat, this.drawData.midPt, el, slope, xAdj, yAdj);
126 } 135 }
127 } 136 }
128 }, 137 },
@@ -131,28 +140,31 @@ exports.LineTool = Montage.create(ShapeTool, {
131 value: function() { 140 value: function() {
132 var hitRec0 = this._mouseDownHitRec, 141 var hitRec0 = this._mouseDownHitRec,
133 hitRec1 = this._mouseUpHitRec, 142 hitRec1 = this._mouseUpHitRec,
134 slope; 143 slope,
144 dx,
145 dy;
135 146
136 if (hitRec0 && hitRec1) 147 if (hitRec0 && hitRec1) {
137 {
138 var p0 = hitRec0.getLocalPoint(), 148 var p0 = hitRec0.getLocalPoint(),
139 p1 = hitRec1.getLocalPoint(); 149 p1 = hitRec1.getLocalPoint();
140 150
151 dx = Math.floor(p0[0] - p1[0]);
152 dy = Math.floor(p0[1] - p1[1]);
153
154 if( (dx === 0) && (dy === 0) ) {
155 return null;
156 }
157
141 // check for divide by 0 for vertical line: 158 // check for divide by 0 for vertical line:
142 if( Math.round(p0[0] - p1[0]) === 0 ) 159 if(dx === 0) {
143 {
144 // vertical line 160 // vertical line
145 slope = "vertical"; 161 slope = "vertical";
146 } 162 } else if (dy === 0) {
147 else if (Math.round(p0[1] - p1[1]) === 0 )
148 {
149 // horizontal line 163 // horizontal line
150 slope = "horizontal"; 164 slope = "horizontal";
151 } 165 } else {
152 else
153 {
154 // if slope is positive, draw a line from top-left to bottom-right 166 // if slope is positive, draw a line from top-left to bottom-right