aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
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/TextTool.js40
-rw-r--r--js/tools/bindingTool.js51
5 files changed, 69 insertions, 29 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/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/bindingTool.js b/js/tools/bindingTool.js
new file mode 100644
index 00000000..1a8cb47f
--- /dev/null
+++ b/js/tools/bindingTool.js
@@ -0,0 +1,51 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */
6
7var Montage = require("montage/core/core").Montage,
8 DrawingTool = require("js/tools/drawing-tool").DrawingTool,
9ModifierToolBase = require("js/tools/modifier-tool-base").ModifierToolBase;
10
11
12exports.BindingTool = Montage.create(ModifierToolBase, {
13 drawingFeedback: { value: { mode: "Draw2D", type: "" } },
14
15 Configure: {
16 value: function (doActivate)
17 {
18 if (doActivate)
19 {
20 NJevent("enableStageMove");
21 this.application.ninja.workspaceMode = "binding";
22
23 }
24 else
25 {
26 NJevent("disableStageMove");
27 this.application.ninja.workspaceMode = "default";
28 }
29 }
30 },
31
32 HandleLeftButtonDown: {
33 value: function(event) {
34 NJevent("enableStageMove");
35
36 }
37 },
38
39 HandleMouseMove: {
40 value: function(event) {
41 this.doDraw(event);
42 }
43 },
44
45 HandleLeftButtonUp: {
46 value: function(event) {
47 this.endDraw(event);
48 NJevent("disableStageMove");
49 }
50 }
51}); \ No newline at end of file