From 355656cac2fa1a025ad97791ea095a54cebdff71 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 1 May 2012 20:13:58 -0700 Subject: Support drawing in side and top view. Also, adding back support for drawing shapes inside canvas when double-clicked into canvas or when moused over canvas. Signed-off-by: Nivesh Rajbhandari --- js/tools/ShapeTool.js | 3 +++ js/tools/drawing-tool-base.js | 63 ++++++++++++++++++++++++------------------- js/tools/drawing-tool.js | 3 ++- 3 files changed, 41 insertions(+), 28 deletions(-) (limited to 'js/tools') diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index 8f45891d..d2337000 100755 --- a/js/tools/ShapeTool.js +++ b/js/tools/ShapeTool.js @@ -106,6 +106,9 @@ exports.ShapeTool = Montage.create(DrawingTool, { if(wasSelected) { this.AddCustomFeedback(); this.application.ninja.elementMediator.addDelegate = this; + if(this.application.ninja.currentSelectedContainer.nodeName === "CANVAS") { + this._targetedElement = this.application.ninja.currentSelectedContainer; + } } else { this.RemoveCustomFeedback(); this.application.ninja.elementMediator.addDelegate = null; diff --git a/js/tools/drawing-tool-base.js b/js/tools/drawing-tool-base.js index 0b51aa28..7d97f105 100755 --- a/js/tools/drawing-tool-base.js +++ b/js/tools/drawing-tool-base.js @@ -24,6 +24,9 @@ exports.DrawingToolBase = Montage.create(Montage, { value: null }, + dragPlane: { + value: null + }, /** * Used on the initial MouseDown for Drawing Tools * @@ -33,28 +36,30 @@ exports.DrawingToolBase = Montage.create(Montage, { * 2 - Y value converted to screen point */ getInitialSnapPoint: { - value: function(x,y) { + value: function(x, y, shapeCanvas) { + snapManager.clearDragPlane(); + // update the snap settings snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() ); snapManager.enableElementSnap( snapManager.elementSnapEnabledAppLevel() ); snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() ); // do the snap - var hitRec = snapManager.snap(x, y, true); - var dragPlane; + this.dragPlane = null; + var hitRec = snapManager.snap(x, y, true); if (hitRec) { - // set up the working plane and convert the hit record to be working plane relative - if (hitRec.getElement() === snapManager.application.ninja.currentSelectedContainer) + if (shapeCanvas) { - dragPlane = viewUtils.getUnprojectedElementPlane( hitRec.getElement() ); - snapManager.setupDragPlaneFromPlane( dragPlane ); + this.dragPlane = viewUtils.getUnprojectedElementPlane( shapeCanvas ); + snapManager.setupDragPlaneFromPlane( this.dragPlane ); } else { - dragPlane = snapManager.setupDragPlanes( hitRec ); + this.dragPlane = snapManager.setupDragPlanes( hitRec, true ); } +// console.log( "drag plane: " + this.dragPlane ); - var wpHitRec = hitRec.convertToWorkingPlane( dragPlane ); + var wpHitRec = hitRec.convertToWorkingPlane( this.dragPlane ); var pt = hitRec.getScreenPoint(); return( [wpHitRec, pt[0], pt[1]] ); @@ -72,28 +77,32 @@ exports.DrawingToolBase = Montage.create(Montage, { snapManager.enableElementSnap( snapManager.elementSnapEnabledAppLevel() ); snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() ); - - // do the first snap var hitRec = snapManager.snap(x, y, snap3d ); if (hitRec) { - if ((hitRec.getType() !== hitRec.SNAP_TYPE_STAGE) && !hitRec.isSomeGridTypeSnap()) { - hitRec = hitRec.convertToWorkingPlane( snapManager.getDragPlane() ); - } - - if(downHitRec !== null) { - // if we are working off-plane, do a snap to the projected locations of the geometry - var thePlane = workingPlane; - if (snapManager.hasDragPlane()) - { - thePlane = snapManager.getDragPlane(); - } - - // Return the up HitRec - return hitRec; - } else { - return null; +// if ((hitRec.getType() !== hitRec.SNAP_TYPE_STAGE) && !hitRec.isSomeGridTypeSnap()) { +// hitRec = hitRec.convertToWorkingPlane( snapManager.getDragPlane() ); +// } +// +// if(downHitRec !== null) { +// // if we are working off-plane, do a snap to the projected locations of the geometry +// var thePlane = workingPlane; +// if (snapManager.hasDragPlane()) +// { +// thePlane = snapManager.getDragPlane(); +// } +// +// // Return the up HitRec +// return hitRec; +// } else { +// return null; +// } + if(downHitRec) { + hitRec = hitRec.convertToWorkingPlane(this.dragPlane); + } else if ((hitRec.getType() !== hitRec.SNAP_TYPE_STAGE) && !hitRec.isSomeGridTypeSnap()) { + hitRec = hitRec.convertToWorkingPlane( snapManager.getDragPlane() ); } } + return hitRec; } }, diff --git a/js/tools/drawing-tool.js b/js/tools/drawing-tool.js index dc5f7996..d906fdf9 100755 --- a/js/tools/drawing-tool.js +++ b/js/tools/drawing-tool.js @@ -72,10 +72,11 @@ exports.DrawingTool = Montage.create(ToolBase, { var snapData, point; this._isDrawing = true; + this.mouseDownHitRec = null; this.mouseUpHitRec = null; point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); - snapData = DrawingToolBase.getInitialSnapPoint(point.x, point.y); //event.layerX, event.layerY); + snapData = DrawingToolBase.getInitialSnapPoint(point.x, point.y, this._targetedElement); //event.layerX, event.layerY); this.mouseDownHitRec = snapData[0]; this.downPoint.x = snapData[1]; this.downPoint.y = snapData[2]; -- cgit v1.2.3 From d2a5fcbaed6b3c3377edecbc27e6a2818b79be40 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 2 May 2012 15:34:49 -0700 Subject: Nesting absolute element in the Tag tool. Refactoring element creation and element models Signed-off-by: Valerio Virgillito --- js/tools/TagTool.js | 151 ++++++++++++++++++---------------------------------- 1 file changed, 53 insertions(+), 98 deletions(-) (limited to 'js/tools') diff --git a/js/tools/TagTool.js b/js/tools/TagTool.js index d946db72..6c999df9 100755 --- a/js/tools/TagTool.js +++ b/js/tools/TagTool.js @@ -13,18 +13,14 @@ var DrawingToolBase = require("js/tools/drawing-tool-base").DrawingToolBase; exports.TagTool = Montage.create(DrawingTool, { drawingFeedback: { value: { mode: "Draw3D", type: "rectangle" } }, - _editSymbol: { value: null }, - - editSymbol:{ - get: function() { return this._editSymbol; }, - set: function(item) { - if(item) { -// stageManagerModule.stageManager.drawElementBoundingBox(item, true); + Configure: { + value: function(wasSelected) { + if(wasSelected) { + NJevent("enableStageMove"); + this.application.ninja.stage.stageDeps.snapManager.setupDragPlaneFromPlane( workingPlane ); } else { -// stageManagerModule.stageManager.drawSelectionRec(true); + NJevent("disableStageMove"); } - - this._editSymbol = item; } }, @@ -59,11 +55,9 @@ exports.TagTool = Montage.create(DrawingTool, { this._escape = false; return; } - - var drawData, selectedItem; if(this._hasDraw) { - drawData = this.getDrawingData(); + var drawData = this.getDrawingData(); if(drawData) { this.insertElement(drawData); @@ -72,82 +66,60 @@ exports.TagTool = Montage.create(DrawingTool, { this._hasDraw = false; this.endDraw(event); } else { - if(this.editSymbol) { - this.insertElement(); - } else { - //selectedItem = this.doSelection(event); - this.doSelection(event); - } - - this._isDrawing = false; + this.doSelection(event); } - } - }, - HandleDoubleClick: { - value: function(event) { - /* - if(selectionManagerModule.selectionManager.isDocument) { - this.editSymbol = documentManagerModule.DocumentManager.activeDocument.documentRoot; - } else { - this.editSymbol = selectionManagerModule.selectionManager._selectedItems[0]; - } - */ + this._isDrawing = false; } }, - /* This will overwrite the existing function in drawing tool. Do not uncomment - HandleKeyPress: { - value: function(event) { - if(event.metaKey) { - // TODO fix this - if(selectionManagerModule.selectionManager.isDocument) { - this.editSymbol = documentManagerModule.DocumentManager.activeDocument.documentRoot; - } else { - this.editSymbol = selectionManagerModule.selectionManager._selectedItems[0]; - } + // TODO: Fix Classname + // TODO: Add position support + insertElement: { + value: function(drawData) { + var element, styles; + // Create the element + if(this.options.selectedElement === "custom") { + element = document.application.njUtils.make(this.options.customName.value, null, this.application.ninja.currentDocument); + } else { + element = document.application.njUtils.make(this.options.selectedElement, null, this.application.ninja.currentDocument); } - } - }, + // Create the model + document.application.njUtils.createModel(element); - HandleKeyUp: { - value: function(event) { - if(event.keyCode === 93 || event.keyCode === 91) { // Command Keycode - this.editSymbol = null; - } - } - }, - */ - Configure: { - value: function(wasSelected) { - if(wasSelected) { - NJevent("enableStageMove"); - this.application.ninja.stage.stageDeps.snapManager.setupDragPlaneFromPlane( workingPlane ); - } else { - NJevent("disableStageMove"); + // Create the styles + styles = this.makeStylesFromDraw(drawData); + if(element.nodeName === "CANVAS") { + element.width = parseInt(styles.width); + element.height = parseInt(styles.height); + delete styles['width']; + delete styles['height']; } + + // Add the element and styles + this.application.ninja.elementMediator.addElements(element, styles); } }, - - insertElement: { - value: function(data) { - var element; - // TODO Refactor into 1 function - if(data) { - // Get Tag & CSS -- ~~ shortcut for ABS - element = this.makeElement(~~data.width, ~~data.height, data.planeMat, data.midPt, this.makeTag()); + makeStylesFromDraw: { + value: function(drawData) { + var styles = {}; - // Insert Element - this.application.ninja.elementMediator.addElements(element.el, element.data); - } else { - element = this.makeStaticElement(this.makeTag()); - this._insertStatic(this.editSymbol, element.el, element.style); + styles['position'] = "absolute"; + styles['left'] = (Math.round(drawData.midPt[0] - 0.5 * ~~drawData.width)) - this.application.ninja.currentSelectedContainer.offsetLeft + 'px'; + styles['top'] = (Math.round(drawData.midPt[1] - 0.5 * ~~drawData.height)) - this.application.ninja.currentSelectedContainer.offsetTop + 'px'; + styles['width'] = ~~drawData.width + 'px'; + styles['height'] = ~~drawData.height + 'px'; + + if(!MathUtils.isIdentityMatrix(drawData.planeMat)) { + styles['-webkit-transform-style'] = 'preserve-3d'; + styles['-webkit-transform'] = DrawingToolBase.getElementMatrix(drawData.planeMat, drawData.midPt); } + return styles; } }, @@ -157,17 +129,17 @@ exports.TagTool = Montage.create(DrawingTool, { selectedTag = this.options.selectedElement; - if(selectedTag === "divTool") { + if(selectedTag === "div") { newTag = NJUtils.makeNJElement("div", "div", "block"); - } else if(selectedTag === "imageTool") { + } else if(selectedTag === "image") { newTag = NJUtils.makeNJElement("image", "image", "image"); - } else if(selectedTag === "videoTool") { + } else if(selectedTag === "video") { newTag = NJUtils.makeNJElement("video", "video", "video", { innerHTML: "Your browser does not support the VIDEO element." }); - } else if(selectedTag === "canvasTool") { + } else if(selectedTag === "canvas") { newTag = NJUtils.makeNJElement("canvas", "canvas", "canvas"); - } else if(selectedTag === "customTool") { + } else if(selectedTag === "custom") { newTag = NJUtils.makeNJElement(this.options.customName.value, this.options.customName.value, "block"); } /* SWF Tag tool - Not used for now. Will revisit this at a later time. @@ -222,13 +194,13 @@ exports.TagTool = Montage.create(DrawingTool, { makeElement: { value: function(w, h, planeMat, midPt, tag, isShape) { - var left = Math.round(midPt[0] - 0.5 * w); - var top = Math.round(midPt[1] - 0.5 * h); + var left = (Math.round(midPt[0] - 0.5 * w)) - this.application.ninja.currentSelectedContainer.offsetLeft + 'px'; + var top = (Math.round(midPt[1] - 0.5 * h)) - this.application.ninja.currentSelectedContainer.offsetTop + 'px'; var styles = { 'position': 'absolute', - 'top' : top + 'px', - 'left' : left + 'px' + 'top' : top, + 'left' : left }; if(!MathUtils.isIdentityMatrix(planeMat)) { @@ -250,23 +222,6 @@ exports.TagTool = Montage.create(DrawingTool, { return {el: tag, data:styles}; } - }, - - makeStaticElement: { - value: function(tag) { - var styles = { - "-webkit-transform-style": "preserve-3d", - "-webkit-transform": "matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)" - }; - tag.innerHTML = "content"; - - return {el: tag, data:styles}; - } - }, - - _insertStatic: { - value: function(parent, tag, style) { - } } }); -- cgit v1.2.3 From 2078bfa96afaef40acb4edac99848ba55e808ef1 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 3 May 2012 15:15:21 -0700 Subject: Refactor creating elements. Removed makeNJElement and separated the model creation Signed-off-by: Valerio Virgillito --- js/tools/BrushTool.js | 10 ++-- js/tools/EyedropperTool.js | 3 +- js/tools/LineTool.js | 11 ++-- js/tools/PenTool.js | 11 ++-- js/tools/ShapeTool.js | 40 +++---------- js/tools/TagTool.js | 129 +----------------------------------------- js/tools/drawing-tool-base.js | 24 -------- 7 files changed, 25 insertions(+), 203 deletions(-) (limited to 'js/tools') diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js index ded56ecc..5c334b92 100644 --- a/js/tools/BrushTool.js +++ b/js/tools/BrushTool.js @@ -374,13 +374,11 @@ exports.BrushTool = Montage.create(ShapeTool, { return; } - var left = Math.round(midPt[0] - 0.5 * w); - var top = Math.round(midPt[1] - 0.5 * h); - if (!canvas) { - var newCanvas = NJUtils.makeNJElement("canvas", "Brushstroke", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); - var elementModel = TagTool.makeElement(w, h, planeMat, midPt, newCanvas, true); - ElementMediator.addElements(newCanvas, elementModel.data, false); + var newCanvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument); + document.application.njUtils.createModelWithShape(newCanvas, "Brushstroke"); + var styles = document.application.njUtils.stylesFromDraw(newCanvas, w, h, {midPt: midPt, planeMat: planeMat}); + this.application.ninja.elementMediator.addElements(newCanvas, styles, false); // create all the GL stuff var world = this.getGLWorld(newCanvas, this._useWebGL); diff --git a/js/tools/EyedropperTool.js b/js/tools/EyedropperTool.js index 346975b2..6678e498 100755 --- a/js/tools/EyedropperTool.js +++ b/js/tools/EyedropperTool.js @@ -375,7 +375,8 @@ exports.EyedropperTool = Montage.create(toolBase, { var worldData = elt.elementModel.shapeModel.GLWorld.exportJSON(); if(worldData) { - this._webGlDataCanvas = njModule.NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": njModule.NJUtils.generateRandom()}, true); + this._webGlDataCanvas = njModule.NJUtils.make("canvas", {"data-RDGE-id": njModule.NJUtils.generateRandom()}, this.application.ninja.currentDocument); + njModule.NJUtils.createModelWithShape(this._webGlDataCanvas, "Canvas"); this._applyElementStyles(elt, this._webGlDataCanvas, ["display", "position", "width", "height", "-webkit-transform", "-webkit-transform-style"]); this._webGlDataCanvas.style.left = eltCoords[0] + "px"; diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js index 3e9167fd..5941b464 100755 --- a/js/tools/LineTool.js +++ b/js/tools/LineTool.js @@ -77,10 +77,11 @@ exports.LineTool = Montage.create(ShapeTool, { h += ~~(yAdj*2); } - canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); - var elementModel = TagTool.makeElement(w, h, drawData.planeMat, drawData.midPt, canvas, true); - canvas.elementModel.isShape = true; - this.application.ninja.elementMediator.addElements(canvas, elementModel.data); + canvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument); + document.application.njUtils.createModelWithShape(canvas, "Line"); + + var styles = document.application.njUtils.stylesFromDraw(canvas, w, h, drawData); + this.application.ninja.elementMediator.addElements(canvas, styles); } else { canvas = this._targetedElement; canvas.elementModel.controller = ShapesController; @@ -241,7 +242,7 @@ exports.LineTool = Montage.create(ShapeTool, { canvas.elementModel.shapeModel.shapeCount++; if(canvas.elementModel.shapeModel.shapeCount === 1) { - canvas.elementModel.selection = "Line"; +// canvas.elementModel.selection = "Line"; canvas.elementModel.pi = "LinePi"; canvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units; diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index 8ecc9f79..16990ca7 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js @@ -557,17 +557,16 @@ exports.PenTool = Montage.create(ShapeTool, { return; } - w= Math.round(w); + w = Math.round(w); h = Math.round(h); var left = Math.round(midPt[0] - 0.5 * w); var top = Math.round(midPt[1] - 0.5 * h); if (!canvas) { - var newCanvas = null; - newCanvas = NJUtils.makeNJElement("canvas", "Subpath", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); - var elementModel = TagTool.makeElement(parseInt(w), parseInt(h), planeMat, midPt, newCanvas, true); - //note that we set the notify event to false because we send the event separately at end of this code block - ElementMediator.addElements(newCanvas, elementModel.data, false); + var newCanvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument); + document.application.njUtils.createModelWithShape(newCanvas, "Subpath"); + var styles = document.application.njUtils.stylesFromDraw(newCanvas, parseInt(w), parseInt(h), {midPt: midPt, planeMat: planeMat}); + this.application.ninja.elementMediator.addElements(newCanvas, styles, false); // create all the GL stuff var world = this.getGLWorld(newCanvas, this._useWebGL);//this.options.use3D);//this.CreateGLWorld(planeMat, midPt, newCanvas, this._useWebGL);//fillMaterial, strokeMaterial); diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index d2337000..0562dbc2 100755 --- a/js/tools/ShapeTool.js +++ b/js/tools/ShapeTool.js @@ -53,23 +53,17 @@ exports.ShapeTool = Montage.create(DrawingTool, { } }, - HandleLeftButtonUp: - { - value: function (event) - { - var drawData; - - drawData = this.getDrawingData(); + HandleLeftButtonUp: { + value: function (event) { + var canvas, drawData = this.getDrawingData(); if(drawData) { - var canvas; if(!this._useExistingCanvas()) { - canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); - var elementModel = TagTool.makeElement(~~drawData.width, ~~drawData.height, - drawData.planeMat, drawData.midPt, canvas, true); + canvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument); + document.application.njUtils.createModelWithShape(canvas); - canvas.elementModel.isShape = true; - this.application.ninja.elementMediator.addElements(canvas, elementModel.data); + var styles = document.application.njUtils.stylesFromDraw(canvas, ~~drawData.width, ~~drawData.height, drawData); + this.application.ninja.elementMediator.addElements(canvas, styles); } else { canvas = this._targetedElement; if (!canvas.getAttribute( "data-RDGE-id" )) @@ -193,26 +187,6 @@ exports.ShapeTool = Montage.create(DrawingTool, { } }, - createCanvas: { - value: function (left, top, w, h) - { - //var tmpDiv = document.createElement("canvas"); - var tmpDiv = NJUtils.makeNJElement("canvas", "Canvas", "block"); - var rules = { - 'position': 'absolute', - 'top' : top + 'px', - 'left' : left + 'px', - '-webkit-transform-style' : 'preserve-3d', - '-webkit-transform' : 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)' - }; - - tmpDiv.width = w; - tmpDiv.height = h; - - return {el: tmpDiv, rules: rules}; - } - }, - // We can draw on an existing canvas unless it has only a single shape object _useExistingCanvas: { value: function() diff --git a/js/tools/TagTool.js b/js/tools/TagTool.js index 6c999df9..5e9c792b 100755 --- a/js/tools/TagTool.js +++ b/js/tools/TagTool.js @@ -89,139 +89,12 @@ exports.TagTool = Montage.create(DrawingTool, { // Create the model document.application.njUtils.createModel(element); - // Create the styles - styles = this.makeStylesFromDraw(drawData); - if(element.nodeName === "CANVAS") { - element.width = parseInt(styles.width); - element.height = parseInt(styles.height); - delete styles['width']; - delete styles['height']; - } + styles = document.application.njUtils.stylesFromDraw(element, ~~drawData.width, ~~drawData.height, drawData); // Add the element and styles this.application.ninja.elementMediator.addElements(element, styles); } - }, - - makeStylesFromDraw: { - value: function(drawData) { - var styles = {}; - - styles['position'] = "absolute"; - styles['left'] = (Math.round(drawData.midPt[0] - 0.5 * ~~drawData.width)) - this.application.ninja.currentSelectedContainer.offsetLeft + 'px'; - styles['top'] = (Math.round(drawData.midPt[1] - 0.5 * ~~drawData.height)) - this.application.ninja.currentSelectedContainer.offsetTop + 'px'; - styles['width'] = ~~drawData.width + 'px'; - styles['height'] = ~~drawData.height + 'px'; - - if(!MathUtils.isIdentityMatrix(drawData.planeMat)) { - styles['-webkit-transform-style'] = 'preserve-3d'; - styles['-webkit-transform'] = DrawingToolBase.getElementMatrix(drawData.planeMat, drawData.midPt); - } - - return styles; - } - }, - - makeTag: { - value: function() { - var selectedTag, newTag; - - selectedTag = this.options.selectedElement; - - if(selectedTag === "div") { - newTag = NJUtils.makeNJElement("div", "div", "block"); - } else if(selectedTag === "image") { - newTag = NJUtils.makeNJElement("image", "image", "image"); - } else if(selectedTag === "video") { - newTag = NJUtils.makeNJElement("video", "video", "video", { - innerHTML: "Your browser does not support the VIDEO element." - }); - } else if(selectedTag === "canvas") { - newTag = NJUtils.makeNJElement("canvas", "canvas", "canvas"); - } else if(selectedTag === "custom") { - newTag = NJUtils.makeNJElement(this.options.customName.value, this.options.customName.value, "block"); - } - /* SWF Tag tool - Not used for now. Will revisit this at a later time. - else if(selectedTag === "flashTool") { - // Generate the swfobject script tag if not found in the user document -// documentControllerModule.DocumentController.SetSWFObjectScript(); - - newTag = NJUtils.makeNJElement("object", "Object", "block", { - classId: "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" - }); - - var param = NJUtils.makeNJElement("param", "Object", "block", { - name: "movie", - value: "" - }); - - var param2 = NJUtils.makeNJElement("param", "Object","block", { - name: "wmode", - value: "transparent" - }); - - var param3 = NJUtils.makeNJElement("param", "Object","block", { - name: "play", - value: "false" - }); - - - newTag.appendChild(param); - newTag.appendChild(param2); - newTag.appendChild(param3); - // TODO Alternative Content - - } - */ - else { - console.log("Invalid Tool is selected."); - } - - try { -// newTag.className = this.options.classField.value; - // TODO: Fix this one - - } - - catch(err) { - console.log("Could not set Tag ID/Class " + err.description); - } - - return newTag; - } - }, - - makeElement: { - value: function(w, h, planeMat, midPt, tag, isShape) { - var left = (Math.round(midPt[0] - 0.5 * w)) - this.application.ninja.currentSelectedContainer.offsetLeft + 'px'; - var top = (Math.round(midPt[1] - 0.5 * h)) - this.application.ninja.currentSelectedContainer.offsetTop + 'px'; - - var styles = { - 'position': 'absolute', - 'top' : top, - 'left' : left - }; - - if(!MathUtils.isIdentityMatrix(planeMat)) { - styles['-webkit-transform-style'] = 'preserve-3d'; - styles['-webkit-transform'] = DrawingToolBase.getElementMatrix(planeMat, midPt); - } else if(isShape) { - styles['-webkit-transform-style'] = 'preserve-3d'; - } - - // TODO - for canvas, set both as style and attribute. - // Otherwise, we need to create a separate controller for canvas elements - if(tag.tagName === "CANVAS") { - tag.width = w; - tag.height = h; - } else { - styles['width'] = w + 'px'; - styles['height'] = h + 'px'; - } - - return {el: tag, data:styles}; - } } }); diff --git a/js/tools/drawing-tool-base.js b/js/tools/drawing-tool-base.js index 7d97f105..376b3a27 100755 --- a/js/tools/drawing-tool-base.js +++ b/js/tools/drawing-tool-base.js @@ -445,30 +445,6 @@ exports.DrawingToolBase = Montage.create(Montage, { } }, - /** - * Get the matrix for the actual element being added to the user document. - */ - getElementMatrix: { - value: function(planeMat, midPt) { - var divMat, flatMat, flatMatSafe; - // calculate the matrix for the element. - // we should not need to worry about divide by zero below since we snapped to the point - divMat = planeMat.slice(0); - divMat[12] = 0.0; - divMat[13] = 0.0; - //divMat[14] = 0.0; - divMat[14] = midPt[2]; - - // set the left and top of the element such that the center of the rectangle is at the mid point - viewUtils.setViewportObj(this.stage); - - flatMat = divMat; - flatMatSafe = MathUtils.scientificToDecimal(flatMat, 10); - - return "matrix3d(" + flatMatSafe + ")"; - } - }, - /** * Draw Helper Functions */ -- cgit v1.2.3 From 8f1385d4aa12173fb4d9af695b8e5036f675b621 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 4 May 2012 14:39:33 -0700 Subject: Fixing selection and layout code to exclude SCRIPT and STYLE tags. Signed-off-by: Nivesh Rajbhandari --- js/tools/SelectionTool.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'js/tools') diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index 855c7b8c..d3e4ebf9 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js @@ -165,10 +165,11 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { box[3] = point.y; //selectionManagerModule.selectionManager.marqueeSelection(box); - var childNodes = this.application.ninja.currentDocument.documentRoot.childNodes; + var childNodes = this.application.ninja.currentDocument.documentRoot.childNodes, + selectionController = this.application.ninja.selectionController; childNodes = Array.prototype.slice.call(childNodes, 0); childNodes.forEach(function(item) { - if(item.nodeType == 1 && SelectionTool._complicatedCollisionDetection(item, box)) { + if(selectionController.isNodeTraversable(item) && SelectionTool._complicatedCollisionDetection(item, box)) { selectedItems.push(item); } }); -- cgit v1.2.3 From 8f8f7f9a36fb9abadea2a9f25aef0084946bebc9 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 4 May 2012 14:42:00 -0700 Subject: Removed special-casing for new template workflow. Instead, we will enforce a width and height on the body in order to do 3d. Signed-off-by: Nivesh Rajbhandari --- js/tools/RotateStage3DTool.js | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'js/tools') diff --git a/js/tools/RotateStage3DTool.js b/js/tools/RotateStage3DTool.js index 2a9c63db..90cbe95e 100755 --- a/js/tools/RotateStage3DTool.js +++ b/js/tools/RotateStage3DTool.js @@ -96,12 +96,6 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { viewUtils.pushViewportObj( stage ); var eltCtr = viewUtils.getCenterOfProjection(); viewUtils.popViewportObj(); -// if(this.application.ninja.documentController.webTemplate) - if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") - { - eltCtr[0] = stage.scrollWidth/2; - eltCtr[1] = stage.scrollHeight/2; - } var curMat = viewUtils.getMatrixFromElement(stage); var curMatInv = glmat4.inverse(curMat, []); @@ -118,17 +112,7 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { } this._origin = viewUtils.localToGlobal(eltCtr, stage); - -// if(this.application.ninja.documentController.webTemplate) - if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") - { - this._startOriginArray = []; - this._startOriginArray.push(this._origin.slice()); - } - else - { - this._setTransformOrigin(false); - } + this._setTransformOrigin(false); this.DrawHandles(); } }, -- cgit v1.2.3 From 27935436ad8cd0675311667f70b6a285eb126a94 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 4 May 2012 17:10:01 -0700 Subject: Fixing references to iframe's styles in new template. Signed-off-by: Nivesh Rajbhandari --- js/tools/RotateStage3DTool.js | 2 +- js/tools/ZoomTool.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'js/tools') diff --git a/js/tools/RotateStage3DTool.js b/js/tools/RotateStage3DTool.js index 90cbe95e..c8818021 100755 --- a/js/tools/RotateStage3DTool.js +++ b/js/tools/RotateStage3DTool.js @@ -139,7 +139,7 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { // let the document and stage manager know about the zoom change this.application.ninja.stage._firstDraw = true; this.application.ninja.documentBar.zoomFactor = 100; - this.application.ninja.currentDocument.iframe.style.zoom = 1.0; + this.application.ninja.currentDocument.model.views.design.iframe.style.zoom = 1.0; this.application.ninja.stage._firstDraw = false; // TODO - Any updates to the stage should redraw stage's children. Move this to mediator? diff --git a/js/tools/ZoomTool.js b/js/tools/ZoomTool.js index 93caf984..17301262 100755 --- a/js/tools/ZoomTool.js +++ b/js/tools/ZoomTool.js @@ -280,7 +280,9 @@ exports.ZoomTool = Montage.create(DrawingTool, { this.application.ninja.documentBar.zoomFactor = zoomFactor*100; //this.application.ninja.stage.zoomFactor = zoomFactor; if (zoomFactor >= 1) - this.application.ninja.currentDocument.iframe.style.zoom = zoomFactor; + { + this.application.ninja.currentDocument.model.views.design.iframe.style.zoom = zoomFactor; + } this.application.ninja.stage._firstDraw = false; //tmp3 = viewUtils.localToGlobal( localPt, userContent ); // DEBUG - remove this line -- cgit v1.2.3