diff --git a/src/debugger/gui/RamWidget.cxx b/src/debugger/gui/RamWidget.cxx index 6bbfcbced..9d0647fc9 100644 --- a/src/debugger/gui/RamWidget.cxx +++ b/src/debugger/gui/RamWidget.cxx @@ -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); diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index 256d432cc..e14566475 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -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; } } diff --git a/src/gui/InputTextDialog.cxx b/src/gui/InputTextDialog.cxx index 983f410e8..930dc2f0a 100644 --- a/src/gui/InputTextDialog.cxx +++ b/src/gui/InputTextDialog.cxx @@ -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(); diff --git a/src/gui/InputTextDialog.hxx b/src/gui/InputTextDialog.hxx index 9c798bc14..6b8ef2eac 100644 --- a/src/gui/InputTextDialog.hxx +++ b/src/gui/InputTextDialog.hxx @@ -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); diff --git a/src/gui/RomAuditDialog.cxx b/src/gui/RomAuditDialog.cxx index 5bd2a98c9..6155ce61e 100644 --- a/src/gui/RomAuditDialog.cxx +++ b/src/gui/RomAuditDialog.cxx @@ -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(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("audit, click 'OK', otherwise click 'Cancel'."); myConfirmMsg = make_unique - (this, instance().frameBuffer().font(), msg, - myMaxWidth, myMaxHeight, kConfirmAuditCmd, - "OK", "Cancel", "ROM Audit", false); + (this, myFont, msg, myMaxWidth, myMaxHeight, kConfirmAuditCmd, + "OK", "Cancel", "ROM Audit", false); } myConfirmMsg->show(); break; @@ -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(this, myFont, w, h, title); + else + myBrowser->setTitle(title); +} diff --git a/src/gui/RomAuditDialog.hxx b/src/gui/RomAuditDialog.hxx index a2ebba3b5..fbd82e693 100644 --- a/src/gui/RomAuditDialog.hxx +++ b/src/gui/RomAuditDialog.hxx @@ -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 myBrowser; + const GUI::Font& myFont; // ROM audit path EditTextWidget* myRomPath;