GUI: Implemented alphabitmap autoscale

This commit is contained in:
Eugene Sandulenko 2014-05-05 00:52:56 +03:00 committed by Alexander Tkachev
parent f0c52096f3
commit 4474ccf814
6 changed files with 23 additions and 10 deletions

View File

@ -80,6 +80,8 @@ struct DrawStep {
uint32 scale; /**< scale of all the coordinates in FIXED POINT with 16 bits mantissa */
bool autoscale; /**< scale alphaimage if present */
DrawingFunctionCallback drawingCall; /**< Pointer to drawing function */
Graphics::Surface *blitSrc;
Graphics::TransparentSurface *blitAlphaSrc;
@ -428,7 +430,7 @@ public:
void drawCallback_ALPHABITMAP(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) {
uint16 x, y, w, h;
stepGetPositions(step, area, x, y, w, h);
blitAlphaBitmap(step.blitAlphaSrc, Common::Rect(x, y, x + w, y + h)); //TODO
blitAlphaBitmap(step.blitAlphaSrc, Common::Rect(x, y, x + w, y + h), step.autoscale); //TODO
}
void drawCallback_CROSS(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) {
@ -493,7 +495,7 @@ public:
virtual void blitKeyBitmap(const Graphics::Surface *source, const Common::Rect &r) = 0;
virtual void blitKeyBitmapClip(const Graphics::Surface *source, const Common::Rect &r, const Common::Rect &clipping) = 0;
virtual void blitAlphaBitmap(Graphics::TransparentSurface *source, const Common::Rect &r) = 0;
virtual void blitAlphaBitmap(Graphics::TransparentSurface *source, const Common::Rect &r, bool autoscale) = 0;
/**
* Draws a string into the screen. Wrapper for the Graphics::Font string drawing

View File

@ -884,6 +884,17 @@ blitKeyBitmap(const Graphics::Surface *source, const Common::Rect &r) {
}
}
template<typename PixelType>
void VectorRendererSpec<PixelType>::
blitAlphaBitmap(Graphics::TransparentSurface *source, const Common::Rect &r, bool autoscale) {
if (autoscale)
source->blit(*_activeSurface, r.left, r.top, Graphics::FLIP_NONE,
nullptr, TS_ARGB(255, 255, 255, 255),
r.width(), r.height());
else
source->blit(*_activeSurface, r.left, r.top);
}
template<typename PixelType>
void VectorRendererSpec<PixelType>::
blitKeyBitmapClip(const Graphics::Surface *source, const Common::Rect &r, const Common::Rect &clipping) {
@ -943,12 +954,6 @@ blitKeyBitmapClip(const Graphics::Surface *source, const Common::Rect &r, const
}
}
template<typename PixelType>
void VectorRendererSpec<PixelType>::
blitAlphaBitmap(Graphics::TransparentSurface *source, const Common::Rect &r) {
source->blit(*_activeSurface, r.left, r.top);
}
template<typename PixelType>
void VectorRendererSpec<PixelType>::
applyScreenShading(GUI::ThemeEngine::ShadingStyle shadingStyle) {

View File

@ -95,7 +95,7 @@ public:
void blitSubSurfaceClip(const Graphics::Surface *source, const Common::Rect &r, const Common::Rect &clipping);
void blitKeyBitmap(const Graphics::Surface *source, const Common::Rect &r);
void blitKeyBitmapClip(const Graphics::Surface *source, const Common::Rect &r, const Common::Rect &clipping);
void blitAlphaBitmap(Graphics::TransparentSurface *source, const Common::Rect &r);
void blitAlphaBitmap(Graphics::TransparentSurface *source, const Common::Rect &r, bool autoscale);
void applyScreenShading(GUI::ThemeEngine::ShadingStyle shadingStyle);

View File

@ -334,7 +334,7 @@ void ThemeItemABitmap::drawSelf(bool draw, bool restore) {
_engine->restoreBackground(_area);
if (draw)
_engine->renderer()->blitAlphaBitmap(_bitmap, _area);
_engine->renderer()->blitAlphaBitmap(_bitmap, _area, false);
_engine->addDirtyRect(_area);
}

View File

@ -468,6 +468,11 @@ bool ThemeParser::parseDrawStep(ParserNode *stepNode, Graphics::DrawStep *drawst
drawstep->blitAlphaSrc = _theme->getAlphaBitmap(stepNode->values["file"]);
if (stepNode->values.contains("autoscale") && stepNode->values["autoscale"] == "true")
drawstep->autoscale = true;
else
drawstep->autoscale = false;
if (!drawstep->blitAlphaSrc)
return parserError("The given filename hasn't been loaded into the GUI.");
}

View File

@ -146,6 +146,7 @@ protected:
XML_PROP(padding, false)
XML_PROP(orientation, false)
XML_PROP(file, false)
XML_PROP(autoscale, false)
KEY_END()
XML_KEY(text)