From fa50874d9ca03540dc5741fb51261ef2b56f89ea Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 25 May 2012 15:34:44 -0700 Subject: IKNinja-1491 - Adding slice value to border gradients. Note that using "circle cover" comes close to matching our canvas 2d/WebGL shape's stroke gradients, but still a little off. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/element-controller.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'js/controllers/elements') diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index 20225c61..7bb07976 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -159,8 +159,6 @@ exports.ElementController = Montage.create(Component, { el.elementModel.stroke = null; return; case 'gradient': - this.setProperty(el, "border-image", color.color.css); - this.setProperty(el, "border-color", "none"); if(color.borderInfo) { if(color.borderInfo.borderWidth) { this.setProperty(el, "border-width", color.borderInfo.borderWidth + color.borderInfo.borderUnits); @@ -169,9 +167,11 @@ exports.ElementController = Montage.create(Component, { 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) { @@ -188,6 +188,25 @@ exports.ElementController = Montage.create(Component, { } }, + setGradientBorder: { + value: function(el, gradientMode, css) { + if(gradientMode === "radial") { + this.setProperty(el, "border-image", css.replace("ellipse", "circle")); + } else { + this.setProperty(el, "border-image", css); + } + this.setProperty(el, "border-color", "none"); + // gradient slice = borderWidth/totalWidth + var b = parseInt(this.getProperty(el, "border-left-width", true)), + w = parseInt(this.getProperty(el, "width", true)), + h = parseInt(this.getProperty(el, "height", true)); + if(h > w) { + w = h; + } + this.setProperty(el, "border-image-slice", Math.floor(b/(w+b+b) * 100) + "%"); + } + }, + getStroke: { value: function(el) { // TODO - Need to figure out which border side user wants -- cgit v1.2.3 From 4c3aac5eabd93052b1554a03d78235215bb49db4 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 29 May 2012 00:34:40 -0700 Subject: document bindings phase 1 - using array controller to bind the current document to all ninja components - removed open document event - removed references to the document controller Signed-off-by: Valerio Virgillito --- js/controllers/elements/shapes-controller.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/controllers/elements') diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 38f133b5..626dedb6 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -213,7 +213,7 @@ exports.ShapesController = Montage.create(CanvasController, { default: CanvasController.setProperty(el, p, value); } - this.application.ninja.documentController.activeDocument.model.needsSave = true; + this.application.ninja.currentDocument.model.needsSave = true; } }, @@ -559,7 +559,7 @@ exports.ShapesController = Montage.create(CanvasController, { } } el.elementModel.shapeModel.GLWorld.render(); - this.application.ninja.documentController.activeDocument.model.needsSave = true; + this.application.ninja.currentDocument.model.needsSave = true; } }, -- cgit v1.2.3