diff options
author | Yohann Ferreira <bertram@cegetel.net> | 2005-02-27 01:00:34 +0000 |
---|---|---|
committer | Yohann Ferreira <bertram@cegetel.net> | 2005-02-27 01:00:34 +0000 |
commit | e7af59e38e0b66db5adc4b40d213066b52cb47f2 (patch) | |
tree | dad9607deb4038b27ad510919d25263d632fea0e | |
parent | 500676abe3e03d63c192663db78d5d1f963c18f4 (diff) | |
download | mana-client-e7af59e38e0b66db5adc4b40d213066b52cb47f2.tar.gz mana-client-e7af59e38e0b66db5adc4b40d213066b52cb47f2.tar.bz2 mana-client-e7af59e38e0b66db5adc4b40d213066b52cb47f2.tar.xz mana-client-e7af59e38e0b66db5adc4b40d213066b52cb47f2.zip |
Now only using Image instances. No more SDL_Surface.
-rw-r--r-- | src/gui/progressbar.cpp | 52 | ||||
-rw-r--r-- | src/gui/progressbar.h | 5 |
2 files changed, 11 insertions, 46 deletions
diff --git a/src/gui/progressbar.cpp b/src/gui/progressbar.cpp index 89ad4a9e..211f2fc5 100644 --- a/src/gui/progressbar.cpp +++ b/src/gui/progressbar.cpp @@ -64,24 +64,16 @@ gcn::Widget() dBottomLeftBorder->setAlpha(1.0f); dBottomRightBorder->setAlpha(1.0f); - 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); - } - + colorBar = new Image(); + colorBar->create(getWidth() - 8, getHeight() - 8); + colorBar->fillWithColor(Red, Green, Blue); + colorBar->setAlpha(0.7f); } ProgressBar::~ProgressBar() { #ifndef USE_OPENGL - SDL_FreeSurface(ColorBar); + //SDL_FreeSurface(ColorBar); #endif } @@ -106,20 +98,8 @@ void ProgressBar::draw(gcn::Graphics *graphics) dLeftBorder->drawPattern(screen, absx, absy+4, 4, getHeight()-8); dRightBorder->drawPattern(screen, absx+getWidth()-4, absy+4, 4, getHeight()-8); - // And then, we color the bar to show the progress - if ( ColorBar ) - { - 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); - } + colorBar->draw(screen, 0, 0, absx + 4, absy + 4, + int(progress*float(getWidth()-4)), getHeight() - 8); #endif } @@ -138,20 +118,6 @@ 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); - } - - + colorBar->fillWithColor(Red, Green, Blue); + colorBar->setAlpha(0.7f); } diff --git a/src/gui/progressbar.h b/src/gui/progressbar.h index 81255b6e..5da046b7 100644 --- a/src/gui/progressbar.h +++ b/src/gui/progressbar.h @@ -94,9 +94,8 @@ class ProgressBar : public gcn::Widget { Image *dBackground; Image *dTopLeftBorder, *dTopRightBorder, *dBottomLeftBorder, *dBottomRightBorder; Image *dLeftBorder, *dRightBorder, *dTopBorder, *dBottomBorder; - #ifndef USE_OPENGL - SDL_Surface *ColorBar; - #endif + // Our color bar + Image *colorBar; }; #endif |