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/elements') 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 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/elements') 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 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/elements') 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 From 25d639e6c7dd737f4671011faf07091c86c0e324 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 7 Jun 2012 13:13:01 -0700 Subject: fixing the body color chip for non banners templates Signed-off-by: Valerio Virgillito --- js/controllers/elements/body-controller.js | 3 ++- js/controllers/elements/controller-factory.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'js/controllers/elements') diff --git a/js/controllers/elements/body-controller.js b/js/controllers/elements/body-controller.js index 9c427c62..a2aa041f 100755 --- a/js/controllers/elements/body-controller.js +++ b/js/controllers/elements/body-controller.js @@ -30,6 +30,7 @@ exports.BodyController = Montage.create(ElementController, { value: function(el, p) { switch(p) { case "background" : + case "background-color": return this.application.ninja.colorController.getColorObjFromCss(this.application.ninja.stylesController.getElementStyle(el, "background-color", false, true)); case "border": return 0; @@ -47,8 +48,8 @@ exports.BodyController = Montage.create(ElementController, { setProperty: { value: function(el, p, value) { switch(p) { - case "body-background": case "background": + case "background-color": this.application.ninja.stylesController.setElementStyle(el, "background-color", value); break; case "overflow": diff --git a/js/controllers/elements/controller-factory.js b/js/controllers/elements/controller-factory.js index 3ac3fe14..2d2a5cd1 100755 --- a/js/controllers/elements/controller-factory.js +++ b/js/controllers/elements/controller-factory.js @@ -8,7 +8,6 @@ var Montage = require("montage/core/core").Montage; var BodyController = require("js/controllers/elements/body-controller").BodyController, BlockController = require("js/controllers/elements/block-controller").BlockController, - StageController = require("js/controllers/elements/stage-controller").StageController, ShapesController = require("js/controllers/elements/shapes-controller").ShapesController, ImageController = require("js/controllers/elements/image-controller").ImageController, VideoController = require("js/controllers/elements/video-controller").VideoController, @@ -27,7 +26,8 @@ exports.ControllerFactory = Montage.create(Montage, { if(value.indexOf("block") !== -1) { return BlockController; } else if(value.indexOf("stage") !== -1) { - return StageController; +// return StageController; + alert("Calling the stage controller. Should not be calling this object"); } else if(value.indexOf("body") !== -1) { return BodyController; } else if(value.indexOf("shape") !== -1) { -- cgit v1.2.3 From 21098080e7716379ceefefca5f3cc1850ac78fa7 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 7 Jun 2012 15:17:19 -0700 Subject: Body PI fixes. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/body-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/controllers/elements') diff --git a/js/controllers/elements/body-controller.js b/js/controllers/elements/body-controller.js index 9c427c62..106fdcd0 100755 --- a/js/controllers/elements/body-controller.js +++ b/js/controllers/elements/body-controller.js @@ -30,7 +30,7 @@ exports.BodyController = Montage.create(ElementController, { value: function(el, p) { switch(p) { case "background" : - return this.application.ninja.colorController.getColorObjFromCss(this.application.ninja.stylesController.getElementStyle(el, "background-color", false, true)); + return this.application.ninja.colorController.getColorObjFromCss(this.application.ninja.stylesController.getElementStyle(el, "background-color")); case "border": return 0; case "height": -- cgit v1.2.3