Merge branch 'release/6.0' of https://github.com/stella-emu/stella into release/6.0

This commit is contained in:
thrust26 2018-08-29 16:41:22 +02:00
commit 6099530ca4
8 changed files with 63 additions and 51 deletions

View File

@ -291,7 +291,7 @@ void ConfigPathDialog::handleCommand(CommandSender* sender, int cmd,
void ConfigPathDialog::createBrowser(const string& title) void ConfigPathDialog::createBrowser(const string& title)
{ {
uInt32 w = 0, h = 0; uInt32 w = 0, h = 0;
getResizableBounds(w, h); getDynamicBounds(w, h);
// Create file browser dialog // Create file browser dialog
if(!myBrowser || uInt32(myBrowser->getWidth()) != w || if(!myBrowser || uInt32(myBrowser->getWidth()) != w ||

View File

@ -798,28 +798,20 @@ Widget* Dialog::TabFocus::getNewFocus()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Dialog::getResizableBounds(uInt32& w, uInt32& h) const bool Dialog::getDynamicBounds(uInt32& w, uInt32& h) const
{ {
const GUI::Rect& r = instance().frameBuffer().imageRect(); const GUI::Rect& r = instance().frameBuffer().imageRect();
bool ntsc = true;
if(instance().hasConsole())
{
ntsc = instance().console().tia().frameLayout() == FrameLayout::ntsc;
}
uInt32 aspect = instance().settings().getInt(ntsc ?"tia.aspectn" : "tia.aspectp");
if(r.width() <= FrameBuffer::kFBMinW || r.height() <= FrameBuffer::kFBMinH) if(r.width() <= FrameBuffer::kFBMinW || r.height() <= FrameBuffer::kFBMinH)
{ {
w = uInt32(aspect * FrameBuffer::kTIAMinW) * 2 / 100; w = r.width();
h = FrameBuffer::kTIAMinH * 2; h = r.height();
return false; return false;
} }
else else
{ {
w = std::max(uInt32(aspect * r.width() / 100), uInt32(FrameBuffer::kFBMinW)); w = uInt32(0.9 * r.width());
h = std::max(uInt32(aspect * r.height() / 100), uInt32(FrameBuffer::kFBMinH)); h = uInt32(0.9 * r.height());
return true; return true;
} }
} }

View File

@ -97,10 +97,23 @@ class Dialog : public GuiObject
void setTitle(const string& title); void setTitle(const string& title);
bool hasTitle() { return !_title.empty(); } bool hasTitle() { return !_title.empty(); }
/** Determine the maximum bounds based on the given width and height /**
Returns whether or not a large font can be used within these bounds. Determine the maximum width/height of a dialog based on the minimum
allowable bounds, also taking into account the current window size.
Currently scales the width/height to 90% of allowable area when possible.
NOTE: This method is meant to be used for dynamic, resizeable dialogs.
That is, those that can change size during a program run, and
*have* to take the current window size into account.
@param w The resulting width to use for the dialog
@param h The resulting height to use for the dialog
@return True if the dialog fits in the current window (scaled to 90%)
False if the dialog is smaller than the current window, and
has to be scaled down
*/ */
bool getResizableBounds(uInt32& w, uInt32& h) const; bool getDynamicBounds(uInt32& w, uInt32& h) const;
protected: protected:
virtual void draw() override { } virtual void draw() override { }

View File

@ -136,7 +136,6 @@ OptionsDialog::OptionsDialog(OSystem& osystem, DialogContainer& parent,
#ifdef CHEATCODE_SUPPORT #ifdef CHEATCODE_SUPPORT
myCheatCodeDialog = make_unique<CheatCodeDialog>(osystem, parent, _font); myCheatCodeDialog = make_unique<CheatCodeDialog>(osystem, parent, _font);
#endif #endif
myLoggerDialog = make_unique<LoggerDialog>(osystem, parent, _font, max_w, max_h);
myDeveloperDialog = make_unique<DeveloperDialog>(osystem, parent, _font, max_w, max_h); myDeveloperDialog = make_unique<DeveloperDialog>(osystem, parent, _font, max_w, max_h);
myHelpDialog = make_unique<HelpDialog>(osystem, parent, _font); myHelpDialog = make_unique<HelpDialog>(osystem, parent, _font);
myAboutDialog = make_unique<AboutDialog>(osystem, parent, _font); myAboutDialog = make_unique<AboutDialog>(osystem, parent, _font);
@ -188,17 +187,21 @@ void OptionsDialog::handleCommand(CommandSender* sender, int cmd,
switch(cmd) switch(cmd)
{ {
case kVidCmd: case kVidCmd:
{
// This dialog is resizable under certain conditions, so we need // This dialog is resizable under certain conditions, so we need
// to re-create it as necessary // to re-create it as necessary
if(myMode != launcher) uInt32 w = 0, h = 0;
{ getDynamicBounds(w, h);
uInt32 w = 0, h = 0;
getResizableBounds(w, h); if(myVideoDialog == nullptr ||
uInt32(myVideoDialog->getWidth()) != w ||
uInt32(myVideoDialog->getHeight()) != h)
{
myVideoDialog = make_unique<VideoDialog>(instance(), parent(), instance().frameBuffer().font(), w, h); myVideoDialog = make_unique<VideoDialog>(instance(), parent(), instance().frameBuffer().font(), w, h);
} }
myVideoDialog->open(); myVideoDialog->open();
break; break;
}
case kAudCmd: case kAudCmd:
myAudioDialog->open(); myAudioDialog->open();
@ -213,31 +216,39 @@ void OptionsDialog::handleCommand(CommandSender* sender, int cmd,
break; break;
case kSnapCmd: case kSnapCmd:
{
// This dialog is resizable under certain conditions, so we need // This dialog is resizable under certain conditions, so we need
// to re-create it as necessary // to re-create it as necessary
if(myMode != launcher) uInt32 w = 0, h = 0;
{ getDynamicBounds(w, h);
uInt32 w = 0, h = 0;
getResizableBounds(w, h); if(mySnapshotDialog == nullptr ||
uInt32(mySnapshotDialog->getWidth()) != w ||
uInt32(mySnapshotDialog->getHeight()) != h)
{
mySnapshotDialog = make_unique<SnapshotDialog>(instance(), parent(), instance().frameBuffer().font(), w, h); mySnapshotDialog = make_unique<SnapshotDialog>(instance(), parent(), instance().frameBuffer().font(), w, h);
} }
mySnapshotDialog->open(); mySnapshotDialog->open();
break; break;
}
case kCfgPathsCmd: case kCfgPathsCmd:
{
// This dialog is resizable under certain conditions, so we need // This dialog is resizable under certain conditions, so we need
// to re-create it as necessary // to re-create it as necessary
if(myMode != launcher) uInt32 w = 0, h = 0;
{ getDynamicBounds(w, h);
uInt32 w = 0, h = 0;
getResizableBounds(w, h); if(myConfigPathDialog == nullptr ||
uInt32(myConfigPathDialog->getWidth()) != w ||
uInt32(myConfigPathDialog->getHeight()) != h)
{
myConfigPathDialog = make_unique<ConfigPathDialog>(instance(), parent(), myConfigPathDialog = make_unique<ConfigPathDialog>(instance(), parent(),
instance().frameBuffer().font(), _boss, w, h); instance().frameBuffer().font(), _boss, w, h);
} }
myConfigPathDialog->open(); myConfigPathDialog->open();
break; break;
}
case kAuditCmd: case kAuditCmd:
myRomAuditDialog->open(); myRomAuditDialog->open();
@ -254,18 +265,23 @@ void OptionsDialog::handleCommand(CommandSender* sender, int cmd,
#endif #endif
case kLoggerCmd: case kLoggerCmd:
{
// This dialog is resizable under certain conditions, so we need // This dialog is resizable under certain conditions, so we need
// to re-create it as necessary // to re-create it as necessary
if(myMode != launcher) uInt32 w = 0, h = 0;
{ bool uselargefont = getDynamicBounds(w, h);
uInt32 w = 0, h = 0;
bool uselargefont = getResizableBounds(w, h);
if(myLoggerDialog == nullptr ||
uInt32(myLoggerDialog->getWidth()) != w ||
uInt32(myLoggerDialog->getHeight()) != h)
{
myLoggerDialog = make_unique<LoggerDialog>(instance(), parent(), myLoggerDialog = make_unique<LoggerDialog>(instance(), parent(),
instance().frameBuffer().font(), w, h, uselargefont); instance().frameBuffer().font(), w, h, uselargefont);
} }
myLoggerDialog->open(); myLoggerDialog->open();
break; break;
}
case kDevelopCmd: case kDevelopCmd:
myDeveloperDialog->open(); myDeveloperDialog->open();

View File

@ -180,7 +180,7 @@ void SnapshotDialog::handleCommand(CommandSender* sender, int cmd,
void SnapshotDialog::createBrowser(const string& title) void SnapshotDialog::createBrowser(const string& title)
{ {
uInt32 w = 0, h = 0; uInt32 w = 0, h = 0;
getResizableBounds(w, h); getDynamicBounds(w, h);
// Create file browser dialog // Create file browser dialog
if(!myBrowser || uInt32(myBrowser->getWidth()) != w || if(!myBrowser || uInt32(myBrowser->getWidth()) != w ||

View File

@ -31,21 +31,13 @@ TimeMachine::TimeMachine(OSystem& osystem)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TimeMachine::requestResize() void TimeMachine::requestResize()
{ {
uInt32 w, h; uInt32 w = 0, h = 0;
myBaseDialog->getResizableBounds(w, h); myBaseDialog->getDynamicBounds(w, h);
// If dialog is too large for given area, we need to resize it
// Otherwise, make it 80% of the allowable width
int newWidth = myWidth;
if(w < FrameBuffer::kFBMinW)
newWidth = w;
else if(myBaseDialog->getWidth() != 0.8 * w)
newWidth = uInt32(0.8 * w);
// Only re-create when absolutely necessary // Only re-create when absolutely necessary
if(myWidth != newWidth) if(myWidth != w)
{ {
myWidth = newWidth; myWidth = w;
Dialog* oldPtr = myBaseDialog; Dialog* oldPtr = myBaseDialog;
Int32 enterWinds = static_cast<TimeMachineDialog*>(myBaseDialog)->getEnterWinds(); Int32 enterWinds = static_cast<TimeMachineDialog*>(myBaseDialog)->getEnterWinds();
delete myBaseDialog; delete myBaseDialog;

View File

@ -45,7 +45,7 @@ class TimeMachine : public DialogContainer
void setEnterWinds(Int32 numWinds); void setEnterWinds(Int32 numWinds);
private: private:
int myWidth; uInt32 myWidth;
private: private:
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported

View File

@ -396,7 +396,7 @@ void UIDialog::handleRomViewer()
void UIDialog::createBrowser(const string& title) void UIDialog::createBrowser(const string& title)
{ {
uInt32 w = 0, h = 0; uInt32 w = 0, h = 0;
getResizableBounds(w, h); getDynamicBounds(w, h);
// Create file browser dialog // Create file browser dialog
if(!myBrowser || uInt32(myBrowser->getWidth()) != w || if(!myBrowser || uInt32(myBrowser->getWidth()) != w ||
@ -405,4 +405,3 @@ void UIDialog::createBrowser(const string& title)
else else
myBrowser->setTitle(title); myBrowser->setTitle(title);
} }