From 4b66fc08f13fbf03d791074f2fd505fdba1f2ff4 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Sat, 14 Mar 2020 09:55:58 +0100 Subject: [PATCH] refine ROM viewer font size calculation define zoom factor for R77 --- src/gui/LauncherDialog.cxx | 21 +++++++++++++-------- src/gui/LauncherDialog.hxx | 3 ++- src/unix/r77/SettingsR77.cxx | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/gui/LauncherDialog.cxx b/src/gui/LauncherDialog.cxx index 6f603802f..d57892f38 100644 --- a/src/gui/LauncherDialog.cxx +++ b/src/gui/LauncherDialog.cxx @@ -145,7 +145,7 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent, TIAConstants::viewableHeight*imgZoom); // Calculate font area, and in the process the font that can be used - Common::Size fontArea(romWidth - 16, myList->getHeight() - imgSize.h - 16); + Common::Size fontArea(romWidth - 16, myList->getHeight() - imgSize.h - 12); const GUI::Font& rominfoFont = getRomInfoFont(fontArea); myRomInfoWidget = new RomInfoWidget(this, rominfoFont, @@ -343,10 +343,13 @@ float LauncherDialog::getRomInfoZoom(int listHeight) const zoom = float(_w - 58 - MIN_LAUNCHER_CHARS * instance().frameBuffer().launcherFont().getMaxCharWidth()) / TIAConstants::viewableWidth; } - if((listHeight - 20 - zoom * TIAConstants::viewableHeight) - / instance().frameBuffer().smallFont().getLineHeight() < MIN_ROMINFO_LINES) + if((listHeight - 12 - zoom * TIAConstants::viewableHeight) < + MIN_ROMINFO_ROWS * instance().frameBuffer().smallFont().getLineHeight() + + MIN_ROMINFO_LINES * instance().frameBuffer().smallFont().getFontHeight()) { - zoom = float(listHeight - 20 - MIN_ROMINFO_LINES * instance().frameBuffer().smallFont().getLineHeight()) + zoom = float(listHeight - 12 - + MIN_ROMINFO_ROWS * instance().frameBuffer().smallFont().getLineHeight() - + MIN_ROMINFO_LINES * instance().frameBuffer().smallFont().getFontHeight()) / TIAConstants::viewableHeight; } @@ -367,11 +370,13 @@ const GUI::Font& LauncherDialog::getRomInfoFont(const Common::Size& area) const // TODO: Perhaps offer a setting to override the font used? // Try to pick a font that works best, based on the available area - if(area.h / instance().frameBuffer().launcherFont().getLineHeight() >= MIN_ROMINFO_LINES && - area.w/ instance().frameBuffer().launcherFont().getMaxCharWidth() >= MIN_ROMINFO_CHARS) + if(area.h >= uInt32(MIN_ROMINFO_ROWS * instance().frameBuffer().launcherFont().getLineHeight() + + MIN_ROMINFO_LINES * instance().frameBuffer().launcherFont().getFontHeight()) + && area.w >= uInt32(MIN_ROMINFO_CHARS * instance().frameBuffer().launcherFont().getMaxCharWidth())) return instance().frameBuffer().launcherFont(); - else if(area.h / instance().frameBuffer().infoFont().getLineHeight() >= MIN_ROMINFO_LINES && - area.w / instance().frameBuffer().infoFont().getMaxCharWidth() >= MIN_ROMINFO_CHARS) + else if(area.h >= uInt32(MIN_ROMINFO_ROWS * instance().frameBuffer().infoFont().getLineHeight() + + MIN_ROMINFO_LINES * instance().frameBuffer().infoFont().getFontHeight()) + && area.w >= uInt32(MIN_ROMINFO_CHARS * instance().frameBuffer().infoFont().getMaxCharWidth())) return instance().frameBuffer().infoFont(); else return instance().frameBuffer().smallFont(); diff --git a/src/gui/LauncherDialog.hxx b/src/gui/LauncherDialog.hxx index 942b20f4e..dc1ce321c 100644 --- a/src/gui/LauncherDialog.hxx +++ b/src/gui/LauncherDialog.hxx @@ -88,7 +88,8 @@ class LauncherDialog : public Dialog private: static constexpr int MIN_LAUNCHER_CHARS = 24; static constexpr int MIN_ROMINFO_CHARS = 24; - static constexpr int MIN_ROMINFO_LINES = 8; + static constexpr int MIN_ROMINFO_ROWS = 7; // full lines + static constexpr int MIN_ROMINFO_LINES = 2; // extra lines void center() override { positionAt(0); } void handleKeyDown(StellaKey key, StellaMod mod, bool repeated) override; diff --git a/src/unix/r77/SettingsR77.cxx b/src/unix/r77/SettingsR77.cxx index ba8ce6858..c3f0d61fd 100644 --- a/src/unix/r77/SettingsR77.cxx +++ b/src/unix/r77/SettingsR77.cxx @@ -51,7 +51,7 @@ SettingsR77::SettingsR77() setPermanent("launcherres", "1280x720"); setPermanent("launcherfont", "large"); - setPermanent("romviewer", "2"); + setPermanent("romviewer", "1.6"); setPermanent("exitlauncher", "true"); setTemporary("minimal_ui", true);