KEYMAPPER: Use a dropdown button to save horizontal space
This commit is contained in:
parent
5079fa9dd4
commit
cc15496e9e
13 changed files with 32 additions and 48 deletions
|
@ -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[] = {
|
||||
|
|
|
@ -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<HardwareInput> 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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -929,8 +929,8 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
|
|||
"<def var='RecorderDialog.ExtInfo.Visible' value='1'/>"
|
||||
"<def var='OnScreenDialog.ShowPics' value='0'/>"
|
||||
"<def var='KeyMapper.Spacing' value='10'/>"
|
||||
"<def var='KeyMapper.LabelWidth' value='100'/>"
|
||||
"<def var='KeyMapper.ButtonWidth' value='80'/>"
|
||||
"<def var='KeyMapper.ButtonWidth' value='140'/>"
|
||||
"<def var='KeyMapper.ResetWidth' value='80'/>"
|
||||
"<def var='Tooltip.MaxWidth' value='200'/>"
|
||||
"<def var='Tooltip.XDelta' value='16'/> "
|
||||
"<def var='Tooltip.YDelta' value='16'/>"
|
||||
|
@ -2677,8 +2677,8 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
|
|||
"<def var='RecorderDialog.ExtInfo.Visible' value='0'/>"
|
||||
"<def var='OnScreenDialog.ShowPics' value='0'/>"
|
||||
"<def var='KeyMapper.Spacing' value='5'/>"
|
||||
"<def var='KeyMapper.LabelWidth' value='80'/>"
|
||||
"<def var='KeyMapper.ButtonWidth' value='60'/>"
|
||||
"<def var='KeyMapper.ButtonWidth' value='100'/>"
|
||||
"<def var='KeyMapper.ResetWidth' value='60'/>"
|
||||
"<def var='Tooltip.MaxWidth' value='70'/>"
|
||||
"<def var='Tooltip.XDelta' value='8'/> "
|
||||
"<def var='Tooltip.YDelta' value='8'/>"
|
||||
|
|
Binary file not shown.
|
@ -41,8 +41,8 @@
|
|||
<def var = 'OnScreenDialog.ShowPics' value = '0'/>
|
||||
|
||||
<def var = 'KeyMapper.Spacing' value = '10'/>
|
||||
<def var = 'KeyMapper.LabelWidth' value = '100'/>
|
||||
<def var = 'KeyMapper.ButtonWidth' value = '80'/>
|
||||
<def var = 'KeyMapper.ButtonWidth' value = '140'/>
|
||||
<def var = 'KeyMapper.ResetWidth' value = '80'/>
|
||||
|
||||
<def var = 'Tooltip.MaxWidth' value = '200'/>
|
||||
<def var = 'Tooltip.XDelta' value = '16'/> <!-- basically cursor size -->
|
||||
|
|
|
@ -42,8 +42,8 @@
|
|||
<def var = 'OnScreenDialog.ShowPics' value = '0'/>
|
||||
|
||||
<def var = 'KeyMapper.Spacing' value = '5'/>
|
||||
<def var = 'KeyMapper.LabelWidth' value = '80'/>
|
||||
<def var = 'KeyMapper.ButtonWidth' value = '60'/>
|
||||
<def var = 'KeyMapper.ButtonWidth' value = '100'/>
|
||||
<def var = 'KeyMapper.ResetWidth' value = '60'/>
|
||||
|
||||
<def var = 'Tooltip.MaxWidth' value = '70'/>
|
||||
<def var = 'Tooltip.XDelta' value = '8'/> <!-- basically cursor size -->
|
||||
|
|
Binary file not shown.
|
@ -48,8 +48,8 @@
|
|||
<def var = 'OnScreenDialog.ShowPics' value = '1'/>
|
||||
|
||||
<def var = 'KeyMapper.Spacing' value = '10'/>
|
||||
<def var = 'KeyMapper.LabelWidth' value = '100'/>
|
||||
<def var = 'KeyMapper.ButtonWidth' value = '80'/>
|
||||
<def var = 'KeyMapper.ButtonWidth' value = '140'/>
|
||||
<def var = 'KeyMapper.ResetWidth' value = '80'/>
|
||||
|
||||
<def var = 'Tooltip.MaxWidth' value = '200'/>
|
||||
<def var = 'Tooltip.XDelta' value = '16'/> <!-- basically cursor size -->
|
||||
|
|
|
@ -57,8 +57,8 @@
|
|||
/>
|
||||
|
||||
<def var = 'KeyMapper.Spacing' value = '5'/>
|
||||
<def var = 'KeyMapper.LabelWidth' value = '80'/>
|
||||
<def var = 'KeyMapper.ButtonWidth' value = '60'/>
|
||||
<def var = 'KeyMapper.ButtonWidth' value = '100'/>
|
||||
<def var = 'KeyMapper.ResetWidth' value = '60'/>
|
||||
|
||||
<def var = 'Tooltip.MaxWidth' value = '70'/>
|
||||
<def var = 'Tooltip.XDelta' value = '9'/> <!-- basically cursor size -->
|
||||
|
|
Binary file not shown.
|
@ -48,8 +48,8 @@
|
|||
<def var = 'OnScreenDialog.ShowPics' value = '1'/>
|
||||
|
||||
<def var = 'KeyMapper.Spacing' value = '10'/>
|
||||
<def var = 'KeyMapper.LabelWidth' value = '100'/>
|
||||
<def var = 'KeyMapper.ButtonWidth' value = '80'/>
|
||||
<def var = 'KeyMapper.ButtonWidth' value = '140'/>
|
||||
<def var = 'KeyMapper.ResetWidth' value = '80'/>
|
||||
|
||||
<def var = 'Tooltip.MaxWidth' value = '200'/>
|
||||
<def var = 'Tooltip.XDelta' value = '16'/> <!-- basically cursor size -->
|
||||
|
|
|
@ -57,8 +57,8 @@
|
|||
/>
|
||||
|
||||
<def var = 'KeyMapper.Spacing' value = '5'/>
|
||||
<def var = 'KeyMapper.LabelWidth' value = '80'/>
|
||||
<def var = 'KeyMapper.ButtonWidth' value = '60'/>
|
||||
<def var = 'KeyMapper.ButtonWidth' value = '100'/>
|
||||
<def var = 'KeyMapper.ResetWidth' value = '60'/>
|
||||
|
||||
<def var = 'Tooltip.MaxWidth' value = '70'/>
|
||||
<def var = 'Tooltip.XDelta' value = '9'/> <!-- basically cursor size -->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue