diff options
author | Eugene Sandulenko | 2016-12-20 21:07:54 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2016-12-20 21:49:29 +0100 |
commit | 16b0cde5fba7b16ff412710942e95ca91f87cecb (patch) | |
tree | c4de59f5b063abdcc5a317877f5e4bb4782a4c00 | |
parent | 0ccb53472a5dabe4a1f4a87c47a93b31b286b168 (diff) | |
download | scummvm-rg350-16b0cde5fba7b16ff412710942e95ca91f87cecb.tar.gz scummvm-rg350-16b0cde5fba7b16ff412710942e95ca91f87cecb.tar.bz2 scummvm-rg350-16b0cde5fba7b16ff412710942e95ca91f87cecb.zip |
GRAPHICS: Implemented partial MacText drawing
-rw-r--r-- | graphics/macgui/mactext.cpp | 32 | ||||
-rw-r--r-- | graphics/macgui/mactext.h | 1 |
2 files changed, 23 insertions, 10 deletions
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp index 2dc1fc8e2c..389fca4872 100644 --- a/graphics/macgui/mactext.cpp +++ b/graphics/macgui/mactext.cpp @@ -74,12 +74,12 @@ void MacText::splitString(Common::String &str) { } void MacText::reallocSurface() { - int lineHeight = _font->getFontHeight() + _interLinear; - int requiredHeight = (_text.size() + (_text.size() * 10 + 9) / 10) * lineHeight; + int lineH = _font->getFontHeight() + _interLinear; + int requiredH = (_text.size() + (_text.size() * 10 + 9) / 10) * lineH; - if (_surface.w < requiredHeight) { + if (_surface.w < requiredH) { // realloc surface - _surface.create(_maxWidth == -1 ? _textMaxWidth : _maxWidth, requiredHeight); + _surface.create(_maxWidth == -1 ? _textMaxWidth : _maxWidth, requiredH); } } @@ -89,16 +89,28 @@ void MacText::render() { _surface.clear(_bgcolor); - int y = 0; + render(0, _text.size()); - for (uint i = 0; i < _text.size(); i++) { - _font->drawString(&_surface, _text[i], 0, y, _textMaxWidth, _fgcolor); + _fullRefresh = false; + } +} - y += _font->getFontHeight() + _interLinear; - } +void MacText::render(int from, int to) { + from = MAX<int>(0, from); + to = MIN<int>(to, _text.size()); - _fullRefresh = false; + int lineH = _font->getFontHeight() + _interLinear; + int y = from * lineH; + + // Clear the screen + _surface.fillRect(Common::Rect(0, y, _surface.w, to * lineH), _bgcolor); + + for (uint i = from; i < to; i++) { + _font->drawString(&_surface, _text[i], 0, y, _textMaxWidth, _fgcolor); + + y += _font->getFontHeight() + _interLinear; } + } void MacText::draw(ManagedSurface *g, int x, int y, int w, int h, int xoff, int yoff) { diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h index 65e93ca5c3..a133c5c24b 100644 --- a/graphics/macgui/mactext.h +++ b/graphics/macgui/mactext.h @@ -41,6 +41,7 @@ public: private: void splitString(Common::String &s); void render(); + void render(int from, int to); void calcMaxWidth(); void reallocSurface(); |