[Scummvm-git-logs] scummvm branch-2-6 -> 17396603680bd8a812bf7a20efe221260452d561
sev-
noreply at scummvm.org
Tue Jun 7 06:53:19 UTC 2022
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
1739660368 GUI: Fix caret position in list widget
Commit: 17396603680bd8a812bf7a20efe221260452d561
https://github.com/scummvm/scummvm/commit/17396603680bd8a812bf7a20efe221260452d561
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2022-06-07T08:53:03+02:00
Commit Message:
GUI: Fix caret position in list widget
Strip formatting from the list widget string before taking the length of
it to calculate the caret position. This can be seen e.g. in the save
dialog when not using the icon view.
Changed paths:
gui/widgets/list.cpp
gui/widgets/list.h
diff --git a/gui/widgets/list.cpp b/gui/widgets/list.cpp
index fa56adcd598..cc047f0a29e 100644
--- a/gui/widgets/list.cpp
+++ b/gui/widgets/list.cpp
@@ -624,6 +624,12 @@ Common::Rect ListWidget::getEditRect() const {
return r;
}
+int ListWidget::getCaretOffset() const {
+ Common::U32String substr(_editString.begin(), _editString.begin() + _caretPos);
+ Common::U32String stripped = stripGUIformatting(substr);
+ return g_gui.getStringWidth(stripped, _font) - _editScrollOffset;
+}
+
void ListWidget::checkBounds() {
if (_currentPos < 0 || _entriesPerPage > (int)_list.size())
_currentPos = 0;
diff --git a/gui/widgets/list.h b/gui/widgets/list.h
index 873364b6394..e1465816f1f 100644
--- a/gui/widgets/list.h
+++ b/gui/widgets/list.h
@@ -165,6 +165,7 @@ protected:
void abortEditMode() override;
Common::Rect getEditRect() const override;
+ int getCaretOffset() const override;
void copyListData(const Common::U32StringArray &list);
More information about the Scummvm-git-logs
mailing list