From 1fa1faf9119e4dd048bd52fd44ab754b6942c319 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 4 Jun 2012 15:32:20 -0700 Subject: Fixing saveAll from menu This was broken, not sure when it broke, but working again. --- js/controllers/document-controller.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index a90375af..bb0041eb 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -174,9 +174,9 @@ exports.DocumentController = Montage.create(Component, { handleExecuteSaveAll: { value: function(event) { // - if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ + if((typeof this.currentDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ // - this.activeDocument.model.saveAll(); + this.currentDocument.model.saveAll(); } else { //TODO: Add error handling } -- cgit v1.2.3 From d44f3196c925332dcaf45f7cf8c64e22a1994bb9 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 4 Jun 2012 17:11:06 -0700 Subject: Fill and Ink-Bottle fixes. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/element-controller.js | 24 +++++++++++++++++ js/controllers/elements/shapes-controller.js | 38 +++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) (limited to 'js/controllers') diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index 01e132d7..fd4d3c12 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -225,6 +225,30 @@ exports.ElementController = Montage.create(Component, { } }, + getFill: { + value: function(el, fill) { + var fillInfo = {}, + color; + if(fill.colorInfo) { + fillInfo.colorInfo = {}; + color = this.getColor(el, true); + if(color && color.color) { + fillInfo.colorInfo.mode = color.mode; + fillInfo.colorInfo.color = color.color; + } else { + fillInfo.colorInfo.mode = "nocolor"; + fillInfo.colorInfo.color = null; + } + } + return fillInfo; + } + }, + + setFill: { + value: function(el, fill, eventType, source) { + this.setColor(el, fill.colorInfo, true); + } + }, //-------------------------------------------------------------------------------------------------------- // Routines to get/set 3D properties get3DProperty: { diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 626dedb6..f19aaffb 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -584,6 +584,44 @@ exports.ShapesController = Montage.create(CanvasController, { } }, + getFill: { + value: function(el, fill) { + var fillInfo = {}, + color; + if(fill.colorInfo) { + fillInfo.colorInfo = {}; + color = this.getColor(el, true); + if(color && color.color) { + fillInfo.colorInfo.mode = color.mode; + fillInfo.colorInfo.color = color.color; + } else { + fillInfo.colorInfo.mode = "nocolor"; + fillInfo.colorInfo.color = null; + } + } + if(fill.webGLInfo) { + fillInfo.webGLInfo = {}; + if(this.getShapeProperty(el, "useWebGl")) { + fillInfo.webGLInfo.material = this.getProperty("fillMaterial"); + } else { + fillInfo.webGLInfo.material = null; + } + } + return fillInfo; + } + }, + + setFill: { + value: function(el, fill, eventType, source) { + if(fill.colorInfo) { + this.setColor(el, fill.colorInfo, true); + } + if(fill.webGLInfo) { + this.setProperty(el, "fillMaterial", fill.webGLInfo.material, eventType, source); + } + } + }, + DisplayMaterials: { value: function (cb) { -- cgit v1.2.3 From 563935933c191093b8ccd88fd1377775c5641b0d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Mon, 4 Jun 2012 23:33:32 -0700 Subject: components fix: adding a first draw event to components Adding a first draw allows the component to have the right element so that ninja can use it's controller to get the component instance Signed-off-by: Valerio Virgillito --- js/controllers/elements/component-controller.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js index 5b0aaeac..dd0766df 100755 --- a/js/controllers/elements/component-controller.js +++ b/js/controllers/elements/component-controller.js @@ -11,7 +11,7 @@ exports.ComponentController = Montage.create(ElementController, { getProperty: { value: function(el, prop) { - var component = el.controller || this.application.ninja.currentDocument.model.getComponentFromElement(el); + var component = el.controller; switch(prop) { case "id": @@ -34,7 +34,7 @@ exports.ComponentController = Montage.create(ElementController, { setProperty: { value: function(el, p, value) { - var component = el.controller || this.application.ninja.currentDocument.model.getComponentFromElement(el); + var component = el.controller; switch(p) { case "id": -- cgit v1.2.3 From 945fac7b1593260757b6f2864810ca9916d7d698 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 5 Jun 2012 11:36:03 -0700 Subject: Updated ink bottle tool to support color-chip's checkbox and undo/redo for strokes/borders. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/element-controller.js | 74 ++++++++++++++++++--------- js/controllers/elements/shapes-controller.js | 69 +++++++++++++++++-------- 2 files changed, 96 insertions(+), 47 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index fd4d3c12..941e05ba 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -5,7 +5,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot */ var Montage = require("montage/core/core").Montage, - Component = require("montage/ui/component").Component; + Component = require("montage/ui/component").Component, + njModule = require("js/lib/NJUtils"); exports.ElementController = Montage.create(Component, { @@ -162,28 +163,12 @@ exports.ElementController = Montage.create(Component, { el.elementModel.stroke = null; return; case 'gradient': - if(color.borderInfo) { - if(color.borderInfo.borderWidth) { - this.setProperty(el, "border-width", color.borderInfo.borderWidth + color.borderInfo.borderUnits); - } - if(color.borderInfo.borderStyle) { - this.setProperty(el, "border-style", color.borderInfo.borderStyle); - } - } this.setGradientBorder(el, color.color.gradientMode, color.color.css); break; default: this.setProperty(el, "border-image", "none"); this.setProperty(el, "border-image-slice", ""); this.setProperty(el, "border-color", color.color.css); - if(color.borderInfo) { - if(color.borderInfo.borderWidth) { - this.setProperty(el, "border-width", color.borderInfo.borderWidth + color.borderInfo.borderUnits); - } - if(color.borderInfo.borderStyle) { - this.setProperty(el, "border-style", color.borderInfo.borderStyle); - } - } } } el.elementModel.stroke = color; @@ -211,17 +196,54 @@ exports.ElementController = Montage.create(Component, { }, getStroke: { - value: function(el) { - // TODO - Need to figure out which border side user wants - return this.application.ninja.stylesController.getElementStyle(el, "border"); + value: function(el, stroke) { + var strokeInfo = {}, + color, + borderWidth, + border; + if(stroke.colorInfo) { + strokeInfo.colorInfo = {}; + color = this.getColor(el, false); + if(color && color.color) { + strokeInfo.colorInfo.mode = color.mode; + strokeInfo.colorInfo.color = color.color; + } else { + strokeInfo.colorInfo.mode = "nocolor"; + strokeInfo.colorInfo.color = null; + } + } + if(stroke.borderInfo) { + // TODO - Need to figure out which border side user wants + strokeInfo.borderInfo = {}; + if(stroke.borderInfo.borderWidth) { + borderWidth = this.getProperty(el, "border-width"); + if(borderWidth) { + border = njModule.NJUtils.getValueAndUnits(borderWidth); + strokeInfo.borderInfo.borderWidth = border[0]; + strokeInfo.borderInfo.borderUnits = border[1]; + } + } + if(stroke.borderInfo.borderStyle) { + strokeInfo.borderInfo.borderStyle = this.getProperty(el, "border-style"); + } + } + return strokeInfo; } }, setStroke: { value: function(el, stroke) { - this.application.ninja.stylesController.setElementStyle(el, "border-width", stroke.borderWidth + stroke.borderUnits); - this.application.ninja.stylesController.setElementStyle(el, "border-style", stroke.borderStyle); - this.setColor(el, stroke.color, false); + if(stroke.borderInfo) { + if(stroke.borderInfo.borderWidth) { + this.application.ninja.stylesController.setElementStyle(el, "border-width", stroke.borderInfo.borderWidth + stroke.borderInfo.borderUnits); + } + if(stroke.borderInfo.borderStyle) { + this.application.ninja.stylesController.setElementStyle(el, "border-style", stroke.borderInfo.borderStyle); + } + } + if(stroke.colorInfo) { + this.setColor(el, stroke.colorInfo, false); + } } }, @@ -245,8 +267,10 @@ exports.ElementController = Montage.create(Component, { }, setFill: { - value: function(el, fill, eventType, source) { - this.setColor(el, fill.colorInfo, true); + value: function(el, fill) { + if(fill.colorInfo) { + this.setColor(el, fill.colorInfo, true); + } } }, //-------------------------------------------------------------------------------------------------------- diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index f19aaffb..845e7dc2 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -551,12 +551,6 @@ exports.ShapesController = Montage.create(CanvasController, { el.elementModel.shapeModel.GLGeomObj.setStrokeColor(webGl); } } - - // Support for ink-bottle tool - if(color.strokeInfo) - { - this.setProperty(el, "strokeSize", color.strokeInfo.strokeSize + " " + color.strokeInfo.strokeUnits); - } } el.elementModel.shapeModel.GLWorld.render(); this.application.ninja.currentDocument.model.needsSave = true; @@ -564,23 +558,54 @@ exports.ShapesController = Montage.create(CanvasController, { }, getStroke: { - value: function(el) { - // TODO - Need to figure out which border side user wants - var size = this.getShapeProperty(el, "strokeSize"); - var color = this.getShapeProperty(el, "stroke"); - return {stroke:color, strokeSize:size}; + value: function(el, stroke) { + var strokeInfo = {}, + color, + strokeWidth, + strokeSize; + if(stroke.colorInfo) { + strokeInfo.colorInfo = {}; + color = this.getColor(el, false); + if(color && color.color) { + strokeInfo.colorInfo.mode = color.mode; + strokeInfo.colorInfo.color = color.color; + } else { + strokeInfo.colorInfo.mode = "nocolor"; + strokeInfo.colorInfo.color = null; + } + } + if(stroke.shapeInfo) { + strokeInfo.shapeInfo = {}; + strokeWidth = this.getProperty(el, "strokeSize"); + if(strokeWidth) { + strokeSize = njModule.NJUtils.getValueAndUnits(strokeWidth); + strokeInfo.shapeInfo.strokeSize = strokeSize[0]; + strokeInfo.shapeInfo.strokeUnits = strokeSize[1]; + } + } + if(stroke.webGLInfo) { + strokeInfo.webGLInfo = {}; + if(this.getShapeProperty(el, "useWebGl")) { + strokeInfo.webGLInfo.material = this.getProperty(el, "strokeMaterial"); + } else { + strokeInfo.webGLInfo.material = null; + } + } + return strokeInfo; } }, setStroke: { - value: function(el, stroke) { - el.elementModel.shapeModel.GLGeomObj.setStrokeColor(stroke.color.webGlColor); - var strokeWidth = this.GetValueInPixels(stroke.strokeSize, stroke.strokeUnits); - el.elementModel.shapeModel.GLGeomObj.setStrokeWidth(strokeWidth); - this.setShapeProperty(el, "stroke", stroke.color.webGlColor); - this.setShapeProperty(el, "strokeSize", stroke.strokeSize + " " + stroke.strokeUnits); - el.elementModel.shapeModel.GLGeomObj.buildBuffers(); - el.elementModel.shapeModel.GLWorld.render(); + value: function(el, stroke, eventType, source) { + if(stroke.colorInfo) { + this.setColor(el, stroke.colorInfo, false); + } + if(stroke.shapeInfo) { + this.setProperty(el, "strokeSize", stroke.shapeInfo.strokeSize + " " + stroke.shapeInfo.strokeUnits, eventType, source); + } + if(stroke.webGLInfo) { + this.setProperty(el, "strokeMaterial", stroke.webGLInfo.material); + } } }, @@ -602,7 +627,7 @@ exports.ShapesController = Montage.create(CanvasController, { if(fill.webGLInfo) { fillInfo.webGLInfo = {}; if(this.getShapeProperty(el, "useWebGl")) { - fillInfo.webGLInfo.material = this.getProperty("fillMaterial"); + fillInfo.webGLInfo.material = this.getProperty(el, "fillMaterial"); } else { fillInfo.webGLInfo.material = null; } @@ -612,12 +637,12 @@ exports.ShapesController = Montage.create(CanvasController, { }, setFill: { - value: function(el, fill, eventType, source) { + value: function(el, fill) { if(fill.colorInfo) { this.setColor(el, fill.colorInfo, true); } if(fill.webGLInfo) { - this.setProperty(el, "fillMaterial", fill.webGLInfo.material, eventType, source); + this.setProperty(el, "fillMaterial", fill.webGLInfo.material); } } }, -- cgit v1.2.3 From 6372f7acc7e1d9fd6aa93e4afd476ac882a34ecd Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 5 Jun 2012 14:07:06 -0700 Subject: fixing the save as Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index bb0041eb..4f2eff50 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -186,9 +186,9 @@ exports.DocumentController = Montage.create(Component, { handleExecuteSaveAs: { value: function(event) { var saveAsSettings = event._event.settings || {}; - if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ - saveAsSettings.fileName = this.activeDocument.model.file.name; - saveAsSettings.folderUri = this.activeDocument.model.file.uri.substring(0, this.activeDocument.model.file.uri.lastIndexOf("/")); + if((typeof this.currentDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ + saveAsSettings.fileName = this.currentDocument.model.file.name; + saveAsSettings.folderUri = this.currentDocument.model.file.uri.substring(0, this.currentDocument.model.file.uri.lastIndexOf("/")); saveAsSettings.callback = this.saveAsCallback.bind(this); this.application.ninja.newFileController.showSaveAsDialog(saveAsSettings); } @@ -204,9 +204,9 @@ exports.DocumentController = Montage.create(Component, { //TODO: Is this used, should be cleaned up handleExecuteFileCloseAll:{ value: function(event) { - if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ - while(this._documents.length > 0){ - this.closeDocument(this._documents[this._documents.length -1].uuid); + if(this.currentDocument && this.application.ninja.coreIoApi.cloudAvailable()){ + while(this.currentDocument.length > 0){ + this.closeDocument(this.currentDocument[this.currentDocument.length -1].uuid); } } } -- cgit v1.2.3 From 5bf88b70e5cfbc68f3d28e8ad412a98be8e55c11 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 5 Jun 2012 14:27:20 -0700 Subject: fixing the save as Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 4f2eff50..a3ebac24 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -291,19 +291,19 @@ exports.DocumentController = Montage.create(Component, { value:function(saveAsDetails){ var fileUri = null, filename = saveAsDetails.filename, destination = saveAsDetails.destination; //update document metadata - this.activeDocument.name = ""+filename; + this.currentDocument.model.file.name = ""+filename; //prepare new file uri if(destination && (destination.charAt(destination.length -1) !== "/")){ destination = destination + "/"; } fileUri = destination+filename; - this.activeDocument.uri = fileUri; + this.currentDocument.model.file.uri = fileUri; //save a new file //use the ioMediator.fileSaveAll when implemented - this.activeDocument.model.file.name = filename; - this.activeDocument.model.file.uri = fileUri; - this.activeDocument.model.save(); + this.currentDocument.model.file.name = filename; + this.currentDocument.model.file.uri = fileUri; + this.currentDocument.model.save(); } }, -- cgit v1.2.3 From e28eb9158a50d7e6d97dbc68066e591ac600c241 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 5 Jun 2012 21:40:44 -0700 Subject: removing all model creators. The elementModel is now a getter that will create a new model when needed. Signed-off-by: Valerio Virgillito --- js/controllers/elements/body-controller.js | 4 ++-- js/controllers/elements/element-controller.js | 8 ++++---- js/controllers/elements/shapes-controller.js | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/elements/body-controller.js b/js/controllers/elements/body-controller.js index 7a3a66f5..9c427c62 100755 --- a/js/controllers/elements/body-controller.js +++ b/js/controllers/elements/body-controller.js @@ -71,7 +71,7 @@ exports.BodyController = Montage.create(ElementController, { getPerspectiveDist: { value: function(el) { - if(el.elementModel && el.elementModel.props3D && el.elementModel.props3D.perspectiveDist) { + if(el.elementModel.props3D && el.elementModel.props3D.perspectiveDist) { return el.elementModel.props3D.perspectiveDist; } else { var dist = this.application.ninja.stylesController.getPerspectiveDistFromElement(el, true); @@ -83,7 +83,7 @@ exports.BodyController = Montage.create(ElementController, { getMatrix: { value: function(el) { - if(el.elementModel && el.elementModel.props3D && el.elementModel.props3D.matrix3d) + if(el.elementModel.props3D && el.elementModel.props3D.matrix3d) { return el.elementModel.props3D.matrix3d.slice(0); } diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index 01e132d7..0223a6b5 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -36,7 +36,7 @@ exports.ElementController = Montage.create(Component, { // Remove the element from the DOM and clear the GLWord. removeElement: { value: function(el) { - if(el.elementModel && el.elementModel.shapeModel && el.elementModel.shapeModel.GLWorld) { + if(el.elementModel.shapeModel && el.elementModel.shapeModel.GLWorld) { el.elementModel.shapeModel.GLWorld.clearTree(); } el.parentNode.removeChild(el); @@ -229,7 +229,7 @@ exports.ElementController = Montage.create(Component, { // Routines to get/set 3D properties get3DProperty: { value: function(el, prop) { - if(el.elementModel && el.elementModel.props3D) { + if(el.elementModel.props3D) { return el.elementModel.props3D[prop]; } } @@ -237,7 +237,7 @@ exports.ElementController = Montage.create(Component, { getMatrix: { value: function(el) { - if(el.elementModel && el.elementModel.props3D && el.elementModel.props3D.matrix3d) { + if(el.elementModel.props3D && el.elementModel.props3D.matrix3d) { return el.elementModel.props3D.matrix3d.slice(0); } else { var mat; @@ -257,7 +257,7 @@ exports.ElementController = Montage.create(Component, { getPerspectiveDist: { value: function(el) { - if(el.elementModel && el.elementModel.props3D && el.elementModel.props3D.perspectiveDist) { + if(el.elementModel.props3D && el.elementModel.props3D.perspectiveDist) { return el.elementModel.props3D.perspectiveDist; } else { var dist = this.application.ninja.stylesController.getPerspectiveDistFromElement(el, false); diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 626dedb6..ae345489 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -133,7 +133,7 @@ exports.ShapesController = Montage.create(CanvasController, { canvas.setAttribute("data-RDGE-id", njModule.NJUtils.generateRandom()); canvas.width = el.width; canvas.height = el.height; - canvas.elementModel = el.elementModel; + canvas._model = el.elementModel; this.toggleWebGlMode(canvas, value); this.application.ninja.elementMediator.replaceElement(canvas, el); break; -- cgit v1.2.3