mirror of https://github.com/stella-emu/stella.git
adjust minimal launcher size based on dialog font
This commit is contained in:
parent
da1c997945
commit
3de15a4250
|
@ -171,8 +171,7 @@ void FrameBuffer::setupFonts()
|
||||||
// However, we have to make sure all Dialogs are sized using the fontsize.
|
// However, we have to make sure all Dialogs are sized using the fontsize.
|
||||||
int zoom_h = (fd.height * 4 * 2) / GUI::stellaMediumDesc.height;
|
int zoom_h = (fd.height * 4 * 2) / GUI::stellaMediumDesc.height;
|
||||||
int zoom_w = (fd.maxwidth * 4 * 2) / GUI::stellaMediumDesc.maxwidth;
|
int zoom_w = (fd.maxwidth * 4 * 2) / GUI::stellaMediumDesc.maxwidth;
|
||||||
int zoom = std::max(zoom_w, zoom_h);
|
myTIAMinZoom = std::max(zoom_w, zoom_h) / 4.F; // round to 25% steps
|
||||||
myTIAMinZoom = std::max(2 * 4, zoom) / 4.F; // round to 25% steps
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -307,6 +307,15 @@ class FrameBuffer
|
||||||
const GUI::Font& infoFont() const { return *myInfoFont; }
|
const GUI::Font& infoFont() const { return *myInfoFont; }
|
||||||
const GUI::Font& smallFont() const { return *mySmallFont; }
|
const GUI::Font& smallFont() const { return *mySmallFont; }
|
||||||
const GUI::Font& launcherFont() const { return *myLauncherFont; }
|
const GUI::Font& launcherFont() const { return *myLauncherFont; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get the font description from the font name
|
||||||
|
|
||||||
|
@param name The settings name of the font
|
||||||
|
|
||||||
|
@return The description of the font
|
||||||
|
*/
|
||||||
|
FontDesc getFontDesc(const string& name) const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
@ -485,9 +494,6 @@ class FrameBuffer
|
||||||
Setup the UI fonts
|
Setup the UI fonts
|
||||||
*/
|
*/
|
||||||
void setupFonts();
|
void setupFonts();
|
||||||
|
|
||||||
|
|
||||||
FontDesc getFontDesc(const string& name) const;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "TabWidget.hxx"
|
#include "TabWidget.hxx"
|
||||||
#include "Widget.hxx"
|
#include "Widget.hxx"
|
||||||
#include "Font.hxx"
|
#include "Font.hxx"
|
||||||
|
#include "StellaMediumFont.hxx"
|
||||||
#include "LauncherDialog.hxx"
|
#include "LauncherDialog.hxx"
|
||||||
#ifdef DEBUGGER_SUPPORT
|
#ifdef DEBUGGER_SUPPORT
|
||||||
#include "DebuggerDialog.hxx"
|
#include "DebuggerDialog.hxx"
|
||||||
|
@ -100,7 +101,7 @@ UIDialog::UIDialog(OSystem& osystem, DialogContainer& parent,
|
||||||
VarList::push_back(items, "Large (14pt)", "large14"); // 14x28
|
VarList::push_back(items, "Large (14pt)", "large14"); // 14x28
|
||||||
VarList::push_back(items, "Large (16pt)", "large16"); // 16x32
|
VarList::push_back(items, "Large (16pt)", "large16"); // 16x32
|
||||||
myDialogFontPopup = new PopUpWidget(myTab, font, xpos, ypos, pwidth, lineHeight,
|
myDialogFontPopup = new PopUpWidget(myTab, font, xpos, ypos, pwidth, lineHeight,
|
||||||
items, "Dialogs font (*)", lwidth);
|
items, "Dialogs font (*)", lwidth, kDialogFont);
|
||||||
wid.push_back(myDialogFontPopup);
|
wid.push_back(myDialogFontPopup);
|
||||||
|
|
||||||
// Enable HiDPI mode
|
// Enable HiDPI mode
|
||||||
|
@ -208,7 +209,7 @@ UIDialog::UIDialog(OSystem& osystem, DialogContainer& parent,
|
||||||
_w - xpos - HBORDER - 2, lineHeight, "");
|
_w - xpos - HBORDER - 2, lineHeight, "");
|
||||||
wid.push_back(myRomPath);
|
wid.push_back(myRomPath);
|
||||||
|
|
||||||
xpos = _w - HBORDER - font.getStringWidth("Follow Launcher path") - CheckboxWidget::prefixSize(font);
|
xpos = _w - HBORDER - font.getStringWidth("Follow Launcher path") - CheckboxWidget::prefixSize(font) - 1;
|
||||||
ypos += lineHeight + VGAP * 2;
|
ypos += lineHeight + VGAP * 2;
|
||||||
myFollowLauncherWidget = new CheckboxWidget(myTab, font, xpos, ypos, "Follow Launcher path");
|
myFollowLauncherWidget = new CheckboxWidget(myTab, font, xpos, ypos, "Follow Launcher path");
|
||||||
wid.push_back(myFollowLauncherWidget);
|
wid.push_back(myFollowLauncherWidget);
|
||||||
|
@ -219,21 +220,15 @@ UIDialog::UIDialog(OSystem& osystem, DialogContainer& parent,
|
||||||
// Launcher width and height
|
// Launcher width and height
|
||||||
myLauncherWidthSlider = new SliderWidget(myTab, font, xpos, ypos, "Launcher width ",
|
myLauncherWidthSlider = new SliderWidget(myTab, font, xpos, ypos, "Launcher width ",
|
||||||
lwidth, 0, 6 * fontWidth, "px");
|
lwidth, 0, 6 * fontWidth, "px");
|
||||||
myLauncherWidthSlider->setMinValue(FBMinimum::Width);
|
|
||||||
myLauncherWidthSlider->setMaxValue(ds.w);
|
myLauncherWidthSlider->setMaxValue(ds.w);
|
||||||
myLauncherWidthSlider->setStepValue(10);
|
myLauncherWidthSlider->setStepValue(10);
|
||||||
// one tickmark every ~100 pixel
|
|
||||||
myLauncherWidthSlider->setTickmarkIntervals((ds.w - FBMinimum::Width + 50) / 100);
|
|
||||||
wid.push_back(myLauncherWidthSlider);
|
wid.push_back(myLauncherWidthSlider);
|
||||||
ypos += lineHeight + VGAP;
|
ypos += lineHeight + VGAP;
|
||||||
|
|
||||||
myLauncherHeightSlider = new SliderWidget(myTab, font, xpos, ypos, "Launcher height ",
|
myLauncherHeightSlider = new SliderWidget(myTab, font, xpos, ypos, "Launcher height ",
|
||||||
lwidth, 0, 6 * fontWidth, "px");
|
lwidth, 0, 6 * fontWidth, "px");
|
||||||
myLauncherHeightSlider->setMinValue(FBMinimum::Height);
|
|
||||||
myLauncherHeightSlider->setMaxValue(ds.h);
|
myLauncherHeightSlider->setMaxValue(ds.h);
|
||||||
myLauncherHeightSlider->setStepValue(10);
|
myLauncherHeightSlider->setStepValue(10);
|
||||||
// one tickmark every ~100 pixel
|
|
||||||
myLauncherHeightSlider->setTickmarkIntervals((ds.h - FBMinimum::Height + 50) / 100);
|
|
||||||
wid.push_back(myLauncherHeightSlider);
|
wid.push_back(myLauncherHeightSlider);
|
||||||
ypos += lineHeight + VGAP;
|
ypos += lineHeight + VGAP;
|
||||||
|
|
||||||
|
@ -399,6 +394,7 @@ void UIDialog::loadConfig()
|
||||||
int cr = settings.getInt("ctrlrate");
|
int cr = settings.getInt("ctrlrate");
|
||||||
myControllerRateSlider->setValue(cr);
|
myControllerRateSlider->setValue(cr);
|
||||||
|
|
||||||
|
handleLauncherSize();
|
||||||
handleRomViewer();
|
handleRomViewer();
|
||||||
|
|
||||||
myTab->loadConfig();
|
myTab->loadConfig();
|
||||||
|
@ -530,6 +526,10 @@ void UIDialog::handleCommand(CommandSender* sender, int cmd, int data, int id)
|
||||||
setDefaults();
|
setDefaults();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case kDialogFont:
|
||||||
|
handleLauncherSize();
|
||||||
|
break;
|
||||||
|
|
||||||
case kListDelay:
|
case kListDelay:
|
||||||
if(myListDelaySlider->getValue() == 0)
|
if(myListDelaySlider->getValue() == 0)
|
||||||
{
|
{
|
||||||
|
@ -600,6 +600,29 @@ void UIDialog::handleCommand(CommandSender* sender, int cmd, int data, int id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void UIDialog::handleLauncherSize()
|
||||||
|
{
|
||||||
|
// Determine minimal launcher sizebased on the default font
|
||||||
|
// So what fits with default font should fit for any font.
|
||||||
|
FontDesc fd = instance().frameBuffer().getFontDesc(myDialogFontPopup->getSelectedTag().toString());
|
||||||
|
int w = std::max(FBMinimum::Width, FBMinimum::Width * fd.maxwidth / GUI::stellaMediumDesc.maxwidth);
|
||||||
|
int h = std::max(FBMinimum::Height, FBMinimum::Height * fd.height / GUI::stellaMediumDesc.height);
|
||||||
|
const Common::Size& ds = instance().frameBuffer().desktopSize();
|
||||||
|
|
||||||
|
myLauncherWidthSlider->setMinValue(w);
|
||||||
|
if(myLauncherWidthSlider->getValue() < myLauncherWidthSlider->getMinValue())
|
||||||
|
myLauncherWidthSlider->setValue(w);
|
||||||
|
// one tickmark every ~100 pixel
|
||||||
|
myLauncherWidthSlider->setTickmarkIntervals((ds.w - w + 67) / 100);
|
||||||
|
|
||||||
|
myLauncherHeightSlider->setMinValue(h);
|
||||||
|
if(myLauncherHeightSlider->getValue() < myLauncherHeightSlider->getMinValue())
|
||||||
|
myLauncherHeightSlider->setValue(h);
|
||||||
|
// one tickmark every ~100 pixel
|
||||||
|
myLauncherHeightSlider->setTickmarkIntervals((ds.h - h + 67) / 100);
|
||||||
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
/*void UIDialog::handleLauncherSize()
|
/*void UIDialog::handleLauncherSize()
|
||||||
// an attempt to limit the minimal and maximal ROM info percentages
|
// an attempt to limit the minimal and maximal ROM info percentages
|
||||||
|
|
|
@ -33,13 +33,14 @@ class UIDialog : public Dialog, public CommandSender
|
||||||
void setDefaults() override;
|
void setDefaults() override;
|
||||||
|
|
||||||
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
|
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
|
||||||
//void handleLauncherSize();
|
void handleLauncherSize();
|
||||||
void handleRomViewer();
|
void handleRomViewer();
|
||||||
void createBrowser(const string& title);
|
void createBrowser(const string& title);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
kDialogFont = 'UIDf',
|
||||||
kListDelay = 'UILd',
|
kListDelay = 'UILd',
|
||||||
kMouseWheel = 'UIMw',
|
kMouseWheel = 'UIMw',
|
||||||
kControllerDelay = 'UIcd',
|
kControllerDelay = 'UIcd',
|
||||||
|
|
Loading…
Reference in New Issue