allow color modulation for image widgets
This commit is contained in:
parent
0edb0bd6f7
commit
36030fdead
3 changed files with 15 additions and 0 deletions
src/guichan
|
@ -83,8 +83,12 @@ namespace gcn
|
|||
|
||||
virtual bool getDirty() const;
|
||||
|
||||
// only affects the alpha value
|
||||
virtual void setBaseColor(const Color& color);
|
||||
|
||||
private:
|
||||
Image* mImage;
|
||||
Color mColor;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -150,6 +150,9 @@ namespace gcn
|
|||
|
||||
SDL_Surface* srcImage = (SDL_Surface*)image->_getData();
|
||||
|
||||
Color c = getColor();
|
||||
SDL_SetSurfaceColorMod(srcImage, c.r, c.g, c.b);
|
||||
SDL_SetSurfaceAlphaMod(srcImage, c.a);
|
||||
SDL_BlitSurface(srcImage, &src, *mTarget, &dst);
|
||||
}
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@ namespace gcn
|
|||
Icon::Icon(Image* image)
|
||||
{
|
||||
mImage = image;
|
||||
mColor = Color(255, 255, 255, 255);
|
||||
setHeight(image->getHeight());
|
||||
setWidth(image->getWidth());
|
||||
Widget::setDirty(true);
|
||||
|
@ -72,6 +73,7 @@ namespace gcn
|
|||
|
||||
void Icon::draw(Graphics* graphics)
|
||||
{
|
||||
graphics->setColor(mColor);
|
||||
graphics->drawImage(mImage, 0, 0);
|
||||
}
|
||||
|
||||
|
@ -103,4 +105,10 @@ namespace gcn
|
|||
graphics->drawLine(i,height - i, width - i - 1, height - i);
|
||||
}
|
||||
}
|
||||
|
||||
void Icon::setBaseColor(const Color& color)
|
||||
{
|
||||
Widget::setDirty(true);
|
||||
mColor = color;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue