[Scummvm-git-logs] scummvm master -> fff4cc4fe1218cff10f28fc2d92051898e53bfd1
sev-
sev at scummvm.org
Sun Jul 19 13:44:02 UTC 2020
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
af7c9ab14f GRAPHICS: MACGUI: Implement API for setting selection in MacText
8b6b724726 DIRECTOR: Fix bug with re-activating editable text
575d79b1d4 GRAPHICS: MACGUI: Do not draw selection on non-active MacText
fff4cc4fe1 GRAPHICS: MACGUI: Properly draw re-activated MacText
Commit: af7c9ab14f7328f91303f42c47873f117dbc1f0e
https://github.com/scummvm/scummvm/commit/af7c9ab14f7328f91303f42c47873f117dbc1f0e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-07-19T15:43:45+02:00
Commit Message:
GRAPHICS: MACGUI: Implement API for setting selection 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 27ee0dce2d..5473dc0eef 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -741,15 +741,8 @@ void MacText::setEditable(bool editable) {
if (editable) {
// TODO: Select whole region. This is done every time the text is set from
// uneditable to editable.
- _selectedText.startX = 0;
- _selectedText.startY = 0;
- _selectedText.startCol = 0;
- _selectedText.startRow = 0;
-
- _selectedText.endX = getLineWidth(getLineCount() - 1);;
- _selectedText.endY = getTextHeight();
- _selectedText.endCol = getLineCharWidth(getLineCount() - 1);
- _selectedText.endRow = getLineCount() - 1;
+ setSelection(0, true);
+ setSelection(-1, false);
setActive(editable);
_wm->setActiveWidget(this);
@@ -1018,6 +1011,61 @@ void MacText::clearSelection() {
_selectedText.endY = _selectedText.startY = -1;
}
+void MacText::setSelection(int pos, bool start) {
+ int row = 0, col = 0;
+ int colX = 0;
+
+ while (pos > 0) {
+ if (pos < getLineCharWidth(row)) {
+ for (int i = 0; i < _textLines[row].chunks.size(); i++) {
+ if (pos < _textLines[row].chunks[i].text.size()) {
+ colX += _textLines[row].chunks[i].getFont()->getStringWidth(Common::U32String(_textLines[row].chunks[i].text.c_str(), pos));
+ col += pos;
+ pos = 0;
+ break;
+ } else {
+ colX += _textLines[row].chunks[i].getFont()->getStringWidth(Common::U32String(_textLines[row].chunks[i].text));
+ pos -= _textLines[row].chunks[i].text.size();
+ col += _textLines[row].chunks[i].text.size();
+ }
+ }
+ break;
+ } else {
+ pos -= getLineCharWidth(row);
+ }
+
+ row++;
+ if (row >= _textLines.size()) {
+ colX = _surface->w;
+ col = getLineCharWidth(row);
+
+ break;
+ }
+ }
+
+ if (pos == -1) {
+ row = _textLines.size() - 1;
+ colX = _surface->w;
+ col = getLineCharWidth(row);
+ }
+
+ int rowY = _textLines[row].y;
+
+ if (start) {
+ _selectedText.startX = colX;
+ _selectedText.startY = rowY;
+ _selectedText.startCol = col;
+ _selectedText.startRow = row;
+ } else {
+ _selectedText.endX = colX;
+ _selectedText.endY = rowY;
+ _selectedText.endCol = col;
+ _selectedText.endRow = row;
+ }
+
+ _contentIsDirty = true;
+}
+
bool MacText::isCutAllowed() {
if (_selectedText.startRow >= _editableRow &&
_selectedText.endRow >= _editableRow)
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index cf5227d70a..0a5a52a2d3 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -191,6 +191,8 @@ public:
Common::U32String cutSelection();
const SelectedText *getSelectedText() { return &_selectedText; }
+ void setSelection(int pos, bool start);
+
Common::U32String getEditedString();
private:
Commit: 8b6b7247265f44ea0ba566b19c150d8f7fa1e26e
https://github.com/scummvm/scummvm/commit/8b6b7247265f44ea0ba566b19c150d8f7fa1e26e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-07-19T15:43:45+02:00
Commit Message:
DIRECTOR: Fix bug with re-activating editable text
Changed paths:
engines/director/castmember.cpp
diff --git a/engines/director/castmember.cpp b/engines/director/castmember.cpp
index ca31755029..1b9d47e5e5 100644
--- a/engines/director/castmember.cpp
+++ b/engines/director/castmember.cpp
@@ -543,8 +543,8 @@ bool TextCastMember::setEditable(bool editable) {
}
Graphics::MacText *text = (Graphics::MacText *)_widget;
- text->_focusable = editable;
text->setEditable(editable);
+ text->_focusable = editable;
text->_selectable = editable;
// text->setActive(editable);
Commit: 575d79b1d46a25bb7f5ad1b3ba338c3a65acecb3
https://github.com/scummvm/scummvm/commit/575d79b1d46a25bb7f5ad1b3ba338c3a65acecb3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-07-19T15:43:45+02:00
Commit Message:
GRAPHICS: MACGUI: Do not draw selection on non-active MacText
Changed paths:
graphics/macgui/mactext.cpp
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 5473dc0eef..20d93adadb 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -884,7 +884,7 @@ bool MacText::draw(bool forceRedraw) {
if (_cursorState)
_composeSurface->blitFrom(*_cursorSurface, *_cursorRect, Common::Point(_cursorX, _cursorY + offset.y + 1));
- if (_selectedText.endY != -1)
+ if (_selectedText.endY != -1 && _active)
drawSelection();
return true;
Commit: fff4cc4fe1218cff10f28fc2d92051898e53bfd1
https://github.com/scummvm/scummvm/commit/fff4cc4fe1218cff10f28fc2d92051898e53bfd1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-07-19T15:43:45+02:00
Commit Message:
GRAPHICS: MACGUI: Properly draw re-activated MacText
Changed paths:
graphics/macgui/mactext.cpp
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 20d93adadb..a87aa32cc9 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -738,13 +738,14 @@ void MacText::setEditable(bool editable) {
_editable = editable;
_cursorOff = !editable;
+ setActive(editable);
+ _active = editable;
if (editable) {
// TODO: Select whole region. This is done every time the text is set from
// uneditable to editable.
setSelection(0, true);
setSelection(-1, false);
- setActive(editable);
_wm->setActiveWidget(this);
} else {
undrawCursor();
More information about the Scummvm-git-logs
mailing list