From 676b6082ab0bcbaf2a5303c7471f87c9cfe847dd Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 3 Aug 2017 19:26:28 +0200 Subject: GRAPHICS: GUI: Mark beginning and end column of selection in MacTextWindow --- graphics/macgui/mactext.h | 2 +- graphics/macgui/mactextwindow.cpp | 26 ++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) (limited to 'graphics') diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h index ffc8c8dc71..7cbf40e8bc 100644 --- a/graphics/macgui/mactext.h +++ b/graphics/macgui/mactext.h @@ -109,6 +109,7 @@ public: void removeLastLine(); int getLineCount() { return _textLines.size(); } int getTextHeight() { return _textMaxHeight; } + int getLineHeight(int line); void render(); Graphics::ManagedSurface *getSurface() { return _surface; } @@ -121,7 +122,6 @@ private: void recalcDims(); void reallocSurface(); int getLineWidth(int line, bool enforce = false); - int getLineHeight(int line); private: MacWindowManager *_wm; diff --git a/graphics/macgui/mactextwindow.cpp b/graphics/macgui/mactextwindow.cpp index 2194fddf36..7873ea2a6c 100644 --- a/graphics/macgui/mactextwindow.cpp +++ b/graphics/macgui/mactextwindow.cpp @@ -164,6 +164,9 @@ void MacTextWindow::drawSelection() { SWAP(s.startCol, s.endCol); } + int lastLineHeight = _mactext->getLineHeight(s.endRow); + s.endY += lastLineHeight; + int start = s.startY - _scrollPos; start = MAX(0, start); @@ -177,10 +180,29 @@ void MacTextWindow::drawSelection() { end = MIN((int)getInnerDimensions().height(), end); + int numLines = 0; + int x1, x2; + for (int y = start; y < end; y++) { - byte *ptr = (byte *)_composeSurface.getBasePtr(kConWOverlap - 2, kConWOverlap - 2 + y); + if (!numLines) { + x1 = 0; + x2 = getInnerDimensions().width(); + + if (y + _scrollPos == s.startY && s.startX > 0) { + numLines = _mactext->getLineHeight(s.startRow); + x1 = s.startX; + } + if (y + _scrollPos == s.endY - lastLineHeight) { + numLines = _mactext->getLineHeight(s.endRow); + x2 = s.endX; + } + } else { + numLines--; + } + + byte *ptr = (byte *)_composeSurface.getBasePtr(x1 + kConWOverlap - 2, y + kConWOverlap - 2); - for (int x = 0; x < getInnerDimensions().width(); x++, ptr++) + for (int x = x1; x < x2; x++, ptr++) if (*ptr == kColorBlack) *ptr = kColorWhite; else -- cgit v1.2.3