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 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'js/controllers/elements/element-controller.js') 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: { -- 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 ++++++++++++++++++--------- 1 file changed, 49 insertions(+), 25 deletions(-) (limited to 'js/controllers/elements/element-controller.js') 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); + } } }, //-------------------------------------------------------------------------------------------------------- -- 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/element-controller.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'js/controllers/elements/element-controller.js') 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); -- cgit v1.2.3