From a809c6b3ba6f024922dd3f10bbc4ab456de2407e Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 2 May 2012 15:45:43 -0700 Subject: Converting line, circle and rectangle shapes to object literal notation. Signed-off-by: Nivesh Rajbhandari --- js/tools/LineTool.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'js/tools') diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js index 3e9167fd..9c4ba892 100755 --- a/js/tools/LineTool.js +++ b/js/tools/LineTool.js @@ -233,7 +233,8 @@ exports.LineTool = Montage.create(ShapeTool, { var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2)); - var line = new Line(world, xOffset, yOffset, w, h, slope, strokeSize, strokeColor, strokeMaterial, strokeStyle, xAdj, yAdj); + var line = new Line(); + line.init(world, xOffset, yOffset, w, h, slope, strokeSize, strokeColor, strokeMaterial, strokeStyle, xAdj, yAdj); world.addObject(line); world.render(); -- cgit v1.2.3 From 7c77aa914eb96c2b5b797e37c16aa786c05f38e8 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 2 May 2012 16:50:38 -0700 Subject: Converting geom-obj to object literal notation. Signed-off-by: Nivesh Rajbhandari --- js/tools/LineTool.js | 2 +- js/tools/OvalTool.js | 2 +- js/tools/RectTool.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'js/tools') diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js index 9c4ba892..a32fbdc8 100755 --- a/js/tools/LineTool.js +++ b/js/tools/LineTool.js @@ -233,7 +233,7 @@ exports.LineTool = Montage.create(ShapeTool, { var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2)); - var line = new Line(); + var line = Object.create(Line, {}); line.init(world, xOffset, yOffset, w, h, slope, strokeSize, strokeColor, strokeMaterial, strokeStyle, xAdj, yAdj); world.addObject(line); 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, { var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); var yOffset = -(canvas.height/2 - (top - canvas.offsetTop + h/2)); - var oval = new Circle(); //GLCircle(); + var oval = Object.create(Circle, {}); oval.init(world, xOffset, yOffset, w, h, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle); 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, { var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2)); - var rect = new Rectangle(); + var rect = Object.create(Rectangle, {}); rect.init(world, xOffset, yOffset, w, h, strokeSize, strokeColor, fillColor, tlRadius, trRadius, blRadius, brRadius, strokeMaterial, fillMaterial, strokeStyle); -- cgit v1.2.3 From 9eeb03e8bb86a4462609d3a18b528daa1516b91c Mon Sep 17 00:00:00 2001 From: hwc487 Date: Mon, 7 May 2012 13:57:18 -0700 Subject: fixes for 2D and 3D translation. --- js/tools/SelectionTool.js | 2 +- js/tools/TranslateObject3DTool.js | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'js/tools') diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index 855c7b8c..07c26b8c 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js @@ -504,7 +504,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { delta = vecUtils.vecSubtract( 3, data.pt1, data.pt0 ); delta[0] = ~~delta[0]; delta[1] = ~~delta[1]; - delta[2] = 0; + //delta[2] = 0; var transMat = Matrix.Translation( delta ); this._moveElements(transMat); } 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, { else { this._delta = null; - // special case for z-translation - if(this._handleMode === 2) + //if(this._handleMode === 2) { - this._dragPlane = viewUtils.getNormalToUnprojectedElementPlane(this._target); + this._dragPlane = viewUtils.getNormalToUnprojectedElementPlane(this._target, this._handleMode, this._inLocalMode); + //console.log( "dragPlane: " + this._dragPlane ); snapManager.setupDragPlaneFromPlane(this._dragPlane); do3DSnap = false; @@ -86,7 +86,8 @@ exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, { var elt = this.application.ninja.stage.getElement(event, true); if(elt && (elt !== hitRec.getElement())) { - hitRec = snapManager.findHitRecordForElement(elt); + var otherSnap = snapManager.findHitRecordForElement(elt); + if (otherSnap) hitRec = otherSnap; } if(elt === this.application.ninja.currentSelectedContainer) { -- cgit v1.2.3 From 15c7bdad38a83d192bd5a1d55a54362c12c73d38 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Tue, 8 May 2012 12:10:07 -0700 Subject: Fixed a snapping issue on the mouse down in drawing tools. --- js/tools/drawing-tool-base.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'js/tools') 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, { * 2 - Y value converted to screen point */ getInitialSnapPoint: { - value: function(x, y, shapeCanvas) { - snapManager.clearDragPlane(); - + value: function(x, y, shapeCanvas) + { // update the snap settings snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() ); snapManager.enableElementSnap( snapManager.elementSnapEnabledAppLevel() ); -- cgit v1.2.3 From 622ce143d92988aa613a0a5b6399efb54facafba Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 9 May 2012 13:23:15 -0700 Subject: some code cleanup Signed-off-by: Valerio Virgillito --- js/tools/TextTool.js | 40 ++++++++++++++-------------------------- 1 file changed, 14 insertions(+), 26 deletions(-) (limited to 'js/tools') 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 */ var Montage = require("montage/core/core").Montage, - DrawingTool = require("js/tools/drawing-tool").DrawingTool; + DrawingTool = require("js/tools/drawing-tool").DrawingTool, RichTextEditor = require("node_modules/labs/rich-text-editor.reel").RichTextEditor, ElementsMediator = require("js/mediators/element-mediator").ElementMediator; exports.TextTool = Montage.create(DrawingTool, { + drawingFeedback: { + value: { mode: "Draw3D", type: "rectangle" } + }, - _selectedElement: { value : null }, + _selectedElement: { + value : null + }, selectedElement: { get: function() { @@ -35,9 +40,6 @@ exports.TextTool = Montage.create(DrawingTool, { } } }, - - - drawingFeedback: { value: { mode: "Draw3D", type: "rectangle" } }, HandleLeftButtonDown: { value: function(event) { @@ -81,15 +83,7 @@ exports.TextTool = Montage.create(DrawingTool, { return; } - var drawData, selectedItem; - if(this._hasDraw) { - drawData = this.getDrawingData(); - - if(drawData) { - //this.insertElement(drawData); - } - this._hasDraw = false; this.endDraw(event); } else { @@ -113,6 +107,8 @@ exports.TextTool = Montage.create(DrawingTool, { drawTextTool: { value: function() { + var self = this; + this.application.ninja.stage.textTool.value = this.selectedElement.innerHTML; if(this.application.ninja.stage.textTool.value === "") { this.application.ninja.stage.textTool.value = " "; } this.selectedElement.innerHTML = ""; @@ -125,35 +121,27 @@ exports.TextTool = Montage.create(DrawingTool, { this.application.ninja.stage.textTool.element.style.width = this.selectedElement.offsetWidth + "px"; this.application.ninja.stage.textTool.element.style.height = this.selectedElement.offsetHeight + "px"; - // Set font styling (Size, Style, Weight) - - me = this; this.application.ninja.stage.textTool.didDraw = function() { - me.applyElementStyles(me.selectedElement, me.application.ninja.stage.textTool.element, ["overflow"]); - me.applyElementStyles(me.selectedElement, me.application.ninja.stage.textTool.element.firstChild, ["font","padding-left","padding-top","padding-right","padding-bottom", "color"]); + self.applyElementStyles(self.selectedElement, self.application.ninja.stage.textTool.element, ["overflow"]); + self.applyElementStyles(self.selectedElement, self.application.ninja.stage.textTool.element.firstChild, ["font","padding-left","padding-top","padding-right","padding-bottom", "color"]); var range = document.createRange(), sel = window.getSelection(); sel.removeAllRanges(); - range.selectNodeContents(this.application.ninja.stage.textTool.element.firstChild); + range.selectNodeContents(self.application.ninja.stage.textTool.element.firstChild); sel.addRange(range); this.didDraw = function() {}; } } }, + /* HandleDoubleClick: { value: function(e) { //this.application.ninja.selectedElements[0].setAttribute("contenteditable", true); - - //if (!this.application.ninja.textTool) { - - //} - - - } }, + */ Configure: { value: function(wasSelected) { -- cgit v1.2.3