mirror of https://github.com/stella-emu/stella.git
Fixed HiDPI mode for all remaining dialogs (Time Machine, BrowserDialog, etc).
All that's left to do now is testing.
This commit is contained in:
parent
ea92c39234
commit
d98c9514fa
|
@ -23,6 +23,7 @@
|
||||||
#include "Debugger.hxx"
|
#include "Debugger.hxx"
|
||||||
#include "CartDebug.hxx"
|
#include "CartDebug.hxx"
|
||||||
#include "Font.hxx"
|
#include "Font.hxx"
|
||||||
|
#include "FBSurface.hxx"
|
||||||
#include "Widget.hxx"
|
#include "Widget.hxx"
|
||||||
#include "RamWidget.hxx"
|
#include "RamWidget.hxx"
|
||||||
|
|
||||||
|
@ -330,7 +331,7 @@ void RamWidget::showInputBox(int cmd)
|
||||||
uInt32 x = getAbsX() + ((getWidth() - myInputBox->getWidth()) >> 1);
|
uInt32 x = getAbsX() + ((getWidth() - myInputBox->getWidth()) >> 1);
|
||||||
uInt32 y = getAbsY() + ((getHeight() - myInputBox->getHeight()) >> 1);
|
uInt32 y = getAbsY() + ((getHeight() - myInputBox->getHeight()) >> 1);
|
||||||
|
|
||||||
myInputBox->show(x, y);
|
myInputBox->show(x, y, dialog().surface().dstRect());
|
||||||
myInputBox->setText("");
|
myInputBox->setText("");
|
||||||
myInputBox->setMessage("");
|
myInputBox->setMessage("");
|
||||||
myInputBox->setFocus(0);
|
myInputBox->setFocus(0);
|
||||||
|
|
|
@ -885,17 +885,18 @@ Widget* Dialog::TabFocus::getNewFocus()
|
||||||
bool Dialog::getDynamicBounds(uInt32& w, uInt32& h) const
|
bool Dialog::getDynamicBounds(uInt32& w, uInt32& h) const
|
||||||
{
|
{
|
||||||
const Common::Rect& r = instance().frameBuffer().imageRect();
|
const Common::Rect& r = instance().frameBuffer().imageRect();
|
||||||
|
const uInt32 scale = instance().frameBuffer().hidpiScaleFactor();
|
||||||
|
|
||||||
if(r.width() <= FBMinimum::Width || r.height() <= FBMinimum::Height)
|
if(r.width() <= FBMinimum::Width || r.height() <= FBMinimum::Height)
|
||||||
{
|
{
|
||||||
w = r.width();
|
w = r.width() / scale;
|
||||||
h = r.height();
|
h = r.height() / scale;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
w = uInt32(0.95 * r.width());
|
w = uInt32(0.95 * r.width() / scale);
|
||||||
h = uInt32(0.95 * r.height());
|
h = uInt32(0.95 * r.height() / scale);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,10 +118,16 @@ void InputTextDialog::show()
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void InputTextDialog::show(uInt32 x, uInt32 y)
|
void InputTextDialog::show(uInt32 x, uInt32 y, const Common::Rect& bossRect)
|
||||||
{
|
{
|
||||||
myXOrig = x;
|
uInt32 scale = instance().frameBuffer().hidpiScaleFactor();
|
||||||
myYOrig = y;
|
myXOrig = bossRect.x() + x * scale;
|
||||||
|
myYOrig = bossRect.y() + y * scale;
|
||||||
|
|
||||||
|
// Only show dialog if we're inside the visible area
|
||||||
|
if(!bossRect.contains(myXOrig, myYOrig))
|
||||||
|
return;
|
||||||
|
|
||||||
myEnableCenter = false;
|
myEnableCenter = false;
|
||||||
open();
|
open();
|
||||||
}
|
}
|
||||||
|
@ -131,17 +137,14 @@ void InputTextDialog::center()
|
||||||
{
|
{
|
||||||
if(!myEnableCenter)
|
if(!myEnableCenter)
|
||||||
{
|
{
|
||||||
// Make sure the menu is exactly where it should be, in case the image
|
// First set position according to original coordinates
|
||||||
// offset has changed
|
surface().setDstPos(myXOrig, myYOrig);
|
||||||
const Common::Rect& image = instance().frameBuffer().imageRect();
|
|
||||||
uInt32 x = image.x() + myXOrig;
|
|
||||||
uInt32 y = image.y() + myYOrig;
|
|
||||||
uInt32 tx = image.x() + image.width();
|
|
||||||
uInt32 ty = image.y() + image.height();
|
|
||||||
if(x + _w > tx) x -= (x + _w - tx);
|
|
||||||
if(y + _h > ty) y -= (y + _h - ty);
|
|
||||||
|
|
||||||
surface().setDstPos(x, y);
|
// Now make sure that the entire menu can fit inside the image bounds
|
||||||
|
// If not, we reset its position
|
||||||
|
if(!instance().frameBuffer().imageRect().contains(
|
||||||
|
myXOrig, myXOrig, surface().dstRect()))
|
||||||
|
surface().setDstPos(myXOrig, myYOrig);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Dialog::center();
|
Dialog::center();
|
||||||
|
|
|
@ -39,7 +39,7 @@ class InputTextDialog : public Dialog, public CommandSender
|
||||||
void show();
|
void show();
|
||||||
|
|
||||||
/** Show input dialog onscreen at the specified coordinates */
|
/** Show input dialog onscreen at the specified coordinates */
|
||||||
void show(uInt32 x, uInt32 y);
|
void show(uInt32 x, uInt32 y, const Common::Rect& bossRect);
|
||||||
|
|
||||||
const string& getResult(int idx = 0);
|
const string& getResult(int idx = 0);
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
RomAuditDialog::RomAuditDialog(OSystem& osystem, DialogContainer& parent,
|
RomAuditDialog::RomAuditDialog(OSystem& osystem, DialogContainer& parent,
|
||||||
const GUI::Font& font, int max_w, int max_h)
|
const GUI::Font& font, int max_w, int max_h)
|
||||||
: Dialog(osystem, parent, font, "Audit ROMs"),
|
: Dialog(osystem, parent, font, "Audit ROMs"),
|
||||||
|
myFont(font),
|
||||||
myMaxWidth(max_w),
|
myMaxWidth(max_w),
|
||||||
myMaxHeight(max_h)
|
myMaxHeight(max_h)
|
||||||
{
|
{
|
||||||
|
@ -87,9 +88,6 @@ RomAuditDialog::RomAuditDialog(OSystem& osystem, DialogContainer& parent,
|
||||||
// Add OK and Cancel buttons
|
// Add OK and Cancel buttons
|
||||||
addOKCancelBGroup(wid, font, "Audit", "Close");
|
addOKCancelBGroup(wid, font, "Audit", "Close");
|
||||||
addBGroupToFocusList(wid);
|
addBGroupToFocusList(wid);
|
||||||
|
|
||||||
// Create file browser dialog
|
|
||||||
myBrowser = make_unique<BrowserDialog>(this, font, myMaxWidth, myMaxHeight, "Select ROM directory to audit");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -187,9 +185,8 @@ void RomAuditDialog::handleCommand(CommandSender* sender, int cmd,
|
||||||
msg.push_back("If you're sure you want to proceed with the");
|
msg.push_back("If you're sure you want to proceed with the");
|
||||||
msg.push_back("audit, click 'OK', otherwise click 'Cancel'.");
|
msg.push_back("audit, click 'OK', otherwise click 'Cancel'.");
|
||||||
myConfirmMsg = make_unique<GUI::MessageBox>
|
myConfirmMsg = make_unique<GUI::MessageBox>
|
||||||
(this, instance().frameBuffer().font(), msg,
|
(this, myFont, msg, myMaxWidth, myMaxHeight, kConfirmAuditCmd,
|
||||||
myMaxWidth, myMaxHeight, kConfirmAuditCmd,
|
"OK", "Cancel", "ROM Audit", false);
|
||||||
"OK", "Cancel", "ROM Audit", false);
|
|
||||||
}
|
}
|
||||||
myConfirmMsg->show();
|
myConfirmMsg->show();
|
||||||
break;
|
break;
|
||||||
|
@ -200,6 +197,7 @@ void RomAuditDialog::handleCommand(CommandSender* sender, int cmd,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kChooseAuditDirCmd:
|
case kChooseAuditDirCmd:
|
||||||
|
createBrowser("Select ROM directory to audit");
|
||||||
myBrowser->show(myRomPath->getText(),
|
myBrowser->show(myRomPath->getText(),
|
||||||
BrowserDialog::Directories, kAuditDirChosenCmd);
|
BrowserDialog::Directories, kAuditDirChosenCmd);
|
||||||
break;
|
break;
|
||||||
|
@ -218,3 +216,17 @@ void RomAuditDialog::handleCommand(CommandSender* sender, int cmd,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void RomAuditDialog::createBrowser(const string& title)
|
||||||
|
{
|
||||||
|
uInt32 w = 0, h = 0;
|
||||||
|
getDynamicBounds(w, h);
|
||||||
|
|
||||||
|
// Create file browser dialog
|
||||||
|
if(!myBrowser || uInt32(myBrowser->getWidth()) != w ||
|
||||||
|
uInt32(myBrowser->getHeight()) != h)
|
||||||
|
myBrowser = make_unique<BrowserDialog>(this, myFont, w, h, title);
|
||||||
|
else
|
||||||
|
myBrowser->setTitle(title);
|
||||||
|
}
|
||||||
|
|
|
@ -42,8 +42,7 @@ class RomAuditDialog : public Dialog
|
||||||
private:
|
private:
|
||||||
void loadConfig() override;
|
void loadConfig() override;
|
||||||
void auditRoms();
|
void auditRoms();
|
||||||
void openBrowser(const string& title, const string& startpath,
|
void createBrowser(const string& title);
|
||||||
FilesystemNode::ListMode mode, int cmd);
|
|
||||||
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
|
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -55,6 +54,7 @@ class RomAuditDialog : public Dialog
|
||||||
|
|
||||||
// Select a new ROM audit path
|
// Select a new ROM audit path
|
||||||
unique_ptr<BrowserDialog> myBrowser;
|
unique_ptr<BrowserDialog> myBrowser;
|
||||||
|
const GUI::Font& myFont;
|
||||||
|
|
||||||
// ROM audit path
|
// ROM audit path
|
||||||
EditTextWidget* myRomPath;
|
EditTextWidget* myRomPath;
|
||||||
|
|
Loading…
Reference in New Issue