- changes transparency parameter of Theme::drawSurface to alpha parameter.
- adds possibility to draw GraphicsWidgets with alpha values. svn-id: r22738
This commit is contained in:
parent
af25e65c31
commit
0a557cf2a4
6 changed files with 15 additions and 30 deletions
|
@ -219,7 +219,7 @@ void ThemeClassic::drawButton(const Common::Rect &r, const Common::String &str,
|
||||||
addDirtyRect(r);
|
addDirtyRect(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThemeClassic::drawSurface(const Common::Rect &r, const Graphics::Surface &surface, kState state, bool transparency) {
|
void ThemeClassic::drawSurface(const Common::Rect &r, const Graphics::Surface &surface, kState state, int alpha) {
|
||||||
if (!_initOk)
|
if (!_initOk)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -624,7 +624,7 @@ void ThemeNew::drawButton(const Common::Rect &r, const Common::String &str, kSta
|
||||||
addDirtyRect(r2);
|
addDirtyRect(r2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThemeNew::drawSurface(const Common::Rect &r, const Graphics::Surface &surface, kState state, bool transparency) {
|
void ThemeNew::drawSurface(const Common::Rect &r, const Graphics::Surface &surface, kState state, int alpha) {
|
||||||
if (!_initOk)
|
if (!_initOk)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -636,25 +636,12 @@ void ThemeNew::drawSurface(const Common::Rect &r, const Graphics::Surface &surfa
|
||||||
|
|
||||||
assert(surface.bytesPerPixel == sizeof(OverlayColor));
|
assert(surface.bytesPerPixel == sizeof(OverlayColor));
|
||||||
|
|
||||||
if (transparency) {
|
if (alpha != 256)
|
||||||
drawSurface(rect, &surface, false, false, 256);
|
restoreBackground(rect);
|
||||||
addDirtyRect(r);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
OverlayColor *src = (OverlayColor *)surface.pixels;
|
drawSurface(rect, &surface, false, false, alpha);
|
||||||
OverlayColor *dst = (OverlayColor *)_screen.getBasePtr(rect.left, rect.top);
|
addDirtyRect(rect);
|
||||||
|
return;
|
||||||
int w = rect.width();
|
|
||||||
int h = rect.height();
|
|
||||||
|
|
||||||
while (h--) {
|
|
||||||
memcpy(dst, src, surface.pitch);
|
|
||||||
src += w;
|
|
||||||
// FIXME: this should be pitch
|
|
||||||
dst += _screen.w;
|
|
||||||
}
|
|
||||||
addDirtyRect(r);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThemeNew::drawSlider(const Common::Rect &rr, int width, kState state) {
|
void ThemeNew::drawSlider(const Common::Rect &rr, int width, kState state) {
|
||||||
|
|
|
@ -452,7 +452,6 @@ LauncherDialog::LauncherDialog()
|
||||||
if (g_gui.evaluator()->getVar("launcher_logo.visible") == 1) {
|
if (g_gui.evaluator()->getVar("launcher_logo.visible") == 1) {
|
||||||
_logo = new GraphicsWidget(this, "launcher_logo");
|
_logo = new GraphicsWidget(this, "launcher_logo");
|
||||||
ThemeNew *th = (ThemeNew *)g_gui.theme();
|
ThemeNew *th = (ThemeNew *)g_gui.theme();
|
||||||
_logo->useTransparency(true);
|
|
||||||
|
|
||||||
_logo->setGfx(th->getImageSurface(th->kThemeLogo));
|
_logo->setGfx(th->getImageSurface(th->kThemeLogo));
|
||||||
|
|
||||||
|
@ -782,7 +781,6 @@ void LauncherDialog::handleScreenChanged() {
|
||||||
if (!_logo)
|
if (!_logo)
|
||||||
_logo = new GraphicsWidget(this, "launcher_logo");
|
_logo = new GraphicsWidget(this, "launcher_logo");
|
||||||
ThemeNew *th = (ThemeNew *)g_gui.theme();
|
ThemeNew *th = (ThemeNew *)g_gui.theme();
|
||||||
_logo->useTransparency(true);
|
|
||||||
|
|
||||||
_logo->setGfx(th->getImageSurface(th->kThemeLogo));
|
_logo->setGfx(th->getImageSurface(th->kThemeLogo));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -142,7 +142,7 @@ public:
|
||||||
|
|
||||||
virtual void drawWidgetBackground(const Common::Rect &r, uint16 hints, kWidgetBackground background = kWidgetBackgroundPlain, kState state = kStateEnabled) = 0;
|
virtual void drawWidgetBackground(const Common::Rect &r, uint16 hints, kWidgetBackground background = kWidgetBackgroundPlain, kState state = kStateEnabled) = 0;
|
||||||
virtual void drawButton(const Common::Rect &r, const Common::String &str, kState state = kStateEnabled) = 0;
|
virtual void drawButton(const Common::Rect &r, const Common::String &str, kState state = kStateEnabled) = 0;
|
||||||
virtual void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, kState state = kStateEnabled, bool transparency = false) = 0;
|
virtual void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, kState state = kStateEnabled, int alpha = 256) = 0;
|
||||||
virtual void drawSlider(const Common::Rect &r, int width, kState state = kStateEnabled) = 0;
|
virtual void drawSlider(const Common::Rect &r, int width, kState state = kStateEnabled) = 0;
|
||||||
virtual void drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, kState state = kStateEnabled) = 0;
|
virtual void drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, kState state = kStateEnabled) = 0;
|
||||||
virtual void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, kState state = kStateEnabled) = 0;
|
virtual void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, kState state = kStateEnabled) = 0;
|
||||||
|
@ -244,7 +244,7 @@ public:
|
||||||
|
|
||||||
void drawWidgetBackground(const Common::Rect &r, uint16 hints, kWidgetBackground background, kState state);
|
void drawWidgetBackground(const Common::Rect &r, uint16 hints, kWidgetBackground background, kState state);
|
||||||
void drawButton(const Common::Rect &r, const String &str, kState state);
|
void drawButton(const Common::Rect &r, const String &str, kState state);
|
||||||
void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, kState state, bool transparency);
|
void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, kState state, int alpha);
|
||||||
void drawSlider(const Common::Rect &r, int width, kState state);
|
void drawSlider(const Common::Rect &r, int width, kState state);
|
||||||
void drawCheckbox(const Common::Rect &r, const String &str, bool checked, kState state);
|
void drawCheckbox(const Common::Rect &r, const String &str, bool checked, kState state);
|
||||||
void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<String> &tabs, int active, uint16 hints, kState state);
|
void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<String> &tabs, int active, uint16 hints, kState state);
|
||||||
|
@ -321,7 +321,7 @@ public:
|
||||||
|
|
||||||
void drawWidgetBackground(const Common::Rect &r, uint16 hints, kWidgetBackground background, kState state);
|
void drawWidgetBackground(const Common::Rect &r, uint16 hints, kWidgetBackground background, kState state);
|
||||||
void drawButton(const Common::Rect &r, const String &str, kState state);
|
void drawButton(const Common::Rect &r, const String &str, kState state);
|
||||||
void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, kState state, bool transparency);
|
void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, kState state, int alpha);
|
||||||
void drawSlider(const Common::Rect &r, int width, kState state);
|
void drawSlider(const Common::Rect &r, int width, kState state);
|
||||||
void drawCheckbox(const Common::Rect &r, const String &str, bool checked, kState state);
|
void drawCheckbox(const Common::Rect &r, const String &str, bool checked, kState state);
|
||||||
void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<String> &tabs, int active, uint16 hints, kState state);
|
void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<String> &tabs, int active, uint16 hints, kState state);
|
||||||
|
|
|
@ -316,7 +316,7 @@ int SliderWidget::posToValue(int pos) {
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
|
||||||
GraphicsWidget::GraphicsWidget(GuiObject *boss, int x, int y, int w, int h)
|
GraphicsWidget::GraphicsWidget(GuiObject *boss, int x, int y, int w, int h)
|
||||||
: Widget(boss, x, y, w, h), _gfx(), _transparency(false) {
|
: Widget(boss, x, y, w, h), _gfx(), _alpha(256) {
|
||||||
_flags = WIDGET_ENABLED | WIDGET_CLEARBG;
|
_flags = WIDGET_ENABLED | WIDGET_CLEARBG;
|
||||||
_type = kGraphicsWidget;
|
_type = kGraphicsWidget;
|
||||||
// HACK: Don't save the background. We want to be sure that redrawing
|
// HACK: Don't save the background. We want to be sure that redrawing
|
||||||
|
@ -326,7 +326,7 @@ GraphicsWidget::GraphicsWidget(GuiObject *boss, int x, int y, int w, int h)
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsWidget::GraphicsWidget(GuiObject *boss, String name)
|
GraphicsWidget::GraphicsWidget(GuiObject *boss, String name)
|
||||||
: Widget(boss, name), _gfx(), _transparency(false) {
|
: Widget(boss, name), _gfx(), _alpha(256) {
|
||||||
_flags = WIDGET_ENABLED | WIDGET_CLEARBG;
|
_flags = WIDGET_ENABLED | WIDGET_CLEARBG;
|
||||||
_type = kGraphicsWidget;
|
_type = kGraphicsWidget;
|
||||||
// HACK: Don't save the background. We want to be sure that redrawing
|
// HACK: Don't save the background. We want to be sure that redrawing
|
||||||
|
@ -352,7 +352,7 @@ void GraphicsWidget::setGfx(const Graphics::Surface *gfx) {
|
||||||
|
|
||||||
void GraphicsWidget::drawWidget(bool hilite) {
|
void GraphicsWidget::drawWidget(bool hilite) {
|
||||||
if (sizeof(OverlayColor) == _gfx.bytesPerPixel && _gfx.pixels) {
|
if (sizeof(OverlayColor) == _gfx.bytesPerPixel && _gfx.pixels) {
|
||||||
g_gui.theme()->drawSurface(Common::Rect(_x, _y, _x+_w, _y+_h), _gfx, Theme::kStateEnabled, _transparency);
|
g_gui.theme()->drawSurface(Common::Rect(_x, _y, _x+_w, _y+_h), _gfx, Theme::kStateEnabled, _alpha);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -271,13 +271,13 @@ public:
|
||||||
|
|
||||||
void setGfx(const Graphics::Surface *gfx);
|
void setGfx(const Graphics::Surface *gfx);
|
||||||
|
|
||||||
void useTransparency(bool state) { _transparency = state; }
|
void useAlpha(int alpha) { _alpha = alpha; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void drawWidget(bool hilite);
|
void drawWidget(bool hilite);
|
||||||
|
|
||||||
Graphics::Surface _gfx;
|
Graphics::Surface _gfx;
|
||||||
bool _transparency;
|
int _alpha;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ContainerWidget */
|
/* ContainerWidget */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue