More MinimalComps updates

A couple of things today.

First is on adding content to Windows and Panels. By default, if you added a child to one of these, it would just add it like any other child, positioning it from the top left of the parent’s position. In particular on the Window, this forced you to reposition your content so it wasn’t on top of the title bar. Also, in either case, if your content was larger than the parent, it would march on outside of the bounds of the parent.

To handle this, I created a content property on these components, which was positioned correctly, and masked the children added to it, so it looked correct. The recommended way of adding children to Panels or Windows was thus:

[code lang=”as3″]window.content.addChild(btn);
panel.content.addChild(myRadioBtn);
// etc.[/code]

or…

[code lang=”as3″]new PushButton(mywindow.content, 10, 10, “click me”);
new RadioButton(mypanel.content, 10, 10, “option 1”);
// etc.[/code]

Unfortunately, this just wasn’t very obvious, and in retrospect, pretty stupid. The proper way would be to override addChild to add the child to the content automatically. So, that’s what I did. I also added a new addRawChild method to each of these components, in case you are doing some custom hackery that really required adding children to the component itself. The following should illustrate the change:

If you were already using content, you won’t see any changes, but you don’t need to use it any more. If you were adding children with addChild and repositioning manually, you’ll probably need to adjust your code to remove those manual adjustments, again, particularly on the Window.

This change also applies to Accordion and Scrollpane, which are based on Panels and Windows.

I also adjusted MinimalConfigurator to account for this, which mainly means I was able to remove the code that checked if the parent had a content property. Now it can always just addChild.

The next change was something else that’s been bugging me for a long time – the PushButton down state. It added an inner drop shadow, but otherwise was not very visible, particularly when using toggle = true. It wasn’t very obvious when a button was toggled in the down state.

So I added a new property on the Style class: Style.BUTTON_DOWN, which is used to redraw the button face when it is down, making it slightly different and much more noticeable. I added values for this to the light and dark themes. If you’ve created custom themes, you can add this to it.

SVN has been updated, and a new SWC and zipped source package have been uploaded to Google Code.

ps. If you used MinimalComps and want to join the conversation, check out the new Google group.

This entry was posted in ActionScript, Components, Flash. Bookmark the permalink.

2 Responses to More MinimalComps updates

  1. dsirijus says:

    Very nice. All those changes are welcome.

  2. Karim says:

    I have just tweaked the MinimalConfigurator for an app i am working on. It has a number of UI’s that use the MinimalConfigurator, i.e;

    settingsUI : MinimalConfigurator;
    renderUI : MinimalConfigurator;
    errorUI : MinimalConfigurator;

    I could have nested each group in it’s own sprite, however it was nice to toggle the visibility of the all components in MinimalConfigurator.

    Made it easy to show different views in my app. So you can now do:

    settingsUI.visible = true;

    Here is the code: http://kurst.co.uk/transfer/MinimalConfigurator.as

    Also ( on another note, you might find this usefull for SpriteSheet ), this PNG encoder is much faster: http://www.blooddy.by/en/crypto/ – I think it was compiled with Haxe.

Leave a Reply