aligned button sizes in launcher

This commit is contained in:
Thomas Jentzsch 2021-12-17 10:28:34 +01:00
parent 49694c1f18
commit 3a8fe1b037
2 changed files with 18 additions and 15 deletions

View File

@ -130,20 +130,20 @@ void LauncherDialog::addOptionWidgets(int& ypos)
const GUI::Icon& settingsIcon = smallIcon ? GUI::icon_settings_small : GUI::icon_settings_large; const GUI::Icon& settingsIcon = smallIcon ? GUI::icon_settings_small : GUI::icon_settings_large;
const GUI::Icon& helpIcon = smallIcon ? GUI::icon_help_small : GUI::icon_help_large; const GUI::Icon& helpIcon = smallIcon ? GUI::icon_help_small : GUI::icon_help_large;
const int iconWidth = settingsIcon.width(); const int iconWidth = settingsIcon.width();
const int iconGap = (fontWidth + 1) & ~0b1; // round up to next even const int iconGap = ((fontWidth + 1) & ~0b1) + 1; // round up to next even
const int buttonWidth = iconWidth + iconGap; const int buttonWidth = iconWidth + iconGap;
const GUI::Icon& dummyIcon = settingsIcon; const GUI::Icon& dummyIcon = settingsIcon;
int xpos = HBORDER; int xpos = HBORDER;
mySettingsButton = new ButtonWidget(this, _font, xpos, ypos - btnYOfs, mySettingsButton = new ButtonWidget(this, _font, xpos, ypos - btnYOfs,
iconWidth, Dialog::buttonHeight(), settingsIcon, iconWidth, buttonHeight, settingsIcon,
iconGap, " Options" + ELLIPSIS + " ", kOptionsCmd); iconGap, " Options" + ELLIPSIS + " ", kOptionsCmd);
wid.push_back(mySettingsButton); wid.push_back(mySettingsButton);
const int cwSettings = mySettingsButton->getWidth(); const int cwSettings = mySettingsButton->getWidth();
const int cwSubDirs = buttonWidth; const int cwSubDirs = buttonWidth;
const int cwAllFiles = buttonWidth; const int cwAllFiles = buttonWidth;
const int cwHelp = buttonWidth - 1; // one pixel narrower to align the the reload button below. const int cwHelp = buttonWidth;
const string& lblFilter = "Filter"; const string& lblFilter = "Filter";
int lwFilter = _font.getStringWidth(lblFilter); int lwFilter = _font.getStringWidth(lblFilter);
int fwFilter = EditTextWidget::calcWidth(_font, "123456"); // at least 6 chars int fwFilter = EditTextWidget::calcWidth(_font, "123456"); // at least 6 chars
@ -196,9 +196,9 @@ void LauncherDialog::addOptionWidgets(int& ypos)
wid.push_back(mySubDirsButton); wid.push_back(mySubDirsButton);
// Show the help button // Show the help button
xpos = _w - HBORDER - (buttonWidth - 1); xpos = _w - HBORDER - buttonWidth;
myHelpButton = new ButtonWidget(this, _font, xpos, ypos - btnYOfs, myHelpButton = new ButtonWidget(this, _font, xpos, ypos - btnYOfs,
buttonWidth - 1, buttonHeight, helpIcon, kHelpCmd); buttonWidth, buttonHeight, helpIcon, kHelpCmd);
const string key = instance().eventHandler().getMappingDesc(Event::UIHelp, EventMode::kMenuMode); const string key = instance().eventHandler().getMappingDesc(Event::UIHelp, EventMode::kMenuMode);
myHelpButton->setToolTip("Click or press " + key + " for help."); myHelpButton->setToolTip("Click or press " + key + " for help.");
wid.push_back(myHelpButton); wid.push_back(myHelpButton);
@ -230,8 +230,8 @@ void LauncherDialog::addPathWidgets(int& ypos)
const int lwFound = _font.getStringWidth(lblFound); const int lwFound = _font.getStringWidth(lblFound);
const GUI::Icon& reloadIcon = smallIcon ? GUI::icon_reload_small : GUI::icon_reload_large; const GUI::Icon& reloadIcon = smallIcon ? GUI::icon_reload_small : GUI::icon_reload_large;
const int iconWidth = reloadIcon.width(); const int iconWidth = reloadIcon.width();
const int buttonWidth = iconWidth + ((fontWidth + 1) & ~0b1) - 1; // round up to next odd const int buttonWidth = iconWidth + ((fontWidth + 1) & ~0b1) + 1; // round up to next odd
const int buttonHeight = lineHeight + 2; const int buttonHeight = Dialog::buttonHeight(); // lineHeight + 2;
const int wNav = _w - HBORDER * 2 - (myUseMinimalUI ? lwFound + LBL_GAP : buttonWidth + BTN_GAP); const int wNav = _w - HBORDER * 2 - (myUseMinimalUI ? lwFound + LBL_GAP : buttonWidth + BTN_GAP);
int xpos = HBORDER; int xpos = HBORDER;
WidgetArray wid; WidgetArray wid;
@ -245,6 +245,7 @@ void LauncherDialog::addPathWidgets(int& ypos)
buttonWidth, buttonHeight, reloadIcon, kReloadCmd); buttonWidth, buttonHeight, reloadIcon, kReloadCmd);
myReloadButton->setToolTip("Reload listing"); myReloadButton->setToolTip("Reload listing");
wid.push_back(myReloadButton); wid.push_back(myReloadButton);
ypos = myNavigationBar->getBottom() + Dialog::vGap();
} }
else else
{ {
@ -257,6 +258,7 @@ void LauncherDialog::addPathWidgets(int& ypos)
EditTextWidget* e = new EditTextWidget(this, _font, myNavigationBar->getRight() - 1, ypos, EditTextWidget* e = new EditTextWidget(this, _font, myNavigationBar->getRight() - 1, ypos,
lwFound + LBL_GAP + 1, lineHeight, ""); lwFound + LBL_GAP + 1, lineHeight, "");
e->setEditable(false, true); e->setEditable(false, true);
ypos = myNavigationBar->getBottom();
} }
addToFocusList(wid); addToFocusList(wid);
} }
@ -271,15 +273,15 @@ void LauncherDialog::addRomWidgets(int& ypos)
HBORDER = Dialog::hBorder(), HBORDER = Dialog::hBorder(),
VGAP = Dialog::vGap(), VGAP = Dialog::vGap(),
buttonHeight = myUseMinimalUI buttonHeight = myUseMinimalUI
? -VGAP * 4 ? -VGAP * 2
: bottomButtons ? Dialog::buttonHeight() : -VGAP * 2; : bottomButtons ? Dialog::buttonHeight() : -VGAP * 2;
int xpos = HBORDER; int xpos = HBORDER;
WidgetArray wid; WidgetArray wid;
// Add list with game titles // Add list with game titles
// Before we add the list, we need to know the size of the RomInfoWidget // Before we add the list, we need to know the size of the RomInfoWidget
ypos += lineHeight + VGAP; const int listHeight = _h - ypos - VBORDER - buttonHeight - VGAP * 3;
const int listHeight = _h - VBORDER * 2 - lineHeight * 2 - buttonHeight - VGAP * 6;
const float imgZoom = getRomInfoZoom(listHeight); const float imgZoom = getRomInfoZoom(listHeight);
const int romWidth = imgZoom * TIAConstants::viewableWidth; const int romWidth = imgZoom * TIAConstants::viewableWidth;
const int listWidth = _w - (romWidth > 0 ? romWidth + fontWidth : 0) - HBORDER * 2; const int listWidth = _w - (romWidth > 0 ? romWidth + fontWidth : 0) - HBORDER * 2;

