summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui/widgets/desktop.cpp24
-rw-r--r--src/gui/widgets/desktop.h6
-rw-r--r--src/resources/image.cpp35
-rw-r--r--src/resources/image.h10
4 files changed, 18 insertions, 57 deletions
diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp
index 4583ef13..13ac866a 100644
--- a/src/gui/widgets/desktop.cpp
+++ b/src/gui/widgets/desktop.cpp
@@ -32,9 +32,6 @@
#include "log.h"
#include "main.h"
-#define VERSION_LABEL_X 25
-#define VERSION_LABEL_Y 2
-
Desktop::Desktop()
: mWallpaper(0)
{
@@ -42,17 +39,9 @@ Desktop::Desktop()
Wallpaper::loadWallpapers();
- gcn::Label *versionLabel = new Label(FULL_VERSION);
- add(versionLabel, VERSION_LABEL_X, VERSION_LABEL_Y);
-
- mVersionRectangle.x = VERSION_LABEL_X;
- mVersionRectangle.y = VERSION_LABEL_Y;
- mVersionRectangle.width = versionLabel->getWidth();
- mVersionRectangle.height = versionLabel->getHeight();
-
- // Loads a white pattern and make it translucent...
- mVersionBorder = Image::getColoredPattern(0xFF, 0xFF, 0xFF);
- mVersionBorder->setAlpha(0.5f);
+ mVersionLabel = new Label(FULL_VERSION);
+ mVersionLabel->setBackgroundColor(gcn::Color(255, 255, 255, 128));
+ add(mVersionLabel, 25, 2);
}
Desktop::~Desktop()
@@ -97,9 +86,8 @@ void Desktop::draw(gcn::Graphics *graphics)
}
// Draw a thin border under the application version...
- g->drawImagePattern(mVersionBorder, mVersionRectangle.x, mVersionRectangle.y,
- mVersionRectangle.width,
- mVersionRectangle.height);
+ g->setColor(gcn::Color(255, 255, 255, 128));
+ g->fillRectangle(gcn::Rectangle(mVersionLabel->getDimension()));
Container::draw(graphics);
}
@@ -128,7 +116,7 @@ void Desktop::setBestFittingWallpaper()
ResourceManager::getInstance()->addResource(idPath, newRsclWlPpr);
mWallpaper = newRsclWlPpr;
}
- else
+ else
mWallpaper = nWallPaper;
}
else
diff --git a/src/gui/widgets/desktop.h b/src/gui/widgets/desktop.h
index 267acead..da623bbd 100644
--- a/src/gui/widgets/desktop.h
+++ b/src/gui/widgets/desktop.h
@@ -24,6 +24,8 @@
#include "gui/widgets/container.h"
+#include "guichanfwd.h"
+
#include <guichan/widgetlistener.hpp>
class Image;
@@ -59,8 +61,8 @@ class Desktop : public Container, gcn::WidgetListener
private:
void setBestFittingWallpaper();
- Image *mWallpaper, *mVersionBorder;
- gcn::Rectangle mVersionRectangle;
+ Image *mWallpaper;
+ gcn::Label *mVersionLabel;
};
#endif // DESKTOP_H
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index 3f9f645a..9af3059a 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -343,7 +343,7 @@ Image* Image::merge(Image *image, int x, int y)
cur_pix = ((Uint32*) mImage->pixels)[current_offset];
// Retreiving each channel of the pixel using pixel format
- r = (Uint8)(((surface_pix & surface_fmt->Rmask) >>
+ r = (Uint8)(((surface_pix & surface_fmt->Rmask) >>
surface_fmt->Rshift) << surface_fmt->Rloss);
g = (Uint8)(((surface_pix & surface_fmt->Gmask) >>
surface_fmt->Gshift) << surface_fmt->Gloss);
@@ -358,14 +358,14 @@ Image* Image::merge(Image *image, int x, int y)
// new pixel with no alpha or nothing on previous pixel
if (a == SDL_ALPHA_OPAQUE || (p_a == 0 && a > 0))
- ((Uint32 *)(surface->pixels))[current_offset] =
+ ((Uint32 *)(surface->pixels))[current_offset] =
SDL_MapRGBA(current_fmt, r, g, b, a);
- else if (a > 0)
+ else if (a > 0)
{ // alpha is lower => merge color with previous value
f_a = (double) a / 255.0;
f_ca = 1.0 - f_a;
f_pa = (double) p_a / 255.0;
- p_r = (Uint8)(((cur_pix & current_fmt->Rmask) >>
+ p_r = (Uint8)(((cur_pix & current_fmt->Rmask) >>
current_fmt->Rshift) << current_fmt->Rloss);
p_g = (Uint8)(((cur_pix & current_fmt->Gmask) >>
current_fmt->Gshift) << current_fmt->Gloss);
@@ -393,42 +393,19 @@ float Image::getAlpha() const
return mAlpha;
}
-Image* Image::getColoredPattern(Uint8 red, Uint8 green, Uint8 blue)
-{
- // A simple pattern used for pattern operations...
- SDL_Surface* tmpSurface = SDL_CreateRGBSurface(SDL_SWSURFACE,
- 2, 2, 32, 0, 0, 0, 0);
-
- Image* patternImage = NULL;
-
- if(tmpSurface)
- {
- //Fill the surface white
- SDL_FillRect(tmpSurface,
- &tmpSurface->clip_rect,
- SDL_MapRGB(tmpSurface->format, red, green, blue));
-
-
- patternImage = Image::load(tmpSurface);
- }
- SDL_FreeSurface(tmpSurface);
-
- return patternImage;
-}
-
Image* Image::SDLgetScaledImage(int width, int height)
{
// No scaling on incorrect new values.
if (width == 0 || height == 0)
return NULL;
-
+
// No scaling when there is ... no different given size ...
if (width == getWidth() && height == getHeight())
return NULL;
Image* scaledImage = NULL;
SDL_Surface* scaledSurface = NULL;
-
+
if (mImage)
{
scaledSurface = _SDLzoomSurface(mImage,
diff --git a/src/resources/image.h b/src/resources/image.h
index c67686e6..f497f608 100644
--- a/src/resources/image.h
+++ b/src/resources/image.h
@@ -89,12 +89,12 @@ class Image : public Resource
/**
* Gets an scaled instance of an image.
- *
+ *
* @param width The desired width of the scaled image.
* @param height The desired height of the scaled image.
*
* @return A new Image* object.
- */
+ */
Image* SDLgetScaledImage(int width, int height);
/**
@@ -138,12 +138,6 @@ class Image : public Resource
*/
float getAlpha() const;
- /**
- * Returns a 2x2 image filled with the desired color.
- * Useful for pattern operations.
- */
- static Image* getColoredPattern(Uint8 red, Uint8 green, Uint8 blue);
-
#ifdef USE_OPENGL
/**
* Sets the target image format. Use <code>false</code> for SDL and