diff --git a/src/gui/ConfigPathDialog.cxx b/src/gui/ConfigPathDialog.cxx index 1b0d26090..692492ae7 100644 --- a/src/gui/ConfigPathDialog.cxx +++ b/src/gui/ConfigPathDialog.cxx @@ -29,10 +29,10 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ConfigPathDialog::ConfigPathDialog( OSystem& osystem, DialogContainer& parent, - const GUI::Font& font, GuiObject* boss, - int max_w, int max_h) + const GUI::Font& font, GuiObject* boss) : Dialog(osystem, parent), CommandSender(boss), + myFont(font), myBrowser(nullptr), myIsGlobal(boss != nullptr) { @@ -126,9 +126,6 @@ ConfigPathDialog::ConfigPathDialog( romButton->clearFlags(WIDGET_ENABLED); myRomPath->setEditable(false); } - - // Create file browser dialog - myBrowser = make_ptr(this, font, max_w, max_h); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -190,7 +187,7 @@ void ConfigPathDialog::setDefaults() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ConfigPathDialog::handleCommand(CommandSender* sender, int cmd, - int data, int id) + int data, int id) { switch (cmd) { @@ -206,31 +203,49 @@ void ConfigPathDialog::handleCommand(CommandSender* sender, int cmd, break; case kChooseRomDirCmd: + // This dialog is resizable under certain conditions, so we need + // to re-create it as necessary + createBrowser(); myBrowser->show("Select ROM directory:", myRomPath->getText(), BrowserDialog::Directories, LauncherDialog::kRomDirChosenCmd); break; case kChooseCheatFileCmd: + // This dialog is resizable under certain conditions, so we need + // to re-create it as necessary + createBrowser(); myBrowser->show("Select cheat file:", myCheatFile->getText(), BrowserDialog::FileLoad, kCheatFileChosenCmd); break; case kChoosePaletteFileCmd: + // This dialog is resizable under certain conditions, so we need + // to re-create it as necessary + createBrowser(); myBrowser->show("Select palette file:", myPaletteFile->getText(), BrowserDialog::FileLoad, kPaletteFileChosenCmd); break; case kChoosePropsFileCmd: + // This dialog is resizable under certain conditions, so we need + // to re-create it as necessary + createBrowser(); myBrowser->show("Select properties file:", myPropsFile->getText(), BrowserDialog::FileLoad, kPropsFileChosenCmd); break; case kChooseNVRamDirCmd: + // This dialog is resizable under certain conditions, so we need + // to re-create it as necessary + createBrowser(); myBrowser->show("Select NVRAM directory:", myNVRamPath->getText(), BrowserDialog::Directories, kNVRamDirChosenCmd); break; case kChooseStateDirCmd: + // This dialog is resizable under certain conditions, so we need + // to re-create it as necessary + createBrowser(); myBrowser->show("Select state directory:", myStatePath->getText(), BrowserDialog::Directories, kStateDirChosenCmd); break; @@ -268,3 +283,15 @@ void ConfigPathDialog::handleCommand(CommandSender* sender, int cmd, break; } } + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ConfigPathDialog::createBrowser() +{ + uInt32 w = 0, h = 0; + getResizableBounds(w, h); + + // Create file browser dialog + if(!myBrowser || uInt32(myBrowser->getWidth()) != w || + uInt32(myBrowser->getHeight()) != h) + myBrowser = make_ptr(this, myFont, w, h); +} diff --git a/src/gui/ConfigPathDialog.hxx b/src/gui/ConfigPathDialog.hxx index 7477f5a99..c706961c0 100644 --- a/src/gui/ConfigPathDialog.hxx +++ b/src/gui/ConfigPathDialog.hxx @@ -35,12 +35,12 @@ class ConfigPathDialog : public Dialog, public CommandSender { public: ConfigPathDialog(OSystem& osystem, DialogContainer& parent, - const GUI::Font& font, GuiObject* boss, - int max_w, int max_h); + const GUI::Font& font, GuiObject* boss); virtual ~ConfigPathDialog() = default; private: void handleCommand(CommandSender* sender, int cmd, int data, int id) override; + void createBrowser(); void loadConfig() override; void saveConfig() override; @@ -61,7 +61,7 @@ class ConfigPathDialog : public Dialog, public CommandSender kNVRamDirChosenCmd = 'LOnc' // nvram (flash/eeprom) dir changed }; - unique_ptr myBrowser; + const GUI::Font& myFont; // Config paths EditTextWidget* myRomPath; @@ -71,6 +71,8 @@ class ConfigPathDialog : public Dialog, public CommandSender EditTextWidget* myPaletteFile; EditTextWidget* myPropsFile; + unique_ptr myBrowser; + // Indicates if this dialog is used for global (vs. in-game) settings bool myIsGlobal; diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index 88f78661e..dfe30aae6 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -723,3 +723,21 @@ Widget* Dialog::TabFocus::getNewFocus() return (currentTab < focus.size()) ? focus[currentTab].widget : nullptr; } + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool Dialog::getResizableBounds(uInt32& w, uInt32& h) const +{ + const GUI::Rect& r = instance().frameBuffer().imageRect(); + if(r.width() <= FrameBuffer::kFBMinW || r.height() <= FrameBuffer::kFBMinH) + { + w = uInt32(0.8 * FrameBuffer::kTIAMinW) * 2; + h = FrameBuffer::kTIAMinH * 2; + return false; + } + else + { + w = std::max(uInt32(0.8 * r.width()), uInt32(FrameBuffer::kFBMinW)); + h = std::max(uInt32(0.8 * r.height()), uInt32(FrameBuffer::kFBMinH)); + return true; + } +} diff --git a/src/gui/Dialog.hxx b/src/gui/Dialog.hxx index 6f3c3cf1e..9a8c13111 100644 --- a/src/gui/Dialog.hxx +++ b/src/gui/Dialog.hxx @@ -105,6 +105,11 @@ class Dialog : public GuiObject void processCancelWithoutWidget(bool state) { _processCancel = state; } + /** Determine the maximum bounds based on the given width and height + Returns whether or not a large font can be used within these bounds. + */ + bool getResizableBounds(uInt32& w, uInt32& h) const; + private: void buildCurrentFocusList(int tabID = -1); bool handleNavEvent(Event::Type e); diff --git a/src/gui/LoggerDialog.cxx b/src/gui/LoggerDialog.cxx index 117ed48b3..1cd9ce1d8 100644 --- a/src/gui/LoggerDialog.cxx +++ b/src/gui/LoggerDialog.cxx @@ -34,7 +34,8 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LoggerDialog::LoggerDialog(OSystem& osystem, DialogContainer& parent, - const GUI::Font& font, int max_w, int max_h) + const GUI::Font& font, int max_w, int max_h, + bool uselargefont) : Dialog(osystem, parent), myLogInfo(nullptr) { @@ -51,10 +52,9 @@ LoggerDialog::LoggerDialog(OSystem& osystem, DialogContainer& parent, // Test listing of the log output xpos = 10; ypos = 10; - myLogInfo = new StringListWidget(this, instance().frameBuffer().infoFont(), - xpos, ypos, _w - 2 * xpos, - _h - buttonHeight - ypos - 20 - 2 * lineHeight, - false); + myLogInfo = new StringListWidget(this, uselargefont ? font : + instance().frameBuffer().infoFont(), xpos, ypos, _w - 2 * xpos, + _h - buttonHeight - ypos - 20 - 2 * lineHeight, false); myLogInfo->setEditable(false); wid.push_back(myLogInfo); ypos += myLogInfo->getHeight() + 8; diff --git a/src/gui/LoggerDialog.hxx b/src/gui/LoggerDialog.hxx index 05c0b423e..d84d3bd3d 100644 --- a/src/gui/LoggerDialog.hxx +++ b/src/gui/LoggerDialog.hxx @@ -31,7 +31,8 @@ class LoggerDialog : public Dialog { public: LoggerDialog(OSystem& osystem, DialogContainer& parent, - const GUI::Font& font, int max_w, int max_h); + const GUI::Font& font, int max_w, int max_h, + bool useLargeFont = true); virtual ~LoggerDialog() = default; private: diff --git a/src/gui/OptionsDialog.cxx b/src/gui/OptionsDialog.cxx index 3cda94c83..ff30df2f5 100644 --- a/src/gui/OptionsDialog.cxx +++ b/src/gui/OptionsDialog.cxx @@ -120,8 +120,8 @@ OptionsDialog::OptionsDialog(OSystem& osystem, DialogContainer& parent, myAudioDialog = make_ptr(osystem, parent, font); myInputDialog = make_ptr(osystem, parent, font, max_w, max_h); myUIDialog = make_ptr(osystem, parent, font); - mySnapshotDialog = make_ptr(osystem, parent, font, boss, max_w, max_h); - myConfigPathDialog = make_ptr(osystem, parent, font, boss, max_w, max_h); + mySnapshotDialog = make_ptr(osystem, parent, font, boss); + myConfigPathDialog = make_ptr(osystem, parent, font, boss); myRomAuditDialog = make_ptr(osystem, parent, font, max_w, max_h); myGameInfoDialog = make_ptr(osystem, parent, font, this); #ifdef CHEATCODE_SUPPORT @@ -211,6 +211,16 @@ void OptionsDialog::handleCommand(CommandSender* sender, int cmd, #endif case kLoggerCmd: + // This dialog is resizable under certain conditions, so we need + // to re-create it as necessary + if(!myIsGlobal) + { + uInt32 w = 0, h = 0; + bool uselargefont = getResizableBounds(w, h); + + myLoggerDialog = make_ptr(instance(), parent(), + instance().frameBuffer().font(), w, h, uselargefont); + } myLoggerDialog->open(); break; diff --git a/src/gui/SnapshotDialog.cxx b/src/gui/SnapshotDialog.cxx index 484a0f9b8..e5bd0edbb 100644 --- a/src/gui/SnapshotDialog.cxx +++ b/src/gui/SnapshotDialog.cxx @@ -29,10 +29,9 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SnapshotDialog::SnapshotDialog( OSystem& osystem, DialogContainer& parent, - const GUI::Font& font, GuiObject* boss, - int max_w, int max_h) + const GUI::Font& font, GuiObject* boss) : Dialog(osystem, parent), - myBrowser(nullptr) + myFont(font) { const int lineHeight = font.getLineHeight(), fontWidth = font.getMaxCharWidth(), @@ -124,9 +123,6 @@ SnapshotDialog::SnapshotDialog( addOKCancelBGroup(wid, font); addToFocusList(wid); - - // Create file browser dialog - myBrowser = make_ptr(this, font, max_w, max_h); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -185,11 +181,17 @@ void SnapshotDialog::handleCommand(CommandSender* sender, int cmd, break; case kChooseSnapSaveDirCmd: + // This dialog is resizable under certain conditions, so we need + // to re-create it as necessary + createBrowser(); myBrowser->show("Select snapshot save directory:", mySnapSavePath->getText(), BrowserDialog::Directories, kSnapSaveDirChosenCmd); break; case kChooseSnapLoadDirCmd: + // This dialog is resizable under certain conditions, so we need + // to re-create it as necessary + createBrowser(); myBrowser->show("Select snapshot load directory:", mySnapLoadPath->getText(), BrowserDialog::Directories, kSnapLoadDirChosenCmd); break; @@ -207,3 +209,15 @@ void SnapshotDialog::handleCommand(CommandSender* sender, int cmd, break; } } + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void SnapshotDialog::createBrowser() +{ + uInt32 w = 0, h = 0; + getResizableBounds(w, h); + + // Create file browser dialog + if(!myBrowser || uInt32(myBrowser->getWidth()) != w || + uInt32(myBrowser->getHeight()) != h) + myBrowser = make_ptr(this, myFont, w, h); +} diff --git a/src/gui/SnapshotDialog.hxx b/src/gui/SnapshotDialog.hxx index 0d1711669..343fc2923 100644 --- a/src/gui/SnapshotDialog.hxx +++ b/src/gui/SnapshotDialog.hxx @@ -35,8 +35,7 @@ class SnapshotDialog : public Dialog { public: SnapshotDialog(OSystem& osystem, DialogContainer& parent, - const GUI::Font& font, GuiObject* boss, - int max_w, int max_h); + const GUI::Font& font, GuiObject* boss); virtual ~SnapshotDialog() = default; private: @@ -45,6 +44,7 @@ class SnapshotDialog : public Dialog void setDefaults() override; void handleCommand(CommandSender* sender, int cmd, int data, int id) override; + void createBrowser(); private: enum { @@ -54,7 +54,7 @@ class SnapshotDialog : public Dialog kSnapLoadDirChosenCmd = 'snlc' // snap chosen (load files) }; - unique_ptr myBrowser; + const GUI::Font& myFont; // Config paths EditTextWidget* mySnapSavePath; @@ -66,6 +66,8 @@ class SnapshotDialog : public Dialog CheckboxWidget* mySnapSingle; CheckboxWidget* mySnap1x; + unique_ptr myBrowser; + private: // Following constructors and assignment operators not supported SnapshotDialog() = delete; diff --git a/src/gui/UIDialog.cxx b/src/gui/UIDialog.cxx index c6a9690fa..5e33189b8 100644 --- a/src/gui/UIDialog.cxx +++ b/src/gui/UIDialog.cxx @@ -415,7 +415,7 @@ void UIDialog::setDefaults() { case 0: // Launcher options { - uInt32 w = std::min(instance().frameBuffer().desktopSize().w, 1000u); + uInt32 w = std::min(instance().frameBuffer().desktopSize().w, 900u); uInt32 h = std::min(instance().frameBuffer().desktopSize().h, 600u); myLauncherWidthSlider->setValue(w); myLauncherWidthLabel->setValue(w);