From cc15496e9e700218aa7aa3c1bd93b36fe4b6ee09 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Tue, 28 Jan 2020 18:44:08 +0100 Subject: [PATCH] KEYMAPPER: Use a dropdown button to save horizontal space --- backends/keymapper/hardware-input.cpp | 2 +- backends/keymapper/remap-widget.cpp | 39 ++++++------------ backends/keymapper/remap-widget.h | 7 ++-- gui/themes/default.inc | 8 ++-- gui/themes/scummclassic.zip | Bin 159073 -> 159074 bytes gui/themes/scummclassic/classic_layout.stx | 4 +- .../scummclassic/classic_layout_lowres.stx | 4 +- gui/themes/scummmodern.zip | Bin 289130 -> 289131 bytes gui/themes/scummmodern/scummmodern_layout.stx | 4 +- .../scummmodern/scummmodern_layout_lowres.stx | 4 +- gui/themes/scummremastered.zip | Bin 287178 -> 287179 bytes .../scummremastered/remastered_layout.stx | 4 +- .../remastered_layout_lowres.stx | 4 +- 13 files changed, 32 insertions(+), 48 deletions(-) diff --git a/backends/keymapper/hardware-input.cpp b/backends/keymapper/hardware-input.cpp index e671c920cee..0b4c0f5e00d 100644 --- a/backends/keymapper/hardware-input.cpp +++ b/backends/keymapper/hardware-input.cpp @@ -214,7 +214,7 @@ const ModifierTableEntry defaultModifiers[] = { { KBD_SHIFT, "S", "Shift+" }, { KBD_ALT, "A", "Alt+" }, { KBD_META, "M", "Meta+" }, - { 0, nullptr, nullptr } + { 0, nullptr, nullptr } }; const HardwareInputTableEntry defaultMouseButtons[] = { diff --git a/backends/keymapper/remap-widget.cpp b/backends/keymapper/remap-widget.cpp index 73a1779acf5..1f8f5e7000c 100644 --- a/backends/keymapper/remap-widget.cpp +++ b/backends/keymapper/remap-widget.cpp @@ -98,12 +98,10 @@ void RemapWidget::reflowActionWidgets() { int spacing = g_gui.xmlEval()->getVar("Globals.KeyMapper.Spacing"); int keyButtonWidth = g_gui.xmlEval()->getVar("Globals.KeyMapper.ButtonWidth"); - int clearButtonWidth = g_gui.xmlEval()->getVar("Globals.Line.Height"); - int clearButtonHeight = g_gui.xmlEval()->getVar("Globals.Line.Height"); - int labelWidth = getWidth() - (spacing + keyButtonWidth + spacing + clearButtonWidth + spacing); + int resetButtonWidth = g_gui.xmlEval()->getVar("Globals.KeyMapper.ResetWidth"); + int labelWidth = getWidth() - (spacing + keyButtonWidth + spacing); uint textYOff = (buttonHeight - kLineHeight) / 2; - uint clearButtonYOff = (buttonHeight - clearButtonHeight) / 2; uint y = spacing; @@ -118,17 +116,17 @@ void RemapWidget::reflowActionWidgets() { previousKeymap = row.keymap; // Insert a keymap separator - x = 4 * spacing + keyButtonWidth + 2 * clearButtonWidth; + x = 2 * spacing + keyButtonWidth; KeymapTitleRow keymapTitle = _keymapSeparators[row.keymap]; if (keymapTitle.descriptionText) { - uint descriptionWidth = getWidth() - x - spacing - keyButtonWidth - spacing; + uint descriptionWidth = getWidth() - x - spacing - resetButtonWidth - spacing; - keymapTitle.descriptionText->resize(x, y, descriptionWidth, kLineHeight); - keymapTitle.resetButton->resize(x + descriptionWidth, y, keyButtonWidth, buttonHeight); + keymapTitle.descriptionText->resize(x, y + textYOff, descriptionWidth, kLineHeight); + keymapTitle.resetButton->resize(x + descriptionWidth, y, resetButtonWidth, buttonHeight); } - y += kLineHeight + spacing; + y += buttonHeight + spacing; } x = spacing; @@ -136,12 +134,6 @@ void RemapWidget::reflowActionWidgets() { row.keyButton->resize(x, y, keyButtonWidth, buttonHeight); x += keyButtonWidth + spacing; - row.clearButton->resize(x, y + clearButtonYOff, clearButtonWidth, clearButtonHeight); - - x += clearButtonWidth + spacing; - row.resetButton->resize(x, y + clearButtonYOff, clearButtonWidth, clearButtonHeight); - - x += clearButtonWidth + spacing; row.actionText->resize(x, y + textYOff, labelWidth, kLineHeight); y += buttonHeight + spacing; @@ -270,20 +262,17 @@ void RemapWidget::loadKeymap() { } void RemapWidget::refreshKeymap() { - int clearButtonWidth = g_gui.xmlEval()->getVar("Globals.Line.Height"); - int clearButtonHeight = g_gui.xmlEval()->getVar("Globals.Line.Height"); - for (uint i = 0; i < _actions.size(); i++) { ActionRow &row = _actions[i]; if (!row.actionText) { row.actionText = new GUI::StaticTextWidget(_scrollContainer, 0, 0, 0, 0, "", Graphics::kTextAlignLeft, nullptr, GUI::ThemeEngine::kFontStyleNormal); - row.keyButton = new GUI::ButtonWidget(_scrollContainer, 0, 0, 0, 0, "", nullptr, kRemapCmd + i); - row.clearButton = addClearButton(_scrollContainer, "", kClearCmd + i, 0, 0, clearButtonWidth, clearButtonHeight); - row.resetButton = new GUI::ButtonWidget(_scrollContainer, 0, 0, 0, 0, "", nullptr, kResetActionCmd + i); - } + row.actionText->setLabel(row.action->description); - row.actionText->setLabel(row.action->description); + row.keyButton = new GUI::DropdownButtonWidget(_scrollContainer, 0, 0, 0, 0, "", nullptr, kRemapCmd + i); + row.keyButton->appendEntry(_("Reset to defaults"), kResetActionCmd + i); + row.keyButton->appendEntry(_("Clear mapping"), kClearCmd + i); + } Array mappedInputs = row.keymap->getActionMapping(row.action); @@ -304,10 +293,6 @@ void RemapWidget::refreshKeymap() { row.keyButton->setTooltip(""); } - // I18N: Button to reset key mapping to defaults - row.resetButton->setLabel(_("R")); - row.resetButton->setTooltip(_("Reset to defaults")); - KeymapTitleRow &keymapTitle = _keymapSeparators[row.keymap]; if (!keymapTitle.descriptionText) { keymapTitle.descriptionText = new GUI::StaticTextWidget(_scrollContainer, 0, 0, 0, 0, row.keymap->getDescription(), Graphics::kTextAlignLeft); diff --git a/backends/keymapper/remap-widget.h b/backends/keymapper/remap-widget.h index 4f7a8621aea..684575ac9e8 100644 --- a/backends/keymapper/remap-widget.h +++ b/backends/keymapper/remap-widget.h @@ -30,6 +30,7 @@ namespace GUI { class ButtonWidget; +class DropdownButtonWidget; class PopUpWidget; class ScrollContainerWidget; class StaticTextWidget; @@ -60,11 +61,9 @@ protected: Common::Action *action; GUI::StaticTextWidget *actionText; - GUI::ButtonWidget *keyButton; - GUI::ButtonWidget *clearButton; - GUI::ButtonWidget *resetButton; + GUI::DropdownButtonWidget *keyButton; - ActionRow() : keymap(nullptr), action(nullptr), actionText(nullptr), keyButton(nullptr), clearButton(nullptr), resetButton(nullptr) { } + ActionRow() : keymap(nullptr), action(nullptr), actionText(nullptr), keyButton(nullptr) {} }; struct KeymapTitleRow { diff --git a/gui/themes/default.inc b/gui/themes/default.inc index 8972e7084e2..b04cc781583 100644 --- a/gui/themes/default.inc +++ b/gui/themes/default.inc @@ -929,8 +929,8 @@ const char *defaultXML1 = "" "" "" "" -"" -"" +"" +"" "" " " "" @@ -2677,8 +2677,8 @@ const char *defaultXML1 = "" "" "" "" -"" -"" +"" +"" "" " " "" diff --git a/gui/themes/scummclassic.zip b/gui/themes/scummclassic.zip index 662f4ebd2026d982e6267a414dcc31250b4c962a..a4456172e0242d51066391df06176ddd6b29fd75 100644 GIT binary patch delta 206 zcmaEOi}TSfPM!d7W)=|!5J=m+k!NNz2TQqiz}kl^6gIDI-oiF{YL^(3p~>WmE?L%~ z)Z)~V&9l3%9Oexxw+{Hl!{TjpoPoh;dyOCCRk(K>z>% delta 209 zcmaEKi}T?vPM!d7W)=|!5LiBSBhSocj^$IW0@iY@xwUz1^AcTTqN;1?H$`W%*Qx$9#)Ga1gcFBVD zwO5BSZm$kysuf{cK6U%AOePyfxINSDvY9MU&79tx%@o0ScKV%cCKpDb>54f_E{t5$ h(?Ha{>8o>?oEfF2zXwt0rW@xnX|lb}WMW`o002A7NfQ77 diff --git a/gui/themes/scummclassic/classic_layout.stx b/gui/themes/scummclassic/classic_layout.stx index a138a70efd1..3b58fb035ca 100644 --- a/gui/themes/scummclassic/classic_layout.stx +++ b/gui/themes/scummclassic/classic_layout.stx @@ -41,8 +41,8 @@ - - + + diff --git a/gui/themes/scummclassic/classic_layout_lowres.stx b/gui/themes/scummclassic/classic_layout_lowres.stx index ebd6c1ff019..74ef157caf0 100644 --- a/gui/themes/scummclassic/classic_layout_lowres.stx +++ b/gui/themes/scummclassic/classic_layout_lowres.stx @@ -42,8 +42,8 @@ - - + + diff --git a/gui/themes/scummmodern.zip b/gui/themes/scummmodern.zip index 18d5750e174e9bd226f3454380777465e6daeda6..ac7d9036fb737622baa3f88ed963898fcf5d8b42 100644 GIT binary patch delta 258 zcmaELN$~Y0L7o6_W)=|!5J=nH$kWQhxRr;=WjV*+GV6ew{j3h#BbGC*VV`cXo=J?! z&}6#wdL~)cpw!~jlI?cunKmEc4Jx+|P+`BZb>~S2hMn906*IGPfE7=dT+bvARcTYh zJmm>f+UD(-5?C&?!Hu52Hl4)=)qv^W(ph4-Zridj6sIN@C1*_En8YG7y&!`{iqUd< zcLs|E_Y7YahT@X^f~1nX>4GUNQq#EtSp*>NXJBAh()c%kg`v1Svm`lVx_mN=`1I^p Z76ERs_rTI|)9o@@)Yy(DurM$%007`ZQosNJ delta 235 zcmaETN$}MrL7o6_W)=|!5LiC7k*Af1aVrm#%W{t8Q>_9H&*E6PJz_c28g^En#H7@m z>6|sp`qNp~Gl^~YThFxk2ro#{dEF09J5Dk%?AZRVn3jInL>7_h?v5-1++asC zFfc4>w3yzL!D7KUefrT17CWv#0W1u~<(VbP8PgS#S;VKSWU@#x#!k1-WKm-~lEA{i GzyJWWe^4L* diff --git a/gui/themes/scummmodern/scummmodern_layout.stx b/gui/themes/scummmodern/scummmodern_layout.stx index c2b8938eeda..f4011a462dd 100644 --- a/gui/themes/scummmodern/scummmodern_layout.stx +++ b/gui/themes/scummmodern/scummmodern_layout.stx @@ -48,8 +48,8 @@ - - + + diff --git a/gui/themes/scummmodern/scummmodern_layout_lowres.stx b/gui/themes/scummmodern/scummmodern_layout_lowres.stx index 4bd8a2331c7..b0c2b8d3982 100644 --- a/gui/themes/scummmodern/scummmodern_layout_lowres.stx +++ b/gui/themes/scummmodern/scummmodern_layout_lowres.stx @@ -57,8 +57,8 @@ /> - - + + diff --git a/gui/themes/scummremastered.zip b/gui/themes/scummremastered.zip index c3c64a9f3c955019a29bbad7cbae474dbbac40ce..0347860769e91348878f06a8fe84080691e6acbb 100644 GIT binary patch delta 220 zcmX?gSn%{=L7o6_W)=|!5J=nH$kWQhxRr-#`FxIVW!3?z0q6C%@1D=Jntl4Lg7!G5S7y# zS1<`r-@Kejcl*5(=FlfhX`8p3MzUODgIhA4KY_&>)u`#=2`tf!cGEW}u$VK>nf^L~ y#e(~{D+@z$Nq#|6N#1nBcowPY9*Hbcj0w||6IrYn4^E$#$fCxk5y`^9zyJVt^G(PA delta 221 zcmX?oSn$+gL7o6_W)=|!5LiC7k*Af1aVrng^7$Ogr&xZ%?U5?HKJO_?5%z!J@6YsSJ*oSImaoH4y2mPKUxDoYjtZm=U6 s7#Nl`&Yu1zfyILH*L2lH7CXlH=_!dUR*VOx&rf7gV^fc0VPIeY0588v-~a#s diff --git a/gui/themes/scummremastered/remastered_layout.stx b/gui/themes/scummremastered/remastered_layout.stx index ba92d91ce27..11e1bdb2cf4 100644 --- a/gui/themes/scummremastered/remastered_layout.stx +++ b/gui/themes/scummremastered/remastered_layout.stx @@ -48,8 +48,8 @@ - - + + diff --git a/gui/themes/scummremastered/remastered_layout_lowres.stx b/gui/themes/scummremastered/remastered_layout_lowres.stx index 818e725cea0..e7963f5f9cd 100644 --- a/gui/themes/scummremastered/remastered_layout_lowres.stx +++ b/gui/themes/scummremastered/remastered_layout_lowres.stx @@ -57,8 +57,8 @@ /> - - + +