Fixes for various dialog boxes in 'small-window' modes.

When in TIA emulation mode at 2x zoom level, all dialogs which
are variable in size will now fit in the window.  In other cases,
the dialog will take up 80% of the available space.
This commit is contained in:
Stephen Anthony 2017-05-05 20:25:52 -02:30
parent 6ba627e059
commit bab6e3119d
10 changed files with 106 additions and 27 deletions

View File

@ -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<BrowserDialog>(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<BrowserDialog>(this, myFont, w, h);
}

View File

@ -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<BrowserDialog> 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<BrowserDialog> myBrowser;
// Indicates if this dialog is used for global (vs. in-game) settings
bool myIsGlobal;

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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;

View File

@ -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:

View File

@ -120,8 +120,8 @@ OptionsDialog::OptionsDialog(OSystem& osystem, DialogContainer& parent,
myAudioDialog = make_ptr<AudioDialog>(osystem, parent, font);
myInputDialog = make_ptr<InputDialog>(osystem, parent, font, max_w, max_h);
myUIDialog = make_ptr<UIDialog>(osystem, parent, font);
mySnapshotDialog = make_ptr<SnapshotDialog>(osystem, parent, font, boss, max_w, max_h);
myConfigPathDialog = make_ptr<ConfigPathDialog>(osystem, parent, font, boss, max_w, max_h);
mySnapshotDialog = make_ptr<SnapshotDialog>(osystem, parent, font, boss);
myConfigPathDialog = make_ptr<ConfigPathDialog>(osystem, parent, font, boss);
myRomAuditDialog = make_ptr<RomAuditDialog>(osystem, parent, font, max_w, max_h);
myGameInfoDialog = make_ptr<GameInfoDialog>(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<LoggerDialog>(instance(), parent(),
instance().frameBuffer().font(), w, h, uselargefont);
}
myLoggerDialog->open();
break;

View File

@ -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<BrowserDialog>(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<BrowserDialog>(this, myFont, w, h);
}

View File

@ -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<BrowserDialog> myBrowser;
const GUI::Font& myFont;
// Config paths
EditTextWidget* mySnapSavePath;
@ -66,6 +66,8 @@ class SnapshotDialog : public Dialog
CheckboxWidget* mySnapSingle;
CheckboxWidget* mySnap1x;
unique_ptr<BrowserDialog> myBrowser;
private:
// Following constructors and assignment operators not supported
SnapshotDialog() = delete;

View File

@ -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);