From 52f3551587aad266a794e69416a9662023e55e0f Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Sun, 10 Aug 2008 18:56:10 +0000 Subject: Bugfix: Several text-drawing issues. Bugfix: Overlapping text in text edit dialogs. svn-id: r33768 --- graphics/VectorRenderer.cpp | 27 ++++++++++++++------------- graphics/VectorRenderer.h | 4 ++-- gui/ListWidget.cpp | 2 +- gui/ThemeRenderer.cpp | 15 ++++++--------- gui/ThemeRenderer.h | 2 +- gui/themes/scummodern.zip | Bin 112527 -> 107874 bytes 6 files changed, 24 insertions(+), 26 deletions(-) diff --git a/graphics/VectorRenderer.cpp b/graphics/VectorRenderer.cpp index e3e7174d90..17a221a725 100644 --- a/graphics/VectorRenderer.cpp +++ b/graphics/VectorRenderer.cpp @@ -323,23 +323,24 @@ inline uint32 fp_sqroot(uint32 x) { template void VectorRendererSpec:: drawString(const Graphics::Font *font, const Common::String &text, const Common::Rect &area, - GUI::Theme::TextAlign alignH, GUI::Theme::TextAlignVertical alignV, int deltax) { + GUI::Theme::TextAlign alignH, GUI::Theme::TextAlignVertical alignV, int deltax, bool ellipsis) { - int offset = 0; + int offset = area.top; - switch (alignV) { - case GUI::Theme::kTextAlignVCenter: - offset = area.top + (area.height() - font->getFontHeight()) / 2; - break; - case GUI::Theme::kTextAlignVBottom: - offset = area.bottom - font->getFontHeight(); - break; - case GUI::Theme::kTextAlignVTop: - offset = area.top; - break; + if (font->getFontHeight() < area.height()) { + switch (alignV) { + case GUI::Theme::kTextAlignVCenter: + offset = area.top + ((area.height() - font->getFontHeight()) >> 1); + break; + case GUI::Theme::kTextAlignVBottom: + offset = area.bottom - font->getFontHeight(); + break; + default: + break; + } } - font->drawString(_activeSurface, text, area.left, offset, area.width(), _fgColor, (Graphics::TextAlignment)alignH, deltax, false); + font->drawString(_activeSurface, text, area.left, offset, area.width(), _fgColor, (Graphics::TextAlignment)alignH, deltax, ellipsis); } /** LINES **/ diff --git a/graphics/VectorRenderer.h b/graphics/VectorRenderer.h index 7eff0a9c50..13ba9ff480 100644 --- a/graphics/VectorRenderer.h +++ b/graphics/VectorRenderer.h @@ -477,7 +477,7 @@ public: * Draws a string into the screen. Wrapper for the Graphics::Font string drawing * method. */ - virtual void drawString(const Graphics::Font *font, const Common::String &text, const Common::Rect &area, GUI::Theme::TextAlign alignH, GUI::Theme::TextAlignVertical alignV, int deltax) = 0; + virtual void drawString(const Graphics::Font *font, const Common::String &text, const Common::Rect &area, GUI::Theme::TextAlign alignH, GUI::Theme::TextAlignVertical alignV, int deltax, bool useEllipsis) = 0; /** * Allows to temporarily enable/disable all shadows drawing. @@ -604,7 +604,7 @@ public: void drawString(const Graphics::Font *font, const Common::String &text, const Common::Rect &area, GUI::Theme::TextAlign alignH, - GUI::Theme::TextAlignVertical alignV, int deltax); + GUI::Theme::TextAlignVertical alignV, int deltax, bool elipsis); /** * @see VectorRenderer::setFgColor() diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp index fa79ef4670..5881d9fcef 100644 --- a/gui/ListWidget.cpp +++ b/gui/ListWidget.cpp @@ -407,7 +407,7 @@ void ListWidget::drawWidget() { if (_selectedItem != pos) { width = g_gui.getStringWidth(buffer) + pad; if (width > _w - r.left) - width = _w - r.left; + width = _w - r.left - _hlRightPadding - _scrollBarWidth; } else width = _w - r.left - _hlRightPadding - _scrollBarWidth; if (width > maxWidth) diff --git a/gui/ThemeRenderer.cpp b/gui/ThemeRenderer.cpp index b8d7204669..b179ac75c3 100644 --- a/gui/ThemeRenderer.cpp +++ b/gui/ThemeRenderer.cpp @@ -552,7 +552,7 @@ void ThemeRenderer::drawDDText(const DrawQueueText &q) { restoreBackground(q.area); _vectorRenderer->setFgColor(_texts[q.type]->_color.r, _texts[q.type]->_color.g, _texts[q.type]->_color.b); - _vectorRenderer->drawString(_texts[q.type]->_fontPtr, q.text, q.area, q.alignH, q.alignV, q.deltax); + _vectorRenderer->drawString(_texts[q.type]->_fontPtr, q.text, q.area, q.alignH, q.alignV, q.deltax, q.elipsis); addDirtyRect(q.area); } @@ -781,18 +781,15 @@ void ThemeRenderer::drawText(const Common::Rect &r, const Common::String &str, W if (!ready()) return; - Common::Rect dr = r; - dr.left += deltax; - if (inverted) { queueDD(kDDTextSelectionBackground, r); - queueDDText(kTextDataInverted, dr, str, false, useEllipsis, align); + queueDDText(kTextDataInverted, r, str, false, useEllipsis, align, kTextAlignVCenter, deltax); return; } switch (font) { case kFontStyleNormal: - queueDDText(kTextDataNormalFont, dr, str, true, useEllipsis, align); + queueDDText(kTextDataNormalFont, r, str, true, useEllipsis, align, kTextAlignVCenter, deltax); return; default: @@ -801,15 +798,15 @@ void ThemeRenderer::drawText(const Common::Rect &r, const Common::String &str, W switch (state) { case kStateDisabled: - queueDDText(kTextDataDisabled, dr, str, true, useEllipsis, align); + queueDDText(kTextDataDisabled, r, str, true, useEllipsis, align, kTextAlignVCenter, deltax); return; case kStateHighlight: - queueDDText(kTextDataHover, dr, str, true, useEllipsis, align); + queueDDText(kTextDataHover, r, str, true, useEllipsis, align, kTextAlignVCenter, deltax); return; case kStateEnabled: - queueDDText(kTextDataDefault, dr, str, true, useEllipsis, align); + queueDDText(kTextDataDefault, r, str, true, useEllipsis, align, kTextAlignVCenter, deltax); return; } } diff --git a/gui/ThemeRenderer.h b/gui/ThemeRenderer.h index 5ed5818f73..1c328430e7 100644 --- a/gui/ThemeRenderer.h +++ b/gui/ThemeRenderer.h @@ -94,7 +94,7 @@ protected: friend class GUI::GuiObject; /** Constant value to expand dirty rectangles, to make sure they are fully copied */ - static const int kDirtyRectangleThreshold = 2; + static const int kDirtyRectangleThreshold = 0; /** Sets whether backcaching is enabled */ static const bool kEnableBackCaching = true; diff --git a/gui/themes/scummodern.zip b/gui/themes/scummodern.zip index dd53887cda..aca5fa32a8 100644 Binary files a/gui/themes/scummodern.zip and b/gui/themes/scummodern.zip differ -- cgit v1.2.3