add hidpi option checkbox to UIDialog

This commit is contained in:
thrust26 2019-05-13 19:04:39 +02:00
parent 087dd1dbb9
commit 093fd4eb75
5 changed files with 38 additions and 6 deletions

View File

@ -53,6 +53,7 @@ FrameBuffer::FrameBuffer(OSystem& osystem)
myStatsEnabled(false),
myLastScanlines(0),
myGrabMouse(false),
myHiDPIAllowed(false),
myHiDPIEnabled(false),
myCurrentModeList(nullptr)
{
@ -85,9 +86,9 @@ bool FrameBuffer::initialize()
myDesktopSize = myAbsDesktopSize;
// Check for HiDPI mode (is it activated, and can we use it?)
myHiDPIEnabled = myOSystem.settings().getBool("hidpi") &&
((myAbsDesktopSize.w / 2) >= FBMinimum::Width) &&
((myAbsDesktopSize.h / 2) >= FBMinimum::Height);
myHiDPIAllowed = ((myAbsDesktopSize.w / 2) >= FBMinimum::Width) &&
((myAbsDesktopSize.h / 2) >= FBMinimum::Height);
myHiDPIEnabled = myHiDPIAllowed && myOSystem.settings().getBool("hidpi");
// In HiDPI mode, the desktop resolution is essentially halved
// Later, the output is scaled and rendered in 2x mode

View File

@ -259,6 +259,12 @@ class FrameBuffer
*/
void stateChanged(EventHandlerState state);
/**
Answer whether hidpi mode is allowed. In this mode, all FBSurfaces
are scaled to 2x normal size.
*/
bool hidpiAllowed() const { return myHiDPIAllowed; }
/**
Answer whether hidpi mode is enabled. In this mode, all FBSurfaces
are scaled to 2x normal size.
@ -562,6 +568,7 @@ class FrameBuffer
uInt32 myLastScanlines;
bool myGrabMouse;
bool myHiDPIAllowed;
bool myHiDPIEnabled;
// The list of all available video modes for this framebuffer

View File

@ -41,7 +41,6 @@ Settings::Settings()
setPermanent("center", "false");
setPermanent("palette", "standard");
setPermanent("uimessages", "true");
setPermanent("hidpi", "false");
// TIA specific options
setPermanent("tia.zoom", "3");
@ -122,6 +121,7 @@ Settings::Settings()
DebuggerDialog::kMediumFontMinH));
#endif
setPermanent("uipalette", "standard");
setPermanent("hidpi", "false");
setPermanent("listdelay", "300");
setPermanent("mwheel", "4");
setPermanent("basic_settings", false);
@ -462,13 +462,16 @@ void Settings::usage() const
<< " -launcherroms <1|0> Show only ROMs in the launcher (vs. all files)\n"
<< " -romviewer <0|1|2> Show ROM info viewer at given zoom level in ROM\n"
<< " launcher (0 for off)\n"
<< " -uipalette <standard| Selects GUI theme\n"
<< " classic|light>\n"
<< " -hidpi <0|1> Enable HiDPI mode\n"
<< " -dialogpos <0..4> Display all dialogs at given positions\n"
<< " -listdelay <delay> Time to wait between keypresses in list widgets\n"
<< " (300-1000)\n"
<< " -mwheel <lines> Number of lines the mouse wheel will scroll in\n"
<< " UI\n"
<< " -basic_settings <0|1> Display only a basic settings dialog\n"
<< " -dialogpos <0..4> Display all dialogs at given positions\n"
<< " -romdir <dir> Directory in which to load ROM files\n"
<< " -romdir <dir> Directory from which to load ROM files\n"
<< " -avoxport <name> The name of the serial port where an AtariVox is\n"
<< " connected\n"
<< " -holdreset Start the emulator with the Game Reset switch\n"

View File

@ -96,6 +96,11 @@ UIDialog::UIDialog(OSystem& osystem, DialogContainer& parent,
myPositionPopup = new PopUpWidget(myTab, font, xpos, ypos, pwidth, lineHeight,
items, "Dialogs position ", lwidth);
wid.push_back(myPositionPopup);
ypos += lineHeight + V_GAP;
// Enable HiDPI mode
myHidpiWidget = new CheckboxWidget(myTab, font, xpos, ypos, "HiDPI mode");
wid.push_back(myHidpiWidget);
ypos += lineHeight + V_GAP * 4;
// Delay between quick-selecting characters in ListWidget
@ -276,6 +281,17 @@ void UIDialog::loadConfig()
const string& pal = settings.getString("uipalette");
myPalettePopup->setSelected(pal, "standard");
// Enable HiDPI mode
if (!instance().frameBuffer().hidpiAllowed())
{
myHidpiWidget->setState(false);
myHidpiWidget->setEnabled(false);
}
else
{
myHidpiWidget->setState(settings.getBool("hidpi"));
}
// Dialog position
myPositionPopup->setSelected(settings.getString("dialogpos"), "0");
@ -324,6 +340,9 @@ void UIDialog::saveConfig()
myPalettePopup->getSelectedTag().toString());
instance().frameBuffer().setUIPalette();
// Enable HiDPI mode
settings.setValue("hidpi", myHidpiWidget->getState());
// Dialog position
settings.setValue("dialogpos", myPositionPopup->getSelectedTag().toString());
@ -347,6 +366,7 @@ void UIDialog::setDefaults()
{
case 0: // Misc. options
myPalettePopup->setSelected("standard");
myHidpiWidget->setState(false);
myPositionPopup->setSelected("0");
myListDelayPopup->setValue(300);
myWheelLinesPopup->setValue(4);

View File

@ -63,6 +63,7 @@ class UIDialog : public Dialog, public CommandSender
// Misc options
PopUpWidget* myPalettePopup;
CheckboxWidget* myHidpiWidget;
PopUpWidget* myPositionPopup;
SliderWidget* myListDelayPopup;
SliderWidget* myWheelLinesPopup;