summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorYohann Ferreira <bertram@cegetel.net>2005-02-27 01:00:34 +0000
committerYohann Ferreira <bertram@cegetel.net>2005-02-27 01:00:34 +0000
commite7af59e38e0b66db5adc4b40d213066b52cb47f2 (patch)
treedad9607deb4038b27ad510919d25263d632fea0e /src/gui
parent500676abe3e03d63c192663db78d5d1f963c18f4 (diff)
downloadMana-e7af59e38e0b66db5adc4b40d213066b52cb47f2.tar.gz
Mana-e7af59e38e0b66db5adc4b40d213066b52cb47f2.tar.bz2
Mana-e7af59e38e0b66db5adc4b40d213066b52cb47f2.tar.xz
Mana-e7af59e38e0b66db5adc4b40d213066b52cb47f2.zip
Now only using Image instances. No more SDL_Surface.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/progressbar.cpp52
-rw-r--r--src/gui/progressbar.h5
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