[Scummvm-git-logs] scummvm master -> 19233ca5b1bc8cfed6b4ea8d9e5e242ac318eff0
sev-
sev at scummvm.org
Sat May 2 23:32:29 UTC 2020
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
f883d195d0 GRAPHICS: MACGUI: Added comments and removed redundant methods in MacText
19233ca5b1 GRAPHICS: MACGUI: Implemented cursor positioning with mouse in MacEditableText
Commit: f883d195d0ac3a5acb8c5659ffbd8b4b6cbcd1dd
https://github.com/scummvm/scummvm/commit/f883d195d0ac3a5acb8c5659ffbd8b4b6cbcd1dd
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-05-03T01:31:53+02:00
Commit Message:
GRAPHICS: MACGUI: Added comments and removed redundant methods in MacText
Changed paths:
graphics/macgui/mactext.cpp
graphics/macgui/mactext.h
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 04cd0ad3c4..e8cab1d656 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -679,20 +679,6 @@ void MacText::clearText() {
recalcDims();
}
-void MacText::replaceLastLine(const Common::U32String &str) {
- int oldLen = MAX<int>(0, _textLines.size() - 1);
-
- // TODO: Recalc length, adapt to _textLines
-
- if (_textLines.size())
- _textLines.pop_back();
-
- splitString(str);
- recalcDims();
-
- render(oldLen, _textLines.size());
-}
-
void MacText::removeLastLine() {
if (!_textLines.size())
return;
@@ -767,6 +753,8 @@ void MacText::getRowCol(int x, int y, int *sx, int *sy, int *row, int *col) {
*row = nrow;
}
+// If adjacent chunks have same format, then skip the format definition
+// This happens when a long paragraph is split into several lines
#define ADDFORMATTING() \
if (formatted) { \
formatting = _textLines[i].chunks[chunk].toString(); \
@@ -791,9 +779,10 @@ Common::U32String MacText::getTextChunk(int startRow, int startCol, int endRow,
Common::U32String formatting, prevformatting;
for (int i = startRow; i <= endRow; i++) {
+ // We requested only part of one line
if (i == startRow && i == endRow) {
for (uint chunk = 0; chunk < _textLines[i].chunks.size(); chunk++) {
- if (_textLines[i].chunks[chunk].text.empty())
+ if (_textLines[i].chunks[chunk].text.empty()) // skip empty chunks
continue;
if (startCol <= 0) {
@@ -814,9 +803,10 @@ Common::U32String MacText::getTextChunk(int startRow, int startCol, int endRow,
if (endCol <= 0)
break;
}
+ // We are at the top line and it is not completely requested
} else if (i == startRow && startCol != 0) {
for (uint chunk = 0; chunk < _textLines[i].chunks.size(); chunk++) {
- if (_textLines[i].chunks[chunk].text.empty())
+ if (_textLines[i].chunks[chunk].text.empty()) // skip empty chunks
continue;
if (startCol <= 0) {
@@ -833,9 +823,10 @@ Common::U32String MacText::getTextChunk(int startRow, int startCol, int endRow,
res += '\n';
else
res += ' ';
+ // We are at the end row, and it could be not completely requested
} else if (i == endRow) {
for (uint chunk = 0; chunk < _textLines[i].chunks.size(); chunk++) {
- if (_textLines[i].chunks[chunk].text.empty())
+ if (_textLines[i].chunks[chunk].text.empty()) // skip empty chunks
continue;
ADDFORMATTING();
@@ -850,9 +841,10 @@ Common::U32String MacText::getTextChunk(int startRow, int startCol, int endRow,
if (endCol <= 0)
break;
}
+ // We are in the middle of requested range, pass whole line
} else {
for (uint chunk = 0; chunk < _textLines[i].chunks.size(); chunk++) {
- if (_textLines[i].chunks[chunk].text.empty())
+ if (_textLines[i].chunks[chunk].text.empty()) // skip empty chunks
continue;
ADDFORMATTING();
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index b6e1cd9679..9df142c6bd 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -131,8 +131,6 @@ public:
void appendTextDefault(const Common::U32String &str, bool skipAdd = false);
void appendTextDefault(const Common::String &str, bool skipAdd = false);
void clearText();
- void replaceLastLine(const Common::U32String &str);
- void replaceLastLine(const Common::String &str);
void removeLastLine();
int getLineCount() { return _textLines.size(); }
int getLineCharWidth(int line, bool enforce = false);
Commit: 19233ca5b1bc8cfed6b4ea8d9e5e242ac318eff0
https://github.com/scummvm/scummvm/commit/19233ca5b1bc8cfed6b4ea8d9e5e242ac318eff0
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-05-03T01:31:53+02:00
Commit Message:
GRAPHICS: MACGUI: Implemented cursor positioning with mouse in MacEditableText
Changed paths:
graphics/macgui/maceditabletext.cpp
diff --git a/graphics/macgui/maceditabletext.cpp b/graphics/macgui/maceditabletext.cpp
index 2bce3ed627..c30df8c120 100644
--- a/graphics/macgui/maceditabletext.cpp
+++ b/graphics/macgui/maceditabletext.cpp
@@ -424,21 +424,28 @@ bool MacEditableText::processEvent(Common::Event &event) {
if (_inTextSelection) {
_inTextSelection = false;
- if (!_menu)
- return true;
-
if (_selectedText.endY == -1 ||
(_selectedText.endX == _selectedText.startX && _selectedText.endY == _selectedText.startY)) {
_selectedText.startY = _selectedText.endY = -1;
_contentIsDirty = true;
- _menu->enableCommand("Edit", "Copy", false);
+
+ if (_menu)
+ _menu->enableCommand("Edit", "Copy", false);
+
+ int x = event.mouse.x - getDimensions().left - 2;
+ int y = event.mouse.y - getDimensions().top + _scrollPos;
+
+ MacText::getRowCol(x, y, nullptr, nullptr, &_cursorRow, &_cursorCol);
+ updateCursorPos();
} else {
- _menu->enableCommand("Edit", "Copy", true);
+ if (_menu) {
+ _menu->enableCommand("Edit", "Copy", true);
- bool cutAllowed = isCutAllowed();
+ bool cutAllowed = isCutAllowed();
- _menu->enableCommand("Edit", "Cut", cutAllowed);
- _menu->enableCommand("Edit", "Clear", cutAllowed);
+ _menu->enableCommand("Edit", "Cut", cutAllowed);
+ _menu->enableCommand("Edit", "Clear", cutAllowed);
+ }
}
}
More information about the Scummvm-git-logs
mailing list