mGUI: Add margin to right-aligned menu text (fixes #871)

This commit is contained in:
Vicki Pfau 2021-08-19 18:22:59 -07:00
parent 7c57a5cc13
commit ebc78cf3ea
2 changed files with 4 additions and 3 deletions

View File

@ -22,6 +22,7 @@ Other fixes:
- Libretro: Fix crash when using Game Boy codes (fixes mgba.io/i/2281) - Libretro: Fix crash when using Game Boy codes (fixes mgba.io/i/2281)
Misc: Misc:
- Core: Suspend runloop when a core crashes - Core: Suspend runloop when a core crashes
- mGUI: Add margin to right-aligned menu text (fixes mgba.io/i/871)
- Qt: Rearrange menus some - Qt: Rearrange menus some
- Qt: Clean up cheats dialog - Qt: Clean up cheats dialog
- Qt: Only set default controller bindings if loading fails (fixes mgba.io/i/799) - Qt: Only set default controller bindings if loading fails (fixes mgba.io/i/799)

View File

@ -163,6 +163,8 @@ enum GUIMenuExitReason GUIShowMenu(struct GUIParams* params, struct GUIMenu* men
GUIFontPrint(params->font, 0, y * 2, GUI_ALIGN_LEFT, 0xFFFFFFFF, menu->subtitle); GUIFontPrint(params->font, 0, y * 2, GUI_ALIGN_LEFT, 0xFFFFFFFF, menu->subtitle);
} }
y += 2 * lineHeight; y += 2 * lineHeight;
unsigned right;
GUIFontIconMetrics(params->font, GUI_ICON_SCROLLBAR_BUTTON, &right, 0);
size_t itemsPerScreen = (params->height - y) / lineHeight; size_t itemsPerScreen = (params->height - y) / lineHeight;
size_t i; size_t i;
for (i = start; i < GUIMenuItemListSize(&menu->items); ++i) { for (i = start; i < GUIMenuItemListSize(&menu->items); ++i) {
@ -174,7 +176,7 @@ enum GUIMenuExitReason GUIShowMenu(struct GUIParams* params, struct GUIMenu* men
struct GUIMenuItem* item = GUIMenuItemListGetPointer(&menu->items, i); struct GUIMenuItem* item = GUIMenuItemListGetPointer(&menu->items, i);
GUIFontPrint(params->font, lineHeight, y, GUI_ALIGN_LEFT, color, item->title); GUIFontPrint(params->font, lineHeight, y, GUI_ALIGN_LEFT, color, item->title);
if (item->validStates && item->validStates[item->state]) { if (item->validStates && item->validStates[item->state]) {
GUIFontPrintf(params->font, params->width, y, GUI_ALIGN_RIGHT, color, "%s ", item->validStates[item->state]); GUIFontPrintf(params->font, params->width - right - 8, y, GUI_ALIGN_RIGHT, color, "%s ", item->validStates[item->state]);
} }
y += lineHeight; y += lineHeight;
if (y + lineHeight > params->height) { if (y + lineHeight > params->height) {
@ -186,8 +188,6 @@ enum GUIMenuExitReason GUIShowMenu(struct GUIParams* params, struct GUIMenu* men
size_t top = 2 * lineHeight; size_t top = 2 * lineHeight;
size_t bottom = params->height - 8; size_t bottom = params->height - 8;
unsigned w; unsigned w;
unsigned right;
GUIFontIconMetrics(params->font, GUI_ICON_SCROLLBAR_BUTTON, &right, 0);
GUIFontIconMetrics(params->font, GUI_ICON_SCROLLBAR_TRACK, &w, 0); GUIFontIconMetrics(params->font, GUI_ICON_SCROLLBAR_TRACK, &w, 0);
right = (right - w) / 2; right = (right - w) / 2;
GUIFontDrawIconSize(params->font, params->width - right - 8, top, 0, bottom - top, 0xA0FFFFFF, GUI_ICON_SCROLLBAR_TRACK); GUIFontDrawIconSize(params->font, params->width - right - 8, top, 0, bottom - top, 0xA0FFFFFF, GUI_ICON_SCROLLBAR_TRACK);