From e1c4f30a4c13d747fa69d78598e0961286bbe571 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 20 Mar 2012 10:59:05 -0700 Subject: Support button control in Properties Panel and use them for edit fill and stroke material. Signed-off-by: Nivesh Rajbhandari --- .../sections/custom-rows/dual-row.reel/dual-row.js | 8 +++- .../properties.reel/sections/custom.reel/custom.js | 44 ++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) (limited to 'js/panels/properties.reel/sections') diff --git a/js/panels/properties.reel/sections/custom-rows/dual-row.reel/dual-row.js b/js/panels/properties.reel/sections/custom-rows/dual-row.reel/dual-row.js index 72d216ca..4c5c80d7 100755 --- a/js/panels/properties.reel/sections/custom-rows/dual-row.reel/dual-row.js +++ b/js/panels/properties.reel/sections/custom-rows/dual-row.reel/dual-row.js @@ -43,7 +43,13 @@ exports.DualRow = Montage.create(Component, { this.element.getElementsByClassName("lbl")[0].innerHTML = this.label + ":"; } if(this.label2 !== null) { - this.element.getElementsByClassName("lbl")[1].innerHTML = this.label2 + ":"; + if(this.content2.type === "button") { + this.content2.element = document.createElement("button"); + this.content2.element.classList.add("nj-skinned"); + this.element.getElementsByClassName("lbl")[1].style.display = "none"; + } else { + this.element.getElementsByClassName("lbl")[1].innerHTML = this.label2 + ":"; + } } else { this.element.getElementsByClassName("lbl")[1].style.display = "none"; } diff --git a/js/panels/properties.reel/sections/custom.reel/custom.js b/js/panels/properties.reel/sections/custom.reel/custom.js index 3c595980..d7334afe 100755 --- a/js/panels/properties.reel/sections/custom.reel/custom.js +++ b/js/panels/properties.reel/sections/custom.reel/custom.js @@ -20,6 +20,7 @@ var TextField = require("js/components/textfield.reel").TextField; var FileInput = require("js/components/ui/file-input.reel").FileInput; var Checkbox = require("js/components/checkbox.reel").Checkbox; var ColorChip = require("js/components/ui/color-chip.reel").ColorChip; +var Button = require("montage/ui/button.reel").Button; exports.CustomSection = Montage.create(Component, { @@ -128,6 +129,15 @@ exports.CustomSection = Montage.create(Component, { } }, + handleAction: { + value:function(event) { + if(event._event.wasSetByCode) return; + + var obj = event.currentTarget; + this._dispatchPropEvent({"type": "change", "id": obj.id, "prop": obj.prop, "value": obj.value, "control": obj}); + } + }, + _dispatchPropEvent: { value: function(event) { // console.log(event); @@ -163,6 +173,7 @@ exports.CustomSection = Montage.create(Component, { case "file" : return this.createFileInput(fields); case "checkbox" : return this.createCheckbox(fields); case "chip" : return this.createColorChip(fields); + case "button" : return this.createButton(fields); } } }, @@ -349,6 +360,39 @@ exports.CustomSection = Montage.create(Component, { // TODO - Hack for now to reference the color select object to unregister color chips this.controls["stageBackground"] = obj; + return obj; + } + }, + + createButton: { + value: function(aField) { + var obj = Button.create(); + + // Set Values for Button + if (aField.id) obj.id = aField.id; + if (aField.label) obj.label = aField.label; + if (aField.prop) obj.prop = aField.prop; + + // Special casing button so slot uses "button" tag instead of "div" + obj.type = "button"; + + if (aField.enabled) { + if(aField.enabled.boundObject) { + // TODO - For now, always bind to this.controls[someProperty] + Object.defineBinding(obj, "enabled", { + boundObject: this.controls, + boundObjectPropertyPath: aField.enabled.boundProperty, + oneway: false + }); + } else { + obj.enabled = aField.enabled; + } + } + + obj.addEventListener("action", this, false); + + this.controls[aField.id] = obj; + return obj; } } -- cgit v1.2.3 From 634358d2697d9668bb9406ac7a029aafae542285 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 20 Mar 2012 11:18:07 -0700 Subject: Button's enabled property binding should be oneway only. Signed-off-by: Nivesh Rajbhandari --- js/panels/properties.reel/sections/custom.reel/custom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/panels/properties.reel/sections') diff --git a/js/panels/properties.reel/sections/custom.reel/custom.js b/js/panels/properties.reel/sections/custom.reel/custom.js index d7334afe..703ef950 100755 --- a/js/panels/properties.reel/sections/custom.reel/custom.js +++ b/js/panels/properties.reel/sections/custom.reel/custom.js @@ -382,7 +382,7 @@ exports.CustomSection = Montage.create(Component, { Object.defineBinding(obj, "enabled", { boundObject: this.controls, boundObjectPropertyPath: aField.enabled.boundProperty, - oneway: false + oneway: true }); } else { obj.enabled = aField.enabled; -- cgit v1.2.3