[Scummvm-git-logs] scummvm master -> e36d66f0e5d3a23ccf9f0d6f951e47f8bb1886d8
sev-
noreply at scummvm.org
Mon May 23 21:45:01 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:
e36d66f0e5 GUI: button widget auto size with screen width
Commit: e36d66f0e5d3a23ccf9f0d6f951e47f8bb1886d8
https://github.com/scummvm/scummvm/commit/e36d66f0e5d3a23ccf9f0d6f951e47f8bb1886d8
Author: Die4Ever (die4ever2005 at gmail.com)
Date: 2022-05-23T23:44:59+02:00
Commit Message:
GUI: button widget auto size with screen width
Changed paths:
gui/launcher.cpp
gui/widget.cpp
gui/widget.h
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 54990995d20..0c99b618d86 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -240,7 +240,7 @@ void LauncherDialog::build() {
new ButtonWidget(this, _title + ".QuitButton", _("~Q~uit"), _("Quit ScummVM"), kQuitCmd);
new ButtonWidget(this, _title + ".AboutButton", _("A~b~out"), _("About ScummVM"), kAboutCmd);
- new ButtonWidget(this, _title + ".OptionsButton", _("Global ~O~ptions..."), _("Change global ScummVM options"), kOptionsCmd, 0, _c("Global Opts...", "lowres"));
+ new ButtonWidget(this, _title + ".OptionsButton", _("Global ~O~ptions..."), _("Change global ScummVM options"), kOptionsCmd, 0, _c("Global ~O~pts...", "lowres"));
// Above the lowest button rows: two more buttons (directly below the list box)
DropdownButtonWidget *addButton =
@@ -986,7 +986,7 @@ void LauncherSimple::build() {
// Add edit button
_editButton =
- new ButtonWidget(this, "Launcher.EditGameButton", _("~G~ame Options..."), _("Change game options"), kEditGameCmd, 0, _c("Game Opts...", "lowres"));
+ new ButtonWidget(this, "Launcher.EditGameButton", _("~G~ame Options..."), _("Change game options"), kEditGameCmd, 0, _c("~G~ame Opts...", "lowres"));
// Add list with game titles
_list = new GroupedListWidget(this, "Launcher.GameList", Common::U32String(), kListSearchCmd);
diff --git a/gui/widget.cpp b/gui/widget.cpp
index ef48bfe173b..bd7d4ac24eb 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -349,10 +349,16 @@ void StaticTextWidget::setFont(ThemeEngine::FontStyle font, Common::Language lan
ButtonWidget::ButtonWidget(GuiObject *boss, int x, int y, int w, int h, const Common::U32String &label, const Common::U32String &tooltip, uint32 cmd, uint8 hotkey, const Common::U32String &lowresLabel)
: StaticTextWidget(boss, x, y, w, h, cleanupHotkey(label), Graphics::kTextAlignCenter, tooltip), CommandSender(boss),
_cmd(cmd), _hotkey(hotkey), _duringPress(false) {
- _lowresLabel = lowresLabel;
+ _lowresLabel = cleanupHotkey(lowresLabel);
- if (hotkey == 0)
- _hotkey = parseHotkey(label);
+ if (hotkey == 0) {
+ _highresHotkey = parseHotkey(label);
+ _hotkey = _highresHotkey;
+ _lowresHotkey = parseHotkey(lowresLabel);
+ } else {
+ _highresHotkey = hotkey;
+ _lowresHotkey = hotkey;
+ }
setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG);
_type = kButtonWidget;
@@ -361,10 +367,16 @@ ButtonWidget::ButtonWidget(GuiObject *boss, int x, int y, int w, int h, const Co
ButtonWidget::ButtonWidget(GuiObject *boss, const Common::String &name, const Common::U32String &label, const Common::U32String &tooltip, uint32 cmd, uint8 hotkey, const Common::U32String &lowresLabel)
: StaticTextWidget(boss, name, cleanupHotkey(label), tooltip), CommandSender(boss),
_cmd(cmd), _hotkey(hotkey), _duringPress(false) {
- _lowresLabel = lowresLabel;
+ _lowresLabel = cleanupHotkey(lowresLabel);
- if (hotkey == 0)
- _hotkey = parseHotkey(label);
+ if (hotkey == 0) {
+ _highresHotkey = parseHotkey(label);
+ _hotkey = _highresHotkey;
+ _lowresHotkey = parseHotkey(lowresLabel);
+ } else {
+ _highresHotkey = hotkey;
+ _lowresHotkey = hotkey;
+ }
setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG);
_type = kButtonWidget;
@@ -403,13 +415,14 @@ void ButtonWidget::setLabel(const Common::String &label) {
}
void ButtonWidget::setLowresLabel(const Common::U32String &label) {
- _lowresLabel = label;
+ _lowresLabel = cleanupHotkey(label);
}
const Common::U32String &ButtonWidget::getLabel() {
bool useLowres = false;
if (!_lowresLabel.empty())
- useLowres = g_gui.theme()->getStringWidth(_label) > _w;
+ useLowres = g_system->getOverlayWidth() <= 320;
+ _hotkey = useLowres ? _lowresHotkey : _highresHotkey;
return useLowres ? _lowresLabel : _label;
}
diff --git a/gui/widget.h b/gui/widget.h
index 4e2846a633c..c00cca3efb2 100644
--- a/gui/widget.h
+++ b/gui/widget.h
@@ -225,6 +225,8 @@ class ButtonWidget : public StaticTextWidget, public CommandSender {
protected:
uint32 _cmd;
uint8 _hotkey;
+ uint8 _highresHotkey;
+ uint8 _lowresHotkey;
Common::U32String _lowresLabel;
public:
ButtonWidget(GuiObject *boss, int x, int y, int w, int h, const Common::U32String &label, const Common::U32String &tooltip = Common::U32String(), uint32 cmd = 0, uint8 hotkey = 0, const Common::U32String &lowresLabel = Common::U32String());
More information about the Scummvm-git-logs
mailing list