Skip to main content
bduffy323
Inspiring
February 2, 2012
Answered

Dynamic script UI changes

pc and mac using CS 5.5.

I was wondering if it was possible to have a UI that can change its appearance when a button is selected. For instance I would like to add a panel to the palette when they select a "turn on filter" button that will display some text boxes and radio buttons that will filter a list. Then if they select the "turn off filter" button I would like to remove the panel that holds all the filter fields and resize the window back to its original size. I've tried a combination of this.layout.layout() and this.layout.resize() after hiding the filter panel, but none seem to resize my palette,  it just leaves a gap where the panel was. The only way I can get it to work is to completely redraw the window but it takes too long due to the long list containted in the list box. Any ideas?

This topic is closed to new replies. Start a new post to keep the conversation going.
Marc Autret
Marc AutretCorrect answer
Legend
February 2, 2012

As I already suggested you can change the maximumSize property before win.layout.layout(1) to live-resize your UI.

Here is a simple example:

#targetengine 'testShowHidePanel'

var NULL_SIZE = [0,0],

    MAX_SIZE = [1000,1000];

var u,

    w = new Window('palette'),

    // ---

    p1 = w.add('panel'),

    c1 = p1.add('checkbox', u, "My checkbox1"),

    e1 = p1.add('edittext', u, "Edit text1"),

    // ---

    p2 = w.add('panel'),

    c2 = p2.add('checkbox', u, "My checkbox2"),

    e2 = p2.add('edittext', u, "Edit text2"),

    // ---

    b = w.add('button', u, "Show filter");

p2.visible = false;

p2.maximumSize = NULL_SIZE;

b.onClick = function()

{

    p2.maximumSize = p2.visible ? NULL_SIZE : MAX_SIZE;

    b.text = (p2.visible ? "Show" : "Hide") + " filter";

    p2.visible ^= 1;

    w.layout.layout(1);

};

w.show();

@+

Marc

2 replies

Marc Autret
Marc AutretCorrect answer
Legend
February 2, 2012

As I already suggested you can change the maximumSize property before win.layout.layout(1) to live-resize your UI.

Here is a simple example:

#targetengine 'testShowHidePanel'

var NULL_SIZE = [0,0],

    MAX_SIZE = [1000,1000];

var u,

    w = new Window('palette'),

    // ---

    p1 = w.add('panel'),

    c1 = p1.add('checkbox', u, "My checkbox1"),

    e1 = p1.add('edittext', u, "Edit text1"),

    // ---

    p2 = w.add('panel'),

    c2 = p2.add('checkbox', u, "My checkbox2"),

    e2 = p2.add('edittext', u, "Edit text2"),

    // ---

    b = w.add('button', u, "Show filter");

p2.visible = false;

p2.maximumSize = NULL_SIZE;

b.onClick = function()

{

    p2.maximumSize = p2.visible ? NULL_SIZE : MAX_SIZE;

    b.text = (p2.visible ? "Show" : "Hide") + " filter";

    p2.visible ^= 1;

    w.layout.layout(1);

};

w.show();

@+

Marc

Translate
bduffy323
bduffy323Author
Inspiring
February 3, 2012

That worked just as you described. Thank you. By any chance would you know if it is possible to create a multicolumn listBox that contains images and populate it on creation?

Thanks again!

Message was edited by: bduffy323

Translate