diff options
author | Yohann Ferreira <bertram@cegetel.net> | 2005-02-23 12:28:25 +0000 |
---|---|---|
committer | Yohann Ferreira <bertram@cegetel.net> | 2005-02-23 12:28:25 +0000 |
commit | 32cd4fc75d9700c83117d69fb5aca294f3bae6ab (patch) | |
tree | 45047ff9871429f5ad96d884e09ef6a6548331d1 /src | |
parent | 1128bbe453e5a04ee98b12929537d9f5ca6c8be5 (diff) | |
download | Mana-32cd4fc75d9700c83117d69fb5aca294f3bae6ab.tar.gz Mana-32cd4fc75d9700c83117d69fb5aca294f3bae6ab.tar.bz2 Mana-32cd4fc75d9700c83117d69fb5aca294f3bae6ab.tar.xz Mana-32cd4fc75d9700c83117d69fb5aca294f3bae6ab.zip |
Fully working Progress Bars. Now need to get it used Image instance only.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/progressbar.cpp | 57 | ||||
-rw-r--r-- | src/gui/progressbar.h | 23 |
2 files changed, 62 insertions, 18 deletions
diff --git a/src/gui/progressbar.cpp b/src/gui/progressbar.cpp index 7a520332..89ad4a9e 100644 --- a/src/gui/progressbar.cpp +++ b/src/gui/progressbar.cpp @@ -64,9 +64,17 @@ gcn::Widget() dBottomLeftBorder->setAlpha(1.0f); dBottomRightBorder->setAlpha(1.0f); - // The color bar - ColorBar = SDL_CreateRGBSurface(SDL_SWSURFACE, width-8, height-8, 32, - red, green, blue, 160); + ColorBar = SDL_AllocSurface(SDL_SWSURFACE, getWidth()-8, getHeight()-8, (screen->format->BytesPerPixel*8), 0, 0, 0, 0); + Uint32 boxColor = SDL_MapRGB(screen->format, Red, Green, Blue); + SDL_Rect sourceRect; + sourceRect.x = sourceRect.y = 0; + sourceRect.w = getWidth(); + sourceRect.h = getHeight(); + if ( ColorBar ) + { + SDL_FillRect(ColorBar, &sourceRect, boxColor); + SDL_SetAlpha(ColorBar, SDL_SRCALPHA, 120); + } } @@ -99,19 +107,18 @@ void ProgressBar::draw(gcn::Graphics *graphics) dRightBorder->drawPattern(screen, absx+getWidth()-4, absy+4, 4, getHeight()-8); // And then, we color the bar to show the progress - SDL_Rect srcRect, destRect; - destRect.x = absx+4; - destRect.y = absy+4; - srcRect.x = 0; - srcRect.y = 0; - srcRect.w = getWidth(); - srcRect.h = getHeight(); - if ( ColorBar ) { - if ( ColorBar->w < (srcRect.w)) srcRect.w=ColorBar->w; - if ( ColorBar->h < (srcRect.h)) srcRect.h=ColorBar->h; - SDL_BlitSurface(ColorBar, &srcRect, screen, &destRect); + SDL_Rect screenRect, colorBarRect; + colorBarRect.x = 0; + colorBarRect.y = 0; + colorBarRect.w = int(progress*float(getWidth()-4)); + colorBarRect.h = getHeight(); + screenRect.w = getWidth(); + screenRect.h = getHeight()-4; + screenRect.x = absx+4; + screenRect.y = absy+4; + if ( ColorBar ) SDL_BlitSurface(ColorBar, &colorBarRect, screen, &screenRect); } #endif @@ -126,3 +133,25 @@ float ProgressBar::getProgress() { return progress; } + +void ProgressBar::setColor(unsigned char MyRed, unsigned char MyGreen, + unsigned char MyBlue) +{ + Red = MyRed; Green = MyGreen; Blue = MyBlue; + + SDL_FreeSurface(ColorBar); + ColorBar = SDL_AllocSurface(SDL_SWSURFACE, getWidth()-8, getHeight()-8, + (screen->format->BytesPerPixel*8), 0, 0, 0, 0); + Uint32 boxColor = SDL_MapRGB(screen->format, Red, Green, Blue); + SDL_Rect sourceRect; + sourceRect.x = sourceRect.y = 0; + sourceRect.w = getWidth(); + sourceRect.h = getHeight(); + if ( ColorBar ) + { + SDL_FillRect(ColorBar, &sourceRect, boxColor); + SDL_SetAlpha(ColorBar, SDL_SRCALPHA, 120); + } + + +} diff --git a/src/gui/progressbar.h b/src/gui/progressbar.h index 22161995..81255b6e 100644 --- a/src/gui/progressbar.h +++ b/src/gui/progressbar.h @@ -67,10 +67,25 @@ class ProgressBar : public gcn::Widget { void setColor( unsigned char MyRed, unsigned char MyGreen, - unsigned char MyBlue) - { - Red = MyRed; Green = MyGreen; Blue = MyBlue; - }; + unsigned char MyBlue); + + /** + * Get The red value of color + */ + unsigned char getRed() + { return Red; }; + + /** + * Get The red value of color + */ + unsigned char getGreen() + { return Green; }; + + /** + * Get The red value of color + */ + unsigned char getBlue() + { return Blue; }; private: float progress; |