From b3c8a8e1290eae0ca7628562c887cfa0ad354e6a Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 3 Aug 2017 09:48:01 +0200 Subject: GRAPHICS: MACGUI: Align and store MacText selection coordinates --- graphics/macgui/mactext.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'graphics/macgui/mactext.cpp') diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp index 7316e5a680..45e5249bc7 100644 --- a/graphics/macgui/mactext.cpp +++ b/graphics/macgui/mactext.cpp @@ -445,7 +445,7 @@ void MacText::removeLastLine() { _textMaxHeight -= h; } -void MacText::getRowCol(int x, int y, int *col, int *row) { +void MacText::getRowCol(int x, int y, int *sx, int *sy, int *row, int *col) { CLIP(y, 0, _textMaxHeight); // FIXME: We should use bsearch() here @@ -454,6 +454,8 @@ void MacText::getRowCol(int x, int y, int *col, int *row) { while (*row < _textLines.size() - 1 && _textLines[*row].y < y) (*row)++; + *sy = _textLines[*row].y; + *col = 0; int width = 0, pwidth = 0; @@ -476,8 +478,10 @@ void MacText::getRowCol(int x, int y, int *col, int *row) { *col = mcol; for (int i = str.size(); i >= 0; i--) { - if (_textLines[*row].chunks[chunk].getFont()->getStringWidth(str) + pwidth < x) { + int strw = _textLines[*row].chunks[chunk].getFont()->getStringWidth(str); + if (strw + pwidth < x) { *col = mcol + i; + *sx = strw + pwidth; break; } -- cgit v1.2.3