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 --- .../properties.reel/sections/custom.reel/custom.js | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'js/panels/properties.reel/sections/custom.reel') 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/custom.reel') 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