How to dynamically change the Appearance of a control in Manipulate?

How can I dynamically change the appearance of b? Strangely it works for the Enabled state but not for the Appearance.

Thanks.

Manipulate[
bAppearance = If[a > 1, "Open", "Closed"];
bEnabled = If[a > 2, False, True];
Plot[Sin[a x + b],
{x, 0, 6}], {a, 1, 4}, {b, 0, 10, Appearance -> Dynamic@bAppearance}]

-

Here's one way around it -- make the Manipulator dynamic:

Manipulate[
bAppearance = If[a > 1, "Open", "Closed"];
bEnabled = If[a > 2, False, True];
Plot[Sin[a x + b], {x, 0, 6}],
{a, 1, 4}, {b, 0, 10, Dynamic@Manipulator[##, Appearance -> bAppearance] &}]


The Manipulator is recreated when bAppearance changes. It won't be recreated when b changes because b will be wrapped in Dynamic when the control is created.

-

Here's one approach, perhaps not as straightforward as might be hoped for but it works:

Manipulate[
Plot[Sin[a x + b], {x, 0, 6}],

{a, 1, 4},

Row@List@With[{choice = Dynamic[If[a < 2, 1, 2]]},
Overlay[{
Control[{b, 0, 1, Appearance -> "Closed"}],
Control[{b, 0, 1, Appearance -> "Open"}]},
{choice}, choice]]]


Also take a look at the ImageSize settings for Overlay, if the switching has resizing issues.

Edit Oops. We can just do it this way:

Manipulate[
Plot[Sin[a x + b], {x, 0, 6}],

{a, 1, 4},

Row@List@Dynamic[If[a < 2,
Control[{b, 0, 1, Appearance -> "Closed"}],
Control[{b, 0, 1, Appearance -> "Open"}]]]]

-
Very nice thanks! – dabd May 3 '13 at 21:04

You can change the appearance of most controls, but the Manipulator Control has something in it that prevents its dynamic behavior (a bug or a feature ?).

Look (with a slider):

Manipulate[
{Dynamic@a, Plot[Sin[a x + b], {x, 0, 6}]},
{a, 1, 4},
{b, 0, 1, ControlType -> Slider,
Appearance -> Dynamic[If[a > 1, {Tiny}, {Large}]]}]


Now the same with a Manipulator (showing it doesn't work):

Manipulate[
{Dynamic@a, Plot[Sin[a x + b], {x, 0, 6}]},
{a, 1, 4},
{b, 0, 1, ControlType -> Manipulator,
Appearance -> Dynamic[If[a > 1, {Tiny}, {Large}]]}]


-
Interesting, but the problem is that the Sliders don't have an "Open", "Closed" state and I am using Manipulators for that reason. I would like the users to be able to input a value directly. – dabd May 3 '13 at 15:47
@dabd I know. I'm trying to tell you that that isn't going to work easily – Dr. belisarius May 3 '13 at 15:50