Design Question: Organizing Skin by image type

kungfoomasta

14-11-2007 19:05:42

I want to limit SkinSets by image type, for organization and ease of use. This would mean any particular SkinSet would only be made of images of the same type, for example a SkinSet could be only .png files, or only .jpg files.

Currently there are two methods to changing the appearance of a Widget:

Widget::setTexture
Widget::setSkin

The setSkin method is more likely to become the popular choice, because it changes the appearance of the entire widget, not just one component, and can also be recursive. For example, window->setTexture("x.png") will only change the windows background texture, but window->setSkin("x") will change the background, borders, TitleBar and Close Button.

Right now I require the user to supply the extension of the texture to use for setSkin, and assume ".png" if extension isn't given. This is inconvenient for people who use ".jpg" for all their textures, or any other images supported by Ogre, requiring the user to keep track of their texture types.

The changes would be noticed when creating a skin:

SkinSetManager::getSingleton().loadSkin("qgui",".png","myResourceGroup");

The SkinSet "qgui" would only be made of .png files. You can use as many skins as you like in your app, I just want the SkinSet to be limited to a particular image extension.

Are there any problems with this?

Zini

14-11-2007 21:52:32

Can't see any. At least these changes won't have any negative impact on my project.

kungfoomasta

14-11-2007 22:22:37

Zini, do you use SkinSets? I'm leaning towards removing the setTexture function, except for the Image widget. I'm going to refactor QuickGUI so that composition widgets differentiate between a Child Widget, and a Component Widget. The call to setSkin and setFont will automatically apply to all Component Widgets, and can optionally be applied to all children widgets. Are you setting textures manually? How difficult would it be for you to use skins, assuming you aren't using them now?

NickM

15-11-2007 06:34:37

I can't see it being a problem for me.

Zini

15-11-2007 09:08:51

No, I am not using SkinSets. And removing setTexture would indeed be a major problem for me, because I am rendering a scene to a texture, which is displayed as an image in a QuickGUI window.

kungfoomasta

15-11-2007 17:33:43

I would keep the "setTexture" function for the Image widget, so Render To Texture would still be supported by this widget. Basically all widgets will be using skins, except for the Image widget, which will have the same behavior it has now.

Zini

15-11-2007 19:07:37

The image widget is fairly high up in the widget hierarchy. which means almost all widgets would keep the setTexture method.

kungfoomasta

15-11-2007 20:09:15

That's currently true, but I would change this so that the Image has no derived widgets. So widgets like a Label, Panel, etc. would derive from the Widget class, and not the Image class. The current functionality involving setTexture require a lot of bookkeeping, and do not lend well to the idea of Widgets being skinned. With more complex widgets being added in the future, it will be more and more painful to manage, since complex widgets are really just a composition of widgets. Changing just the main container component while holding the rest of the widget's appearance is just odd, and seems unnatural. For example, mConsole->setTexture("someTexture.png") vs. mConsole->setSkin("ziniSkin"). The setTexture method does not really do what is intended, unless the user really wants to change just the base component in a complex widget.

I hope these changes are acceptable. :)

Zini

15-11-2007 20:22:00

Yes, they are. Actually I found it always a bit strange, that almost everything is an Image.