How to do a progression bar with CEGUI ?

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
karmaGfa
Just popping in
Just popping in
Posts: 6
Joined: Wed Jan 19, 2005 07:51
Location: Taiwan

How to do a progression bar with CEGUI ?

Postby karmaGfa » Tue Feb 22, 2005 10:23

Hello,

Does somebody know how to make a progression bar from a picture ?

I mean, I have a graphical bar, and I want to display part of it only, and it will change gradually and programmatically at runtime.

Should I luse a simple CEGUI::StaticImage (how ?) or there is a more suitable component for that ?

Thank you,
Vincent
For the 2005 year, I will not complain anymore about open source projects. :pint:

User avatar
karmaGfa
Just popping in
Just popping in
Posts: 6
Joined: Wed Jan 19, 2005 07:51
Location: Taiwan

Re: How to do a progression bar with CEGUI ?

Postby karmaGfa » Tue Feb 22, 2005 10:39

Lol, I just found a file named "CEGUIProgressBar.h" :oops:
Perhaps it is doing what I want .. :D
For the 2005 year, I will not complain anymore about open source projects. :pint:

User avatar
karmaGfa
Just popping in
Just popping in
Posts: 6
Joined: Wed Jan 19, 2005 07:51
Location: Taiwan

Re: How to do a progression bar with CEGUI ?

Postby karmaGfa » Tue Feb 22, 2005 12:04

Finally, the progress bar doesn't do what I need (my bar is a vertical bar), so I found the solution in the StaticImage :

To avoid the picture to be streched while resizing the componant, I am using the vertical formating :

<pre>
m_pEnergyBar->setVerticalFormatting(StaticImage::VertFormatting::BottomAligned);
</pre>

It was that simple :)
For the 2005 year, I will not complain anymore about open source projects. :pint:

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: How to do a progression bar with CEGUI ?

Postby CrazyEddie » Tue Feb 22, 2005 19:27

Yeah, this would have been my suggestion here, since the current 'looks' can't do what you needed without some modification.

With the approach you've taken you just need to adjust the position and/or size of the StaticImage so that the image it draws gets clipped as required to give the illusion of the progress graphic expanding / retracting.

CE.

User avatar
Assidragon
Just popping in
Just popping in
Posts: 6
Joined: Sun Jan 16, 2005 02:24
Location: Hungary
Contact:

Re: How to do a progression bar with CEGUI ?

Postby Assidragon » Tue Feb 22, 2005 21:54

Well, it has been answered, but I thought I'd just post the other possible way to make it, in case someone would ever like to try it out another way:

Code: Select all

staticImageset->undefineImage((utf8*)imagename);
staticImageset->defineImage((utf8*)imagename,
   Point(0.0f, 0.0f),
   Size(originaltex_x * ratiox, originaltex_y * ratioy),
   Point(0.0f,0.0f));
window->setSize(Size(original_windowx * ratiox, original_windowy * ratioy));


This thing just resets the image of the staticImage, and then sets the staticimage window to the appropiate size. I just like this way because it allows me to have bars that grow towards the left side of the screen, not only to the right.

Agnostos
Just popping in
Just popping in
Posts: 4
Joined: Sat Jul 26, 2008 00:59
Location: Brisbane, Australia

Postby Agnostos » Sat Jul 26, 2008 01:09

Sorry to bring up an old topic guys, however I'm trying not to create un-neccassary threads.

Basically As mentioned above a few years ago by someone else, A Progress bar from an image is what I want.

I've got 2 images from 2 different image sets currently.

The first one I'm calling an overlay i.e. the one at the front.
The second one I'm calling background. i.e. the one behind.

Both images are the same except from some diffeing colours.

Basically I want to remove chunks of the overlay image to show the background image in accordance with a float value.

I'm currently using CEGUI version 0.5, mainly because when I implement 0.6 many many problems occur and I don't want to mess around for another 6 hours re coding my gui manager.

If there is an easy fix for this in the latest version I am happy to update to it if there is an "easy" wqay of implementing this.

Any help would be appreciated.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Mon Jul 28, 2008 08:55

I don't think the situation with progress bars has changed. I'll check a couple of things and maybe get back to you a little later on...

CE.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Mon Jul 28, 2008 10:44

I've looked into this a little...

I'm not sure what 'version' the original issue was raised against. Having looked into the intended implementation for the existing versions (including 0.5.x) this should actually be possible, and the fact that it isn't is a bug (the code that is supposed to calculate the clipping rectangle for the progress imagery is instead affecting the area rectangle used for rendering the imagery itself.

It's an easy fix (if you want a patch against 0.5.x code, you'll have to ask), though since it appears to be a long standing bug, I have to now evaluate the impact of fixing the issue.

CE.

Agnostos
Just popping in
Just popping in
Posts: 4
Joined: Sat Jul 26, 2008 00:59
Location: Brisbane, Australia

Postby Agnostos » Mon Jul 28, 2008 11:45

ahh, many thanks.
so your saying that I'd have to modify the actual CEGUI code to keep the texture the same size, whilst modifying the size of the static image

static image is a defaultwindow * by default for reasons mentioned in the wiki,

I'll look into it.

again, many thanks

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Mon Jul 28, 2008 12:43

No, not really :)

What I'm saying is that the CEGUI ProgressBar widget should do what you want, and in fact, is set up so that it very easily does what you want - that is, it can draw one image (or set of images) as a background, and then uses another image (or set of images) as a foreground that is drawn over the top of the background. The foreground image is clipped according to the current progress, and so obscures some parts of the background, while other parts show though.

This all works 'out of the box' as it were (with appropriate looknfeel definitions), except that prior to my fix, the clipping part was not working as expected; rather than drawing the foreground image full size and clipping it, it would instead scale the imagery to fit into the clipping region (which for some instances is useful and what you want, but not in most(?) cases).

I have fixed this in branches/v0-6, and yes, to get the fix you'd need to modify the CEGUI code and rebuild.

I feel that it's unlikely you'd need to mess around with StaticImages, I can't recall the exact state of things back in Feb 2005, though I'm 99% certain the the original issue related to the 'old' way of rendering, in which the general setup was hard-coded and not easily modified, unlike today where you can hack around on some XML and away you go!

CE.

Agnostos
Just popping in
Just popping in
Posts: 4
Joined: Sat Jul 26, 2008 00:59
Location: Brisbane, Australia

Postby Agnostos » Mon Jul 28, 2008 21:47

ahh okay, updating to version 0.6 then...
and messing with progress bar again..
so get one of the lazy animators I'm working with to draw some art for it and work from there you say.
goodo.

Cheers

oh and I think I'll stay around on these forums for a while. who knows if I need help or can give any.
Well back to work... ahh webcomics.. I mean coding

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Tue Jul 29, 2008 08:39

If you want the version that has the clipping fix you'll need the code from SVN in cegui_mk2/branches/v0-6 - the code in this branch can largely be considered 'stable' as it's where all the maintenance releases are made from. Currently there is no released version that has this fix at present (since it was only fixed yesterday - though the fix will be in the next release, be that 0.6.2 or 0.7.0).

If you do not require the fix (depending on your imagery arrangement, you may not, then 0.5.x should still work the same as the unfixed 0.6.x version.

CE.

Agnostos
Just popping in
Just popping in
Posts: 4
Joined: Sat Jul 26, 2008 00:59
Location: Brisbane, Australia

[solved]

Postby Agnostos » Tue Jul 29, 2008 10:41

I've worked out a deal with the project manager and a couple of animators so that we no longer need to use the method mentioned earlier.
We've simply placed an overlay with transparent points in it whilst having a resizing block of solid colour behind it. not as effcient as I'd like, however it's simple.

Many thanks.

Consider this problem solved


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 4 guests