GRAPHICS: MACGUI: change the behavior of cursor and selectedText, currently, we won't draw the cursor when we have selectedText

This commit is contained in:
ysj1173886760 2021-05-27 20:07:52 +08:00 committed by Eugene Sandulenko
parent 0176107051
commit b11dfdfeaa

View File

@ -1049,7 +1049,8 @@ bool MacText::draw(bool forceRedraw) {
_composeSurface->frameRect(borderRect, 0);
}
if (_cursorState)
// if we are drawing the selection text, then we don't draw the cursor
if (_cursorState && !(_selectedText.endY != -1 && _active))
_composeSurface->blitFrom(*_cursorSurface, *_cursorRect, Common::Point(_cursorX, _cursorY + offset.y + 1));
if (_selectedText.endY != -1 && _active)
@ -1106,6 +1107,13 @@ void MacText::drawSelection() {
if (_selectedText.endY == -1)
return;
// we check if the selection size is 0, then we don't draw it anymore
// it's a small optimize, but can bring us correct behavior
if (_selectedText.startX == _selectedText.endX && _selectedText.startY == _selectedText.endY) {
_selectedText.startY = _selectedText.endY = -1;
return;
}
SelectedText s = _selectedText;
if (s.startY > s.endY || (s.startY == s.endY && s.startX > s.endX)) {