aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
authorArmen Kesablyan2012-05-14 11:45:11 -0700
committerArmen Kesablyan2012-05-14 11:45:11 -0700
commit9e6c0a247bd2f14d92278bcd97fff40277b71667 (patch)
tree4194388c03814b9168922dbf2907edf426295874 /js/tools
parent9fc3b70bf57e10846e71808c6041fbc339a435d1 (diff)
parent27f4cacb39de1c2e3910748dadc9fc16d0655480 (diff)
downloadninja-9e6c0a247bd2f14d92278bcd97fff40277b71667.tar.gz
Merge branch 'refs/heads/masterDomArc' into binding
Diffstat (limited to 'js/tools')
-rwxr-xr-xjs/tools/LineTool.js3
-rwxr-xr-xjs/tools/OvalTool.js2
-rwxr-xr-xjs/tools/RectTool.js2
-rwxr-xr-xjs/tools/SelectionTool.js2
-rwxr-xr-xjs/tools/TextTool.js40
-rwxr-xr-xjs/tools/TranslateObject3DTool.js9
-rwxr-xr-xjs/tools/drawing-tool-base.js5
7 files changed, 26 insertions, 37 deletions
diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js
index 5941b464..198d7e69 100755
--- a/js/tools/LineTool.js
+++ b/js/tools/LineTool.js
@@ -234,7 +234,8 @@ exports.LineTool = Montage.create(ShapeTool, {
234 var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); 234 var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2);
235 var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2)); 235 var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2));
236 236
237 var line = new Line(world, xOffset, yOffset, w, h, slope, strokeSize, strokeColor, strokeMaterial, strokeStyle, xAdj, yAdj); 237 var line = Object.create(Line, {});
238 line.init(world, xOffset, yOffset, w, h, slope, strokeSize, strokeColor, strokeMaterial, strokeStyle, xAdj, yAdj);
238 239
239 world.addObject(line); 240 world.addObject(line);
240 world.render(); 241 world.render();
diff --git a/js/tools/OvalTool.js b/js/tools/OvalTool.js
index 6edec811..e9dc66bb 100755
--- a/js/tools/OvalTool.js
+++ b/js/tools/OvalTool.js
@@ -68,7 +68,7 @@ exports.OvalTool = Montage.create(ShapeTool, {
68 var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); 68 var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2);
69 var yOffset = -(canvas.height/2 - (top - canvas.offsetTop + h/2)); 69 var yOffset = -(canvas.height/2 - (top - canvas.offsetTop + h/2));
70 70
71 var oval = new Circle(); //GLCircle(); 71 var oval = Object.create(Circle, {});
72 oval.init(world, xOffset, yOffset, w, h, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle); 72 oval.init(world, xOffset, yOffset, w, h, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle);
73 73
74 world.addObject(oval); 74 world.addObject(oval);
diff --git a/js/tools/RectTool.js b/js/tools/RectTool.js
index 0c14a559..0a3c8200 100755
--- a/js/tools/RectTool.js
+++ b/js/tools/RectTool.js
@@ -87,7 +87,7 @@ exports.RectTool = Montage.create(ShapeTool, {
87 var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); 87 var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2);
88 var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2)); 88 var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2));
89 89
90 var rect = new Rectangle(); 90 var rect = Object.create(Rectangle, {});
91 rect.init(world, xOffset, yOffset, w, h, strokeSize, strokeColor, fillColor, 91 rect.init(world, xOffset, yOffset, w, h, strokeSize, strokeColor, fillColor,
92 tlRadius, trRadius, blRadius, brRadius, strokeMaterial, fillMaterial, strokeStyle); 92 tlRadius, trRadius, blRadius, brRadius, strokeMaterial, fillMaterial, strokeStyle);
93 93
diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js
index d3e4ebf9..5c8b15ae 100755
--- a/js/tools/SelectionTool.js
+++ b/js/tools/SelectionTool.js
@@ -505,7 +505,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
505 delta = vecUtils.vecSubtract( 3, data.pt1, data.pt0 ); 505 delta = vecUtils.vecSubtract( 3, data.pt1, data.pt0 );
506 delta[0] = ~~delta[0]; 506 delta[0] = ~~delta[0];
507 delta[1] = ~~delta[1]; 507 delta[1] = ~~delta[1];
508 delta[2] = 0; 508 //delta[2] = 0;
509 var transMat = Matrix.Translation( delta ); 509 var transMat = Matrix.Translation( delta );
510 this._moveElements(transMat); 510 this._moveElements(transMat);
511 } 511 }
diff --git a/js/tools/TextTool.js b/js/tools/TextTool.js
index a58aacc6..024a92ce 100755
--- a/js/tools/TextTool.js
+++ b/js/tools/TextTool.js
@@ -5,13 +5,18 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
5</copyright> */ 5</copyright> */
6 6
7var Montage = require("montage/core/core").Montage, 7var Montage = require("montage/core/core").Montage,
8 DrawingTool = require("js/tools/drawing-tool").DrawingTool; 8 DrawingTool = require("js/tools/drawing-tool").DrawingTool,
9 RichTextEditor = require("node_modules/labs/rich-text-editor.reel").RichTextEditor, 9 RichTextEditor = require("node_modules/labs/rich-text-editor.reel").RichTextEditor,
10 ElementsMediator = require("js/mediators/element-mediator").ElementMediator; 10 ElementsMediator = require("js/mediators/element-mediator").ElementMediator;
11 11
12exports.TextTool = Montage.create(DrawingTool, { 12exports.TextTool = Montage.create(DrawingTool, {
13 drawingFeedback: {
14 value: { mode: "Draw3D", type: "rectangle" }
15 },
13 16
14 _selectedElement: { value : null }, 17 _selectedElement: {
18 value : null
19 },
15 20
16 selectedElement: { 21 selectedElement: {
17 get: function() { 22 get: function() {
@@ -35,9 +40,6 @@ exports.TextTool = Montage.create(DrawingTool, {
35 } 40 }
36 } 41 }
37 }, 42 },
38
39
40 drawingFeedback: { value: { mode: "Draw3D", type: "rectangle" } },
41 43
42 HandleLeftButtonDown: { 44 HandleLeftButtonDown: {
43 value: function(event) { 45 value: function(event) {
@@ -81,15 +83,7 @@ exports.TextTool = Montage.create(DrawingTool, {
81 return; 83 return;
82 } 84 }
83 85
84 var drawData, selectedItem;
85
86 if(this._hasDraw) { 86 if(this._hasDraw) {
87 drawData = this.getDrawingData();
88
89 if(drawData) {
90 //this.insertElement(drawData);
91 }
92
93 this._hasDraw = false; 87 this._hasDraw = false;
94 this.endDraw(event); 88 this.endDraw(event);
95 } else { 89 } else {
@@ -113,6 +107,8 @@ exports.TextTool = Montage.create(DrawingTool, {
113 107
114 drawTextTool: { 108 drawTextTool: {
115 value: function() { 109 value: function() {
110 var self = this;
111
116 this.application.ninja.stage.textTool.value = this.selectedElement.innerHTML; 112 this.application.ninja.stage.textTool.value = this.selectedElement.innerHTML;
117 if(this.application.ninja.stage.textTool.value === "") { this.application.ninja.stage.textTool.value = " "; } 113 if(this.application.ninja.stage.textTool.value === "") { this.application.ninja.stage.textTool.value = " "; }
118 this.selectedElement.innerHTML = ""; 114 this.selectedElement.innerHTML = "";
@@ -125,35 +121,27 @@ exports.TextTool = Montage.create(DrawingTool, {
125 this.application.ninja.stage.textTool.element.style.width = this.selectedElement.offsetWidth + "px"; 121 this.application.ninja.stage.textTool.element.style.width = this.selectedElement.offsetWidth + "px";
126 this.application.ninja.stage.textTool.element.style.height = this.selectedElement.offsetHeight + "px"; 122 this.application.ninja.stage.textTool.element.style.height = this.selectedElement.offsetHeight + "px";
127 123
128
129 // Set font styling (Size, Style, Weight) 124 // Set font styling (Size, Style, Weight)
130
131 me = this;
132 this.application.ninja.stage.textTool.didDraw = function() { 125 this.application.ninja.stage.textTool.didDraw = function() {
133 me.applyElementStyles(me.selectedElement, me.application.ninja.stage.textTool.element, ["overflow"]); 126 self.applyElementStyles(self.selectedElement, self.application.ninja.stage.textTool.element, ["overflow"]);
134 me.applyElementStyles(me.selectedElement, me.application.ninja.stage.textTool.element.firstChild, ["font","padding-left","padding-top","padding-right","padding-bottom", "color"]); 127 self.applyElementStyles(self.selectedElement, self.application.ninja.stage.textTool.element.firstChild, ["font","padding-left","padding-top","padding-right","padding-bottom", "color"]);
135 var range = document.createRange(), 128 var range = document.createRange(),
136 sel = window.getSelection(); 129 sel = window.getSelection();
137 sel.removeAllRanges(); 130 sel.removeAllRanges();
138 range.selectNodeContents(this.application.ninja.stage.textTool.element.firstChild); 131 range.selectNodeContents(self.application.ninja.stage.textTool.element.firstChild);
139 sel.addRange(range); 132 sel.addRange(range);
140 this.didDraw = function() {}; 133 this.didDraw = function() {};
141 } 134 }
142 } 135 }
143 }, 136 },
144 137
138 /*
145 HandleDoubleClick: { 139 HandleDoubleClick: {
146 value: function(e) { 140 value: function(e) {
147 //this.application.ninja.selectedElements[0].setAttribute("contenteditable", true); 141 //this.application.ninja.selectedElements[0].setAttribute("contenteditable", true);
148
149 //if (!this.application.ninja.textTool) {
150
151 //}
152
153
154
155 } 142 }
156 }, 143 },
144 */
157 145
158 Configure: { 146 Configure: {
159 value: function(wasSelected) { 147 value: function(wasSelected) {
diff --git a/js/tools/TranslateObject3DTool.js b/js/tools/TranslateObject3DTool.js
index b4f55bd9..f8b32d23 100755
--- a/js/tools/TranslateObject3DTool.js
+++ b/js/tools/TranslateObject3DTool.js
@@ -54,10 +54,10 @@ exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, {
54 else 54 else
55 { 55 {
56 this._delta = null; 56 this._delta = null;
57 // special case for z-translation 57 //if(this._handleMode === 2)
58 if(this._handleMode === 2)
59 { 58 {
60 this._dragPlane = viewUtils.getNormalToUnprojectedElementPlane(this._target); 59 this._dragPlane = viewUtils.getNormalToUnprojectedElementPlane(this._target, this._handleMode, this._inLocalMode);
60 //console.log( "dragPlane: " + this._dragPlane );
61 snapManager.setupDragPlaneFromPlane(this._dragPlane); 61 snapManager.setupDragPlaneFromPlane(this._dragPlane);
62 do3DSnap = false; 62 do3DSnap = false;
63 63
@@ -86,7 +86,8 @@ exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, {
86 var elt = this.application.ninja.stage.getElement(event, true); 86 var elt = this.application.ninja.stage.getElement(event, true);
87 if(elt && (elt !== hitRec.getElement())) 87 if(elt && (elt !== hitRec.getElement()))
88 { 88 {
89 hitRec = snapManager.findHitRecordForElement(elt); 89 var otherSnap = snapManager.findHitRecordForElement(elt);
90 if (otherSnap) hitRec = otherSnap;
90 } 91 }
91 if(elt === this.application.ninja.currentSelectedContainer) 92 if(elt === this.application.ninja.currentSelectedContainer)
92 { 93 {
diff --git a/js/tools/drawing-tool-base.js b/js/tools/drawing-tool-base.js
index 376b3a27..84641754 100755
--- a/js/tools/drawing-tool-base.js
+++ b/js/tools/drawing-tool-base.js
@@ -36,9 +36,8 @@ exports.DrawingToolBase = Montage.create(Montage, {
36 * 2 - Y value converted to screen point 36 * 2 - Y value converted to screen point
37 */ 37 */
38 getInitialSnapPoint: { 38 getInitialSnapPoint: {
39 value: function(x, y, shapeCanvas) { 39 value: function(x, y, shapeCanvas)
40 snapManager.clearDragPlane(); 40 {
41
42 // update the snap settings 41 // update the snap settings
43 snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() ); 42 snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() );
44 snapManager.enableElementSnap( snapManager.elementSnapEnabledAppLevel() ); 43 snapManager.enableElementSnap( snapManager.elementSnapEnabledAppLevel() );