View File

@ -45,8 +45,8 @@ NavigationWidget::NavigationWidget(GuiObject* boss, const GUI::Font& font,
const GUI::Icon& nextIcon = smallIcon ? GUI::icon_next_small : GUI::icon_next_large; const GUI::Icon& nextIcon = smallIcon ? GUI::icon_next_small : GUI::icon_next_large;
const GUI::Icon& upIcon = smallIcon ? GUI::icon_up_small : GUI::icon_up_large; const GUI::Icon& upIcon = smallIcon ? GUI::icon_up_small : GUI::icon_up_large;
const int iconWidth = homeIcon.width(); const int iconWidth = homeIcon.width();
const int buttonWidth = iconWidth + ((fontWidth + 1) & ~0b1) - 1; // round up to next odd const int buttonWidth = iconWidth + ((fontWidth + 1) & ~0b1) + 1; // round up to next odd
const int buttonHeight = lineHeight + 2; const int buttonHeight = h;
myHomeButton = new ButtonWidget(boss, _font, xpos, ypos, myHomeButton = new ButtonWidget(boss, _font, xpos, ypos,
buttonWidth, buttonHeight, homeIcon, FileListWidget::kHomeDirCmd); buttonWidth, buttonHeight, homeIcon, FileListWidget::kHomeDirCmd);
@ -72,7 +72,7 @@ NavigationWidget::NavigationWidget(GuiObject* boss, const GUI::Font& font,
boss->addFocusWidget(myUpButton); boss->addFocusWidget(myUpButton);
xpos = myUpButton->getRight() + BTN_GAP; xpos = myUpButton->getRight() + BTN_GAP;
myPath = new PathWidget(boss, this, _font, xpos, ypos, _w + _x - xpos, lineHeight); myPath = new PathWidget(boss, this, _font, xpos, ypos, _w + _x - xpos, h);
} }
else else
{ {
@ -209,7 +209,7 @@ void NavigationWidget::PathWidget::setPath(const string& path)
{ {
// Add new widget to list // Add new widget to list
FolderLinkWidget* s = new FolderLinkWidget(_boss, _font, x, _y, FolderLinkWidget* s = new FolderLinkWidget(_boss, _font, x, _y,
width, lineHeight + 2, name, curPath); width, _h, name, curPath);
s->setID(uInt32(idx)); s->setID(uInt32(idx));
s->setTarget(myTarget); s->setTarget(myTarget);
myFolderList.push_back(s); myFolderList.push_back(s);
@ -254,5 +254,6 @@ void NavigationWidget::PathWidget::FolderLinkWidget::drawWidget(bool hilite)
if(hilite) if(hilite)
s.frameRect(_x, _y, _w, _h, kBtnBorderColorHi); s.frameRect(_x, _y, _w, _h, kBtnBorderColorHi);
s.drawString(_font, _label, _x + 1, _y + 2, _w, hilite ? _textcolorhi : _textcolor, _align); s.drawString(_font, _label, _x + 1, _y + (_h - _font.getFontHeight()) / 2 , _w,
hilite ? _textcolorhi : _textcolor, _align);
} }