[Scummvm-git-logs] scummvm master -> f08877734c83538b13ea74c08eaee3b6180574f4
sev-
noreply at scummvm.org
Thu Nov 19 19:46:47 UTC 2026
This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
e712489b6e GUI: Speak list, popup and tab selections moved by keyboard
bc9a62f95f GUI: Speak the widget that receives the focus
fb50b4c7ae GUI: Silence speech when a key is pressed
d9c03aec2f GUI: Describe widgets for speech by the text labelling them
f08877734c TTS: (Windows) - Escape markup in spoken text
Commit: e712489b6eff6c10755d0d1ad83e02956cb5a5ad
https://github.com/scummvm/scummvm/commit/e712489b6eff6c10755d0d1ad83e02956cb5a5ad
Author: objectinspace (amockery at gmail.com)
Date: 2026-11-19T20:46:40+01:00
Commit Message:
GUI: Speak list, popup and tab selections moved by keyboard
The text to speech calls in ListWidget, PopUpDialog and TabWidget all
sat inside their handleMouseMoved() methods, keyed off the position of
the mouse cursor. Moving the selection with the keyboard changed it
silently, so the launcher's game list, the drop-down menus and the tab
bars said nothing at all unless the mouse was used.
Announce the new selection from the keyboard paths as well. ListWidget
speaks from the point where handleKeyDown() has established that the
selection changed, PopUpDialog from setSelection(), which both the
mouse and the arrow keys go through, and TabWidget from adjustTabs(),
which is reached when cycling tabs but not while the dialog is being
built. Each of these updates _lastRead so that the mouse handler does
not repeat what was just said.
Assisted-by: Claude:claude-opus-5
Changed paths:
gui/widgets/list.cpp
gui/widgets/popup.cpp
gui/widgets/tab.cpp
diff --git a/gui/widgets/list.cpp b/gui/widgets/list.cpp
index b5664687ace..0fde3a1c42e 100644
--- a/gui/widgets/list.cpp
+++ b/gui/widgets/list.cpp
@@ -836,6 +836,10 @@ bool ListWidget::handleKeyDown(Common::KeyState state) {
markAsDirty();
if (_selectedItem != oldSelectedItem) {
+ if (_selectedItem >= 0 && _selectedItem < (int)_list.size())
+ read(stripGUIformatting(_list[_selectedItem]));
+ _lastRead = -1;
+
sendCommand(kListSelectionChangedCmd, _selectedItem);
// also draw scrollbar
_scrollBar->markAsDirty();
diff --git a/gui/widgets/popup.cpp b/gui/widgets/popup.cpp
index 6f2091917e1..c6c322aeeaa 100644
--- a/gui/widgets/popup.cpp
+++ b/gui/widgets/popup.cpp
@@ -327,6 +327,14 @@ void PopUpDialog::setSelection(int item) {
// Draw new selection
if (item >= 0)
drawMenuEntry(item, true);
+
+ // Announce the new selection, so that it is not only the mouse that
+ // speaks. Updating _lastRead keeps handleMouseMoved() from repeating
+ // what was just said.
+ if (item >= 0 && item < (int)_entries.size() && _lastRead != item) {
+ read(_entries[item]);
+ _lastRead = item;
+ }
}
}
diff --git a/gui/widgets/tab.cpp b/gui/widgets/tab.cpp
index 83354982ff0..fe168c0a612 100644
--- a/gui/widgets/tab.cpp
+++ b/gui/widgets/tab.cpp
@@ -312,6 +312,14 @@ void TabWidget::adjustTabs(int value) {
setActiveTab(tabID);
+ // Announce the tab we moved to. This is only reached when the user cycles
+ // tabs, not while the dialog is being built, so it will not recite every
+ // tab title on open.
+ if (tabID != _lastRead) {
+ read(_tabs[tabID].title);
+ _lastRead = tabID;
+ }
+
if (_navButtonsVisible) {
if (lastVis != _lastVisibleTab) {
_navLeft->setEnabled(true);
Commit: bc9a62f95fbb583044833a57c5c154a4565d3e51
https://github.com/scummvm/scummvm/commit/bc9a62f95fbb583044833a57c5c154a4565d3e51
Author: objectinspace (amockery at gmail.com)
Date: 2026-11-19T20:46:40+01:00
Commit Message:
GUI: Speak the widget that receives the focus
Moving the focus with the keyboard was silent, so a user relying on
text to speech had no way of telling where they were. The launcher's
Tab key, for instance, moves the focus between the game list and the
search field without saying anything about either.
Add Widget::getSpokenDescription(), which returns the text to announce
when a widget gains the focus, and call it from Dialog::setFocusWidget().
The default implementation returns the tooltip. ListWidget adds the
current selection to it, and EditTextWidget the text entered so far.
Both name the kind of control when there is no tooltip to use, so that
an unlabelled widget is still audible rather than silent.
Nothing is announced while a dialog is being built, only once it is on
screen, and the existing announcements made on mouse hover are
unchanged.
Assisted-by: Claude:claude-opus-5
Changed paths:
gui/dialog.cpp
gui/widget.cpp
gui/widget.h
gui/widgets/edittext.cpp
gui/widgets/edittext.h
gui/widgets/list.cpp
gui/widgets/list.h
diff --git a/gui/dialog.cpp b/gui/dialog.cpp
index b6cbe9dba56..f0512119500 100644
--- a/gui/dialog.cpp
+++ b/gui/dialog.cpp
@@ -125,6 +125,10 @@ void Dialog::lostFocus() {
}
void Dialog::setFocusWidget(Widget *widget) {
+ // Remember which widget had the focus, as releaseFocus() clears it and we
+ // want to know afterwards whether the focus actually moved.
+ Widget *previousWidget = _focusedWidget;
+
// The focus will change. Tell the old focused widget (if any)
// that it lost the focus.
releaseFocus();
@@ -133,6 +137,12 @@ void Dialog::setFocusWidget(Widget *widget) {
if (widget)
widget->receivedFocus();
+ // Announce the newly focused widget, so that moving the focus by keyboard
+ // is audible. Only do so once the dialog is on screen, to avoid speaking
+ // while it is still being built.
+ if (widget && widget != previousWidget && isVisible())
+ widget->readDescription();
+
_focusedWidget = widget;
}
diff --git a/gui/widget.cpp b/gui/widget.cpp
index 709ab26e41e..158ab7cdc75 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -273,6 +273,12 @@ void Widget::read(const Common::U32String &str) {
}
}
+void Widget::readDescription() {
+ Common::U32String description = getSpokenDescription();
+ if (!description.empty())
+ read(description);
+}
+
#pragma mark -
StaticTextWidget::StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, bool scale, const Common::U32String &text, Graphics::TextAlign align, const Common::U32String &tooltip, ThemeEngine::FontStyle font, Common::Language lang, bool useEllipsis)
diff --git a/gui/widget.h b/gui/widget.h
index d7567f48635..6ba9ac63480 100644
--- a/gui/widget.h
+++ b/gui/widget.h
@@ -189,6 +189,22 @@ public:
void read(const Common::U32String &str);
+ /**
+ * Describe this widget for text-to-speech, for when it gains focus.
+ *
+ * The default implementation falls back on the tooltip, so that widgets
+ * which have not overridden this still say something rather than leaving
+ * the user with silence. Widgets which carry a label or a value should
+ * override this to report it.
+ *
+ * @return A human readable description, or an empty string if the widget
+ * has nothing meaningful to say.
+ */
+ virtual Common::U32String getSpokenDescription() const { return _tooltip; }
+
+ /** Speak this widget's description, if text-to-speech is enabled. */
+ void readDescription();
+
protected:
void updateState(int oldFlags, int newFlags);
diff --git a/gui/widgets/edittext.cpp b/gui/widgets/edittext.cpp
index b1cae209d0f..1b59e51086d 100644
--- a/gui/widgets/edittext.cpp
+++ b/gui/widgets/edittext.cpp
@@ -20,6 +20,7 @@
*/
#include "common/system.h"
+#include "common/translation.h"
#include "common/unicode-bidi.h"
#include "gui/widgets/edittext.h"
#include "gui/gui-manager.h"
@@ -143,6 +144,19 @@ Common::Rect EditTextWidget::getEditRect() const {
return r;
}
+Common::U32String EditTextWidget::getSpokenDescription() const {
+ // Prefer the tooltip, which names the field. Fall back on naming the kind
+ // of control only when there is no label to give, so that an unlabelled
+ // field is still audible rather than silent.
+ // I18N: Spoken by text-to-speech to name an unlabelled text entry field
+ Common::U32String description = _tooltip.empty() ? _("edit text") : _tooltip;
+
+ if (!_editString.empty())
+ description += Common::U32String(", ") + _editString;
+
+ return description;
+}
+
void EditTextWidget::receivedFocusWidget() {
g_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, true);
}
diff --git a/gui/widgets/edittext.h b/gui/widgets/edittext.h
index b224ae9d65a..dc81d517e51 100644
--- a/gui/widgets/edittext.h
+++ b/gui/widgets/edittext.h
@@ -45,6 +45,8 @@ public:
bool wantsFocus() override { return true; }
+ Common::U32String getSpokenDescription() const override;
+
void reflowLayout() override;
protected:
diff --git a/gui/widgets/list.cpp b/gui/widgets/list.cpp
index 0fde3a1c42e..28937dda2ab 100644
--- a/gui/widgets/list.cpp
+++ b/gui/widgets/list.cpp
@@ -22,6 +22,7 @@
#include "common/system.h"
#include "common/frac.h"
#include "common/tokenizer.h"
+#include "common/translation.h"
#include "gui/widgets/list.h"
#include "gui/widgets/scrollbar.h"
@@ -854,6 +855,20 @@ bool ListWidget::handleKeyUp(Common::KeyState state) {
return true;
}
+Common::U32String ListWidget::getSpokenDescription() const {
+ // Prefer the tooltip, which names the list. Fall back on naming the kind
+ // of control only when there is no label to give, so that an unlabelled
+ // list is still audible rather than silent. Follow it with the current
+ // selection, so that arriving here says what is under the cursor.
+ // I18N: Spoken by text-to-speech to name an unlabelled list of items
+ Common::U32String description = _tooltip.empty() ? _("list") : _tooltip;
+
+ if (_selectedItem >= 0 && _selectedItem < (int)_list.size())
+ description += Common::U32String(", ") + stripGUIformatting(_list[_selectedItem]);
+
+ return description;
+}
+
void ListWidget::receivedFocusWidget() {
_inversion = ThemeEngine::kTextInversionFocus;
diff --git a/gui/widgets/list.h b/gui/widgets/list.h
index 9161868fb12..a70350a66ab 100644
--- a/gui/widgets/list.h
+++ b/gui/widgets/list.h
@@ -132,6 +132,8 @@ public:
const Common::U32String getSelectedString() const { return stripGUIformatting(_list[_selectedItem]); }
+ Common::U32String getSpokenDescription() const override;
+
/// Get visual position (index in filtered list) from real data index
int getVisualPos(int dataIndex) const;
Commit: fb50b4c7aeb3442db408f6ba9091bad7df81dbe3
https://github.com/scummvm/scummvm/commit/fb50b4c7aeb3442db408f6ba9091bad7df81dbe3
Author: objectinspace (amockery at gmail.com)
Date: 2026-11-19T20:46:40+01:00
Commit Message:
GUI: Silence speech when a key is pressed
Each new announcement already interrupts whatever is being spoken, but
a key that announces nothing of its own left the speech running. A
long tooltip or list entry kept talking while the user typed into a
field, pressed a modifier or otherwise moved on, with no way to stop
it short of waiting for it to finish.
Stop any speech in progress whenever a key is pressed in the GUI, as
screen readers do. This is done in GuiManager::processEvent() before
the key is passed to the dialog, so the key still does what it
otherwise would, and anything it announces itself is spoken in full.
Keymapped GUI actions are covered too, as they arrive as custom
engine action events rather than key presses. Auto-repeated key
presses are ignored, so holding a key down does not keep stopping the
speech.
Assisted-by: Claude:claude-opus-5-5
Changed paths:
gui/gui-manager.cpp
diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp
index 5b31a1b0af4..f2beee1b813 100644
--- a/gui/gui-manager.cpp
+++ b/gui/gui-manager.cpp
@@ -923,6 +923,17 @@ void GuiManager::processEvent(const Common::Event &event, Dialog *const activeDi
mouseX = g_system->getOverlayWidth() - mouseX;
}
Common::Point mouse(mouseX - activeDialog->_x, event.mouse.y - activeDialog->_y);
+
+ // Pressing a key silences any speech in progress, as screen readers do.
+ // This happens before the key is handled, so that whatever the key itself
+ // announces is not cut off, and the key otherwise works as usual.
+ if ((event.type == Common::EVENT_KEYDOWN && !event.kbdRepeat) ||
+ event.type == Common::EVENT_CUSTOM_ENGINE_ACTION_START) {
+ Common::TextToSpeechManager *ttsMan = _system->getTextToSpeechManager();
+ if (ttsMan && ttsMan->isSpeaking())
+ ttsMan->stop();
+ }
+
switch (event.type) {
case Common::EVENT_KEYDOWN:
activeDialog->handleKeyDown(event.kbd);
Commit: d9c03aec2f25177cd09c9982c70be5ca34410740
https://github.com/scummvm/scummvm/commit/d9c03aec2f25177cd09c9982c70be5ca34410740
Author: objectinspace (amockery at gmail.com)
Date: 2026-11-19T20:46:40+01:00
Commit Message:
GUI: Describe widgets for speech by the text labelling them
The widget receiving the focus is announced by its spoken description,
which falls back on its tooltip. Buttons, checkboxes, radio buttons,
sliders, popups and tab widgets did not provide one, and text fields and
lists were named by their tooltip. Only a few widgets have a tooltip, so
most would be announced by nothing, or by the kind of control alone,
such as "drop-down list, 2x", with nothing saying what they set.
They now describe themselves as a reader would see them, and as
hovering reads them, adding the state or value that matters when the
widget is reached without seeing it:
- buttons by their label, or their tooltip for picture buttons
- checkboxes and radio buttons by their label, followed by whether they
are checked or selected
- popups, sliders, text fields and lists by the text labelling them,
followed by their current entry, value, text or selection
- tab widgets by the title of their active tab
Popups, sliders, text fields and lists have no label of their own, but
a separate text widget placed before them. Widgets can now find it the
way a reader would: the nearest text before them on the same row, as the
layouts place labels, or a picture with a tooltip there, as the launcher
uses for its search field. Their tooltip is used when there is no such
text, and the kind of control only when there is neither.
A slider is followed by the value shown after it on the same row, such
as a percentage, when there is one, and otherwise by its own value.
Only text fields and lists can take the focus for now, so most of these
descriptions are heard once keyboard navigation lets the focus reach the
other widgets.
Assisted-by: Claude:claude-opus-5-5
Changed paths:
gui/widget.cpp
gui/widget.h
gui/widgets/edittext.cpp
gui/widgets/list.cpp
gui/widgets/popup.cpp
gui/widgets/popup.h
gui/widgets/tab.cpp
gui/widgets/tab.h
diff --git a/gui/widget.cpp b/gui/widget.cpp
index 158ab7cdc75..3846860ec29 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -279,6 +279,58 @@ void Widget::readDescription() {
read(description);
}
+Common::U32String Widget::findTextBeside(bool before) const {
+ // Look among the widgets sharing this widget's parent for text on the
+ // same row, that is spanning this widget's vertical centre, and keep the
+ // nearest one on the wanted side. Positions are in the parent's
+ // coordinates, which RTL layouts mirror when drawn, so "before" holds
+ // there too.
+ const int centre = _y + _h / 2;
+ const Widget *best = nullptr;
+ Common::U32String bestText;
+
+ for (const Widget *w = _boss->_firstWidget; w; w = w->_next) {
+ if (w == this || !w->isVisible())
+ continue;
+ if (centre < w->_y || centre >= w->_y + w->_h)
+ continue;
+ if (before ? (w->_x >= _x) : (w->_x <= _x))
+ continue;
+ if (best && (before ? (w->_x <= best->_x) : (w->_x >= best->_x)))
+ continue;
+
+ Common::U32String text;
+ if (w->_type == kStaticTextWidget)
+ text = static_cast<const StaticTextWidget *>(w)->getLabel();
+ else if (w->_type == kGraphicsWidget)
+ text = w->_tooltip;
+ else
+ continue;
+
+ if (text.empty())
+ continue;
+ best = w;
+ bestText = text;
+ }
+
+ return bestText;
+}
+
+Common::U32String Widget::findSpokenLabel() const {
+ return findTextBeside(true);
+}
+
+Common::U32String Widget::findSpokenValue() const {
+ return findTextBeside(false);
+}
+
+Common::U32String Widget::findSpokenName(const Common::U32String &kind) const {
+ const Common::U32String label = findSpokenLabel();
+ if (!label.empty())
+ return label;
+ return _tooltip.empty() ? kind : _tooltip;
+}
+
#pragma mark -
StaticTextWidget::StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, bool scale, const Common::U32String &text, Graphics::TextAlign align, const Common::U32String &tooltip, ThemeEngine::FontStyle font, Common::Language lang, bool useEllipsis)
@@ -423,6 +475,23 @@ void ButtonWidget::drawWidget() {
g_gui.theme()->drawButton(Common::Rect(_x, _y, _x + _w, _y + _h), getLabel(), _state, getFlags());
}
+/**
+ * Name a widget for text-to-speech by its label, as hovering it reads, or by
+ * its tooltip when it has none, as for picture buttons. Name the kind of
+ * control only when there is neither, so that an unlabelled widget is still
+ * audible.
+ */
+static Common::U32String spokenName(const Common::U32String &label, const Common::U32String &tooltip, const Common::U32String &kind) {
+ if (!label.empty())
+ return label;
+ return tooltip.empty() ? kind : tooltip;
+}
+
+Common::U32String ButtonWidget::getSpokenDescription() const {
+ // I18N: Spoken by text-to-speech to name an unlabelled button
+ return spokenName(_label, _tooltip, _("button"));
+}
+
void ButtonWidget::setLabel(const Common::U32String &label) {
StaticTextWidget::setLabel(cleanupHotkey(label));
}
@@ -752,6 +821,14 @@ void CheckboxWidget::drawWidget() {
g_gui.theme()->drawCheckbox(Common::Rect(_x, _y, _x + _w, _y + _h), _spacing, getLabel(), _state, Widget::_state, _overrideText, (g_gui.useRTL() && _useRTL));
}
+Common::U32String CheckboxWidget::getSpokenDescription() const {
+ // I18N: Spoken by text-to-speech to name an unlabelled checkbox
+ const Common::U32String name = spokenName(_label, _tooltip, _("checkbox"));
+ // I18N: Spoken by text-to-speech for the state of a checkbox
+ const Common::U32String state = _state ? _("checked") : _("not checked");
+ return name + Common::U32String(", ") + state;
+}
+
#pragma mark -
RadiobuttonGroup::RadiobuttonGroup(GuiObject *boss, uint32 cmd) : CommandSender(boss) {
_value = -1;
@@ -827,6 +904,14 @@ void RadiobuttonWidget::drawWidget() {
g_gui.theme()->drawRadiobutton(Common::Rect(_x, _y, _x + _w, _y + _h), _spacing, getLabel(), _state, Widget::_state, (g_gui.useRTL() && _useRTL));
}
+Common::U32String RadiobuttonWidget::getSpokenDescription() const {
+ // I18N: Spoken by text-to-speech to name an unlabelled radio button
+ const Common::U32String name = spokenName(_label, _tooltip, _("radio button"));
+ // I18N: Spoken by text-to-speech for the state of a radio button
+ const Common::U32String state = _state ? _("selected") : _("not selected");
+ return name + Common::U32String(", ") + state;
+}
+
#pragma mark -
SliderWidget::SliderWidget(GuiObject *boss, int x, int y, int w, int h, bool scale, const Common::U32String &tooltip, uint32 cmd)
@@ -905,6 +990,18 @@ void SliderWidget::drawWidget() {
g_gui.theme()->drawSlider(r1, valueToBarWidth(_value), _state, (g_gui.useRTL() && _useRTL));
}
+Common::U32String SliderWidget::getSpokenDescription() const {
+ // Sliders are labelled by the text before them. Follow the name with the
+ // value as shown after the slider, such as a percentage, or failing
+ // that, the slider's own value.
+ // I18N: Spoken by text-to-speech to name an unlabelled slider
+ const Common::U32String name = findSpokenName(_("slider"));
+ Common::U32String value = findSpokenValue();
+ if (value.empty())
+ value = Common::U32String(Common::String::format("%d", _value));
+ return name + Common::U32String(", ") + value;
+}
+
int SliderWidget::valueToBarWidth(int value) {
value = CLIP(value, _valueMin, _valueMax);
return (_w * (value - _valueMin) / (_valueMax - _valueMin));
diff --git a/gui/widget.h b/gui/widget.h
index 6ba9ac63480..3c7056b8941 100644
--- a/gui/widget.h
+++ b/gui/widget.h
@@ -205,7 +205,35 @@ public:
/** Speak this widget's description, if text-to-speech is enabled. */
void readDescription();
+ /**
+ * Find the text labelling this widget, for widgets such as popups,
+ * sliders and text fields, which have no label of their own but a
+ * separate text widget before them on the same row, as layouts place
+ * them. A picture with a tooltip serves as a label too.
+ *
+ * @return The label, or an empty string if there is none.
+ */
+ Common::U32String findSpokenLabel() const;
+
+ /**
+ * Find the text just after this widget on the same row, such as the
+ * value shown beside a slider.
+ *
+ * @return The text, or an empty string if there is none.
+ */
+ Common::U32String findSpokenValue() const;
+
+ /**
+ * Name this widget for speech by the text labelling it, or by its
+ * tooltip when there is none, or else by the given kind of control, so
+ * that an unlabelled widget is still audible.
+ */
+ Common::U32String findSpokenName(const Common::U32String &kind) const;
+
protected:
+ /** The nearest text before (or after) this widget on the same row, as described in findSpokenLabel() */
+ Common::U32String findTextBeside(bool before) const;
+
void updateState(int oldFlags, int newFlags);
virtual void drawWidget() = 0;
@@ -281,6 +309,7 @@ public:
void handleMouseDown(int x, int y, int button, int clickCount) override;
void handleMouseEntered(int button) override { readLabel(); if (_duringPress) { setFlags(WIDGET_PRESSED); } else { setFlags(WIDGET_HILITED); } markAsDirty(); }
void handleMouseLeft(int button) override { clearFlags(WIDGET_HILITED | WIDGET_PRESSED); markAsDirty(); }
+ Common::U32String getSpokenDescription() const override;
void setHighLighted(bool enable);
void setPressedState();
@@ -364,6 +393,7 @@ public:
void handleMouseUp(int x, int y, int button, int clickCount) override;
void handleMouseEntered(int button) override { readLabel(); setFlags(WIDGET_HILITED); markAsDirty(); }
void handleMouseLeft(int button) override { clearFlags(WIDGET_HILITED); markAsDirty(); }
+ Common::U32String getSpokenDescription() const override;
void setState(bool state);
void toggleState() { setState(!_state); }
@@ -414,6 +444,7 @@ public:
void handleMouseUp(int x, int y, int button, int clickCount) override;
void handleMouseEntered(int button) override { readLabel(); setFlags(WIDGET_HILITED); markAsDirty(); }
void handleMouseLeft(int button) override { clearFlags(WIDGET_HILITED); markAsDirty(); }
+ Common::U32String getSpokenDescription() const override;
void setState(bool state, bool setGroup = true);
void toggleState() { setState(!_state); }
@@ -455,6 +486,7 @@ public:
void handleMouseUp(int x, int y, int button, int clickCount) override;
void handleMouseEntered(int button) override { setFlags(WIDGET_HILITED); markAsDirty(); }
void handleMouseLeft(int button) override { clearFlags(WIDGET_HILITED); markAsDirty(); }
+ Common::U32String getSpokenDescription() const override;
void handleMouseWheel(int x, int y, int direction) override;
protected:
diff --git a/gui/widgets/edittext.cpp b/gui/widgets/edittext.cpp
index 1b59e51086d..5d344ebbe68 100644
--- a/gui/widgets/edittext.cpp
+++ b/gui/widgets/edittext.cpp
@@ -145,11 +145,11 @@ Common::Rect EditTextWidget::getEditRect() const {
}
Common::U32String EditTextWidget::getSpokenDescription() const {
- // Prefer the tooltip, which names the field. Fall back on naming the kind
- // of control only when there is no label to give, so that an unlabelled
- // field is still audible rather than silent.
+ // Name the field by the text before it, or its tooltip. Fall back on
+ // naming the kind of control only when there is neither, so that an
+ // unlabelled field is still audible rather than silent.
// I18N: Spoken by text-to-speech to name an unlabelled text entry field
- Common::U32String description = _tooltip.empty() ? _("edit text") : _tooltip;
+ Common::U32String description = findSpokenName(_("edit text"));
if (!_editString.empty())
description += Common::U32String(", ") + _editString;
diff --git a/gui/widgets/list.cpp b/gui/widgets/list.cpp
index 28937dda2ab..8635c0eddc9 100644
--- a/gui/widgets/list.cpp
+++ b/gui/widgets/list.cpp
@@ -856,12 +856,13 @@ bool ListWidget::handleKeyUp(Common::KeyState state) {
}
Common::U32String ListWidget::getSpokenDescription() const {
- // Prefer the tooltip, which names the list. Fall back on naming the kind
- // of control only when there is no label to give, so that an unlabelled
- // list is still audible rather than silent. Follow it with the current
- // selection, so that arriving here says what is under the cursor.
+ // Name the list by the text before it, or its tooltip. Fall back on
+ // naming the kind of control only when there is neither, so that an
+ // unlabelled list is still audible rather than silent. Follow it with
+ // the current selection, so that arriving here says what is under the
+ // cursor.
// I18N: Spoken by text-to-speech to name an unlabelled list of items
- Common::U32String description = _tooltip.empty() ? _("list") : _tooltip;
+ Common::U32String description = findSpokenName(_("list"));
if (_selectedItem >= 0 && _selectedItem < (int)_list.size())
description += Common::U32String(", ") + stripGUIformatting(_list[_selectedItem]);
diff --git a/gui/widgets/popup.cpp b/gui/widgets/popup.cpp
index c6c322aeeaa..84bc3ecfab6 100644
--- a/gui/widgets/popup.cpp
+++ b/gui/widgets/popup.cpp
@@ -20,6 +20,7 @@
*/
#include "common/system.h"
+#include "common/translation.h"
#include "gui/gui-manager.h"
#include "gui/widgets/popup.h"
@@ -556,4 +557,16 @@ void PopUpWidget::drawWidget() {
g_gui.theme()->drawPopUpWidget(Common::Rect(_x, _y, _x + _w, _y + _h), sel, pad, _state, (g_gui.useRTL() && _useRTL));
}
+Common::U32String PopUpWidget::getSpokenDescription() const {
+ // Popups are labelled by the text before them. Follow the name with the
+ // current entry, which hovering reads.
+ // I18N: Spoken by text-to-speech to name an unlabelled drop-down list
+ Common::U32String description = findSpokenName(_("drop-down list"));
+
+ if (_selectedItem >= 0 && _selectedItem < (int)_entries.size())
+ description += Common::U32String(", ") + _entries[_selectedItem].name;
+
+ return description;
+}
+
} // End of namespace GUI
diff --git a/gui/widgets/popup.h b/gui/widgets/popup.h
index 89fb837fed0..ce4d0f30035 100644
--- a/gui/widgets/popup.h
+++ b/gui/widgets/popup.h
@@ -74,6 +74,7 @@ public:
void handleMouseEntered(int button) override { if (_selectedItem != -1) read(_entries[_selectedItem].name); setFlags(WIDGET_HILITED); markAsDirty(); }
void handleMouseLeft(int button) override { clearFlags(WIDGET_HILITED); markAsDirty(); }
+ Common::U32String getSpokenDescription() const override;
void reflowLayout() override;
protected:
diff --git a/gui/widgets/tab.cpp b/gui/widgets/tab.cpp
index fe168c0a612..d4a43623f2f 100644
--- a/gui/widgets/tab.cpp
+++ b/gui/widgets/tab.cpp
@@ -498,4 +498,11 @@ void TabWidget::computeLastVisibleTab(bool adjustFirstIfRoom) {
}
}
+Common::U32String TabWidget::getSpokenDescription() const {
+ // The tab bar is named by its active tab, as hovering a tab reads its title
+ if (_activeTab >= 0 && _activeTab < (int)_tabs.size())
+ return _tabs[_activeTab].title;
+ return _tooltip;
+}
+
} // End of namespace GUI
diff --git a/gui/widgets/tab.h b/gui/widgets/tab.h
index 26f531531a4..051d734018a 100644
--- a/gui/widgets/tab.h
+++ b/gui/widgets/tab.h
@@ -111,6 +111,7 @@ public:
void handleMouseDown(int x, int y, int button, int clickCount) override;
void handleMouseMoved(int x, int y, int button) override;
void handleMouseLeft(int button) override { _lastRead = -1; };
+ Common::U32String getSpokenDescription() const override;
bool handleKeyDown(Common::KeyState state) override;
void handleMouseWheel(int x, int y, int direction) override;
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
Commit: f08877734c83538b13ea74c08eaee3b6180574f4
https://github.com/scummvm/scummvm/commit/f08877734c83538b13ea74c08eaee3b6180574f4
Author: objectinspace (amockery at gmail.com)
Date: 2026-11-19T20:46:40+01:00
Commit Message:
TTS: (Windows) - Escape markup in spoken text
The text is spoken with SAPI markup parsing enabled, to set the pitch,
but it wasn't escaped. Anything looking like a tag, such as "<default>"
in the options, was silently dropped. Escape &, < and > first.
Assisted-by: Claude:claude-opus-5-5
Changed paths:
backends/text-to-speech/windows/windows-text-to-speech.cpp
diff --git a/backends/text-to-speech/windows/windows-text-to-speech.cpp b/backends/text-to-speech/windows/windows-text-to-speech.cpp
index 10912c951d8..3fd45b70efc 100644
--- a/backends/text-to-speech/windows/windows-text-to-speech.cpp
+++ b/backends/text-to-speech/windows/windows-text-to-speech.cpp
@@ -176,6 +176,28 @@ DWORD WINAPI startSpeech(LPVOID parameters) {
return 0;
}
+// The text is parsed as SAPI markup, to set the pitch, so escape it
+static Common::U32String escapeForSapi(const Common::U32String &str) {
+ Common::U32String escaped;
+ for (uint i = 0; i < str.size(); ++i) {
+ switch (str[i]) {
+ case '&':
+ escaped += Common::U32String("&");
+ break;
+ case '<':
+ escaped += Common::U32String("<");
+ break;
+ case '>':
+ escaped += Common::U32String(">");
+ break;
+ default:
+ escaped += str[i];
+ break;
+ }
+ }
+ return escaped;
+}
+
bool WindowsTextToSpeechManager::say(const Common::U32String &str, Action action) {
if (_speechState == BROKEN || _speechState == NO_VOICE) {
if (_ttsState->_enabled)
@@ -187,7 +209,7 @@ bool WindowsTextToSpeechManager::say(const Common::U32String &str, Action action
return true;
// We have to set the pitch by prepending xml code at the start of the said string;
- Common::U32String pitch = Common::U32String::format("<pitch absmiddle=\"%d\"/>%S", _ttsState->_pitch / 10, str.c_str());
+ Common::U32String pitch = Common::U32String::format("<pitch absmiddle=\"%d\"/>%S", _ttsState->_pitch / 10, escapeForSapi(str).c_str());
WCHAR *strW = (WCHAR *) pitch.encodeUTF16Native();
if (strW == nullptr) {
warning("Cannot convert from UTF-32 encoding for text to speech");
More information about the Scummvm-git-logs
mailing list