aboutsummaryrefslogtreecommitdiff
path: root/gui/widget.cpp
diff options
context:
space:
mode:
authorEugene Sandulenko2014-05-29 17:49:34 +0300
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commit30f7556beed2de07caa338650a89f18b0b71cae5 (patch)
tree0b3f4c66292285737523fad0a7b756b7d2347bb6 /gui/widget.cpp
parentc6e04845cc753fa219ed5c66a330eabccf2839c7 (diff)
downloadscummvm-rg350-30f7556beed2de07caa338650a89f18b0b71cae5.tar.gz
scummvm-rg350-30f7556beed2de07caa338650a89f18b0b71cae5.tar.bz2
scummvm-rg350-30f7556beed2de07caa338650a89f18b0b71cae5.zip
GUI: Added support for alphabitmaps in picbuttons
Diffstat (limited to 'gui/widget.cpp')
-rw-r--r--gui/widget.cpp85
1 files changed, 66 insertions, 19 deletions
diff --git a/gui/widget.cpp b/gui/widget.cpp
index d3de824fc5..ffdca7337b 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -402,13 +402,15 @@ PicButtonWidget::PicButtonWidget(GuiObject *boss, int x, int y, int w, int h, co
setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG);
_type = kButtonWidget;
+ _mode = ThemeEngine::kAutoScaleNone;
}
PicButtonWidget::PicButtonWidget(GuiObject *boss, const Common::String &name, const char *tooltip, uint32 cmd, uint8 hotkey)
: ButtonWidget(boss, name, "", tooltip, cmd, hotkey),
- _alpha(256), _transparency(false), _showButton(true) {
+ _alpha(256), _transparency(false), _showButton(true), _isAlpha(false) {
setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG);
_type = kButtonWidget;
+ _mode = ThemeEngine::kAutoScaleNone;
}
PicButtonWidget::~PicButtonWidget() {
@@ -436,6 +438,23 @@ void PicButtonWidget::setGfx(const Graphics::Surface *gfx, int statenum) {
_gfx[statenum].copyFrom(*gfx);
}
+void PicButtonWidget::setAGfx(const Graphics::TransparentSurface *gfx, int statenum, ThemeEngine::AutoScaleMode mode) {
+ _agfx[statenum].free();
+
+ if (!gfx || !gfx->getPixels())
+ return;
+
+ if (gfx->format.bytesPerPixel == 1) {
+ warning("PicButtonWidget::setGfx got paletted surface passed");
+ return;
+ }
+
+ _agfx[statenum].copyFrom(*gfx);
+
+ _isAlpha = true;
+ _mode = mode;
+}
+
void PicButtonWidget::setGfx(int w, int h, int r, int g, int b, int statenum) {
if (w == -1)
w = _w;
@@ -453,32 +472,60 @@ void PicButtonWidget::drawWidget() {
if (_showButton)
g_gui.theme()->drawButtonClip(Common::Rect(_x, _y, _x + _w, _y + _h), getBossClipRect(), "", _state, getFlags());
- Graphics::Surface *gfx;
+ if (!_isAlpha) {
+ Graphics::Surface *gfx;
- if (_state == ThemeEngine::kStateHighlight)
- gfx = &_gfx[kPicButtonHighlight];
- else if (_state == ThemeEngine::kStateDisabled)
- gfx = &_gfx[kPicButtonStateDisabled];
- else if (_state == ThemeEngine::kStatePressed)
- gfx = &_gfx[kPicButtonStatePressed];
- else
- gfx = &_gfx[kPicButtonStateEnabled];
+ if (_state == ThemeEngine::kStateHighlight)
+ gfx = &_gfx[kPicButtonHighlight];
+ else if (_state == ThemeEngine::kStateDisabled)
+ gfx = &_gfx[kPicButtonStateDisabled];
+ else if (_state == ThemeEngine::kStatePressed)
+ gfx = &_gfx[kPicButtonStatePressed];
+ else
+ gfx = &_gfx[kPicButtonStateEnabled];
- if (!gfx)
- gfx = &_gfx[kPicButtonStateEnabled];
+ if (!gfx->getPixels())
+ gfx = &_gfx[kPicButtonStateEnabled];
- if (gfx->getPixels()) {
+ if (gfx->getPixels()) {
// Check whether the set up surface needs to be converted to the GUI
// color format.
- const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat();
- if (gfx->format != requiredFormat) {
- gfx->convertToInPlace(requiredFormat);
+ const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat();
+ if (gfx->format != requiredFormat) {
+ gfx->convertToInPlace(requiredFormat);
+ }
+
+ const int x = _x + (_w - gfx->w) / 2;
+ const int y = _y + (_h - gfx->h) / 2;
+
+ g_gui.theme()->drawSurface(Common::Rect(x, y, x + gfx->w, y + gfx->h), *gfx, _state, _alpha, _transparency);
}
+ } else {
+ Graphics::TransparentSurface *gfx;
+
+ if (_state == ThemeEngine::kStateHighlight)
+ gfx = &_agfx[kPicButtonHighlight];
+ else if (_state == ThemeEngine::kStateDisabled)
+ gfx = &_agfx[kPicButtonStateDisabled];
+ else if (_state == ThemeEngine::kStatePressed)
+ gfx = &_agfx[kPicButtonStatePressed];
+ else
+ gfx = &_agfx[kPicButtonStateEnabled];
- const int x = _x + (_w - gfx->w) / 2;
- const int y = _y + (_h - gfx->h) / 2;
+ if (!gfx->getPixels())
+ gfx = &_agfx[kPicButtonStateEnabled];
- g_gui.theme()->drawSurfaceClip(Common::Rect(x, y, x + gfx->w, y + gfx->h), getBossClipRect(), *gfx, _state, _alpha, _transparency);
+ if (gfx->getPixels()) {
+ if (_mode == GUI::ThemeEngine::kAutoScaleNone) {
+ const int x = _x + (_w - gfx->w) / 2;
+ const int y = _y + (_h - gfx->h) / 2;
+
+ g_gui.theme()->drawASurface(Common::Rect(x, y, x + gfx->w, y + gfx->h), *gfx, _mode);
+
+ } else {
+ g_gui.theme()->drawASurface(Common::Rect(_x, _y, _x + _w, _y + _h), *gfx, _mode);
+ }
+ }
}
}