Progress Bar new skin

skorpio

09-03-2009 06:08:16

Hello,

I just started using QuickGUI rather successfully after failing to get CEGUI and Hikari to work. So,
Great Work!

I would like to create another skin for the progress bar. However I can't seem to get it working.
I can still use the default.

Here is the code from latest release 1.6.1 Patch (Demo_QuickGUI01.py)

progDesc.widget_name = "Prog"
progDesc.textDesc.segments.append(gui.TextSegment("micross.12",Ogre.ColourValue().White,"Progress Bar"))
progDesc.textDesc.horizontalTextAlignment = gui.TEXT_ALIGNMENT_HORIZONTAL_CENTER
progDesc.widget_dimensions = gui.Rect(100,400,200,35)
progDesc.progressbar_fillDirection = gui.PROGRESSBAR_FILLS_POSITIVE_TO_NEGATIVE
progDesc.progressbar_clippingEdge = gui.PROGRESSBAR_CLIP_RIGHT_TOP
progDesc.progressbar_layout = gui.PROGRESSBAR_LAYOUT_VERTICAL
self.mGUIManager.getActiveSheet().createProgressBar(progDesc)


I tried,

progDesc.widget_setSkinType("newskin")
progDesc.widget_setSkinType ="newskin"
progDesc.setSkinType("newskin")
progDesc.widget.setSkinType("newskin")
progDesc.Widget.setSkinType("newskin")


None of them work. I do have a newskin which I appended to ProgressBar.skinTypes, like this

SkinClass ProgressBar
{
SkinType default
{
}

SkinType newskin
{
}
}


Any suggestions? Thanks
Skorpio

kungfoomasta

09-03-2009 16:28:45

The new skin has to match the skin definition for the widget. QuickGUProgressBar.cpp outlines what ProgressBar skins must contain, but you can always just imitate the default skins I've provided, and follow the same structure:


SkinClass ProgressBar
{
SkinType default
{
SkinElement background
{
Border_Bottom 2
Border_Left 2
Border_Right 2
Border_Top 2
Texture qgui.progressbar1.background.png
TileBackground false
TileBorders true
}

SkinElement bar
{
Border_Bottom 0
Border_Left 0
Border_Right 0
Border_Top 0
Texture qgui.progressbar1.bar.png
TileBackground false
TileBorders false
}

SkinElement clipmap
{
Border_Bottom 0
Border_Left 0
Border_Right 0
Border_Top 0
Texture qgui.progressbar1.clipbox.png
TileBackground false
TileBorders false
}

}

}


ProgressBar skins have 3 SkinElements, the background, the bar that grows/shrinks on top of the background, and the clipmap, which will clip any bar pixels wherever the clipmap has transparent pixels. For easiest results, the clipmap image and the bar image should be the same dimensions.

You can change the skin before creation of the ProgressBar, or after.

Before:

progDesc.widget_skinTypeName = "MySkin";

After:

myProgressBar->setSkinType("MySkin");

To define your own skin, create a new Skin Type inside the "SkinClass ProgressBar" script:


SkinType MySkin
{
SkinElement background
{
}

SkinElement bar
{
}

SkinElement clipmap
{
}

}


(Note if you don't fill in the SkinElements, nothing will be shown. I haven't actually tried to make a transparent ProgressBar, so there may be bugs.)

skorpio

10-03-2009 05:58:56

Hello,

Thanks for your tips. Here is what I got so far.

progDesc.widget_skinTypeName = "MySkin" causes python to crash. Ogre doesn't even load.
and I placed this code before the progress bar was created.

myProgressBar.setSkinType("MySkin") works, sort of.
It loads with the texture of the default bar, but when I add this workaround, the progressbar loads with the correct texture.

myProgressBar.setProgress(myProgressBar.getProgress())

Thanks,

Skorpio

kungfoomasta

10-03-2009 17:33:20

Hm, sounds like a bug on my part. Can you email me the Skin definition and the texture files, and I'll try to repro/fix the issue? I'll pm you my email

skorpio

11-03-2009 03:59:23

Hello,

Here are the files you requested.
I made copies of the texture you provided, change the color and renamed to qui.progressbar2.*.png

http://www.mediafire.com/file/gdyad3wmv ... ground.png
http://www.mediafire.com/file/fyvo1oixj ... r2.bar.png
http://www.mediafire.com/file/jxjjlhuvn ... lipbox.png
http://www.mediafire.com/file/z5zw2xezg ... .skinTypes

I'm using python 1.6.1 (patch) which fixed the Demo_QuickGUI. I'm not sure
what version Andy used to compile it, he doesn't mention it.

Thanks,

Skorpio

kungfoomasta

11-03-2009 17:28:48

Those links don't seem to be working for me. :( Can you email them to benjaminki at hotmail dot com ?

kungfoomasta

14-03-2009 19:46:07

Thanks for the email. Setting the skin in the desc prior to ProgressBar creation didn't give me any problems, however setting the skin after creation didn't update the skin like you mentioned. I've made a few changes, both cases are working for me:




ProgressBarDesc* pd = FactoryManager::getSingleton().getDescFactory()->getInstance<ProgressBarDesc>("DefaultProgressBarDesc");
pd->resetToDefault();
pd->widget_skinTypeName = "testbar";
ProgressBar* pg = mGUIManager->getActiveSheet()->createProgressBar(pd);

ProgressBar* pg2 = mGUIManager->getActiveSheet()->createProgressBar(Rect(300,300,125,25));
pg2->setSkinType("testbar");


Having an empty skin for a ProgressBar will cause a crash, and this is because I end up trying to create an Ogre::Texture of width/height 0. I could try and spend time adding in code to disable users from using empty skins for the ProgressBar, but I don't think users will ever try to create an empty skin for a ProgressBar and try to use it. (pointless?) (Plus I have tons of more important things to focus on. :mrgreen: )

Thanks for pointing out the issue, I the fix is committed into SVN and will be available in the next release.