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
d6fbaba4d4
commit
050a27f1ae
|
@ -23,6 +23,7 @@
|
|||
#include "Debugger.hxx"
|
||||
#include "CartDebug.hxx"
|
||||
#include "Font.hxx"
|
||||
#include "FBSurface.hxx"
|
||||
#include "Widget.hxx"
|
||||
#include "RamWidget.hxx"
|
||||
|
||||
|
@ -330,7 +331,7 @@ void RamWidget::showInputBox(int cmd)
|
|||
uInt32 x = getAbsX() + ((getWidth() - myInputBox->getWidth()) >> 1);
|
||||
uInt32 y = getAbsY() + ((getHeight() - myInputBox->getHeight()) >> 1);
|
||||
|
||||
myInputBox->show(x, y);
|
||||
myInputBox->show(x, y, dialog().surface().dstRect());
|
||||
myInputBox->setText("");
|
||||
myInputBox->setMessage("");
|
||||
myInputBox->setFocus(0);
|
||||
|
|
|
@ -885,17 +885,18 @@ Widget* Dialog::TabFocus::getNewFocus()
|
|||
bool Dialog::getDynamicBounds(uInt32& w, uInt32& h) const
|
||||
{
|
||||
const Common::Rect& r = instance().frameBuffer().imageRect();
|
||||
const uInt32 scale = instance().frameBuffer().hidpiScaleFactor();
|
||||
|
||||
if(r.width() <= FBMinimum::Width || r.height() <= FBMinimum::Height)
|
||||
{
|
||||
w = r.width();
|
||||
h = r.height();
|
||||
w = r.width() / scale;
|
||||
h = r.height() / scale;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
w = uInt32(0.95 * r.width());
|
||||
h = uInt32(0.95 * r.height());
|
||||
w = uInt32(0.95 * r.width() / scale);
|
||||
h = uInt32(0.95 * r.height() / scale);
|
||||
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;
|
||||
myYOrig = y;
|
||||
uInt32 scale = instance().frameBuffer().hidpiScaleFactor();
|
||||
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;
|
||||
open();
|
||||
}
|
||||
|
@ -131,17 +137,14 @@ void InputTextDialog::center()
|
|||
{
|
||||
if(!myEnableCenter)
|
||||
{
|
||||
// Make sure the menu is exactly where it should be, in case the image
|
||||
// offset has changed
|
||||
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);
|
||||
// First set position according to original coordinates
|
||||
surface().setDstPos(myXOrig, myYOrig);
|
||||
|
||||
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
|
||||
Dialog::center();
|
||||
|
|
|
@ -39,7 +39,7 @@ class InputTextDialog : public Dialog, public CommandSender
|
|||
void show();
|
||||
|
||||
/** 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);
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
RomAuditDialog::RomAuditDialog(OSystem& osystem, DialogContainer& parent,
|
||||
const GUI::Font& font, int max_w, int max_h)
|
||||
: Dialog(osystem, parent, font, "Audit ROMs"),
|
||||
myFont(font),
|
||||
myMaxWidth(max_w),
|
||||
myMaxHeight(max_h)
|
||||
{
|
||||
|
@ -87,9 +88,6 @@ RomAuditDialog::RomAuditDialog(OSystem& osystem, DialogContainer& parent,
|
|||
// Add OK and Cancel buttons
|
||||
addOKCancelBGroup(wid, font, "Audit", "Close");
|
||||
addBGroupToFocusList(wid);
|
||||
|
||||
// Create file browser dialog
|
||||
myBrowser = make_unique<BrowserDialog>(this, font, myMaxWidth, myMaxHeight, "Select ROM directory to audit");
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -187,8 +185,7 @@ void RomAuditDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
msg.push_back("If you're sure you want to proceed with the");
|
||||
msg.push_back("audit, click 'OK', otherwise click 'Cancel'.");
|
||||
myConfirmMsg = make_unique<GUI::MessageBox>
|
||||
(this, instance().frameBuffer().font(), msg,
|
||||
myMaxWidth, myMaxHeight, kConfirmAuditCmd,
|
||||
(this, myFont, msg, myMaxWidth, myMaxHeight, kConfirmAuditCmd,
|
||||
"OK", "Cancel", "ROM Audit", false);
|
||||
}
|
||||
myConfirmMsg->show();
|
||||
|
@ -200,6 +197,7 @@ void RomAuditDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
break;
|
||||
|
||||
case kChooseAuditDirCmd:
|
||||
createBrowser("Select ROM directory to audit");
|
||||
myBrowser->show(myRomPath->getText(),
|
||||
BrowserDialog::Directories, kAuditDirChosenCmd);
|
||||
break;
|
||||
|
@ -218,3 +216,17 @@ void RomAuditDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
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:
|
||||
void loadConfig() override;
|
||||
void auditRoms();
|
||||
void openBrowser(const string& title, const string& startpath,
|
||||
FilesystemNode::ListMode mode, int cmd);
|
||||
void createBrowser(const string& title);
|
||||
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
|
||||
|
||||
private:
|
||||
|
@ -55,6 +54,7 @@ class RomAuditDialog : public Dialog
|
|||
|
||||
// Select a new ROM audit path
|
||||
unique_ptr<BrowserDialog> myBrowser;
|
||||
const GUI::Font& myFont;
|
||||
|
||||
// ROM audit path
|
||||
EditTextWidget* myRomPath;
|
||||
|
|
Loading…
Reference in New Issue