GUI: Don't enforce full redraw upon closing tool tip

This commit is contained in:
Miro Kropacek 2023-04-29 12:23:01 +02:00 committed by Eugene Sandulenko
parent 751c79e6ff
commit 19b7b2aa20
4 changed files with 25 additions and 5 deletions

View File

@ -97,4 +97,19 @@ void Tooltip::drawDialog(DrawLayer layerToDraw) {
}
}
void Tooltip::close() {
// copy&paste from Dialog::close()
_visible = false;
if (_mouseWidget) {
_mouseWidget->handleMouseLeft(0);
_mouseWidget = nullptr;
}
releaseFocus();
g_gui.closeTopDialog(false);
// instead of kRedrawCloseDialog schedule kRedrawTopDialog of the parent
g_gui.scheduleTopDialogRedraw();
}
}

View File

@ -43,6 +43,8 @@ public:
void receivedFocus(int x = -1, int y = -1) override {}
protected:
void close() override;
void handleMouseDown(int x, int y, int button, int clickCount) override {
close();
_parent->handleMouseDown(x + (getAbsX() - _parent->getAbsX()), y + (getAbsY() - _parent->getAbsY()), button, clickCount);

View File

@ -614,7 +614,7 @@ void GuiManager::openDialog(Dialog *dialog) {
dialog->reflowLayout();
}
void GuiManager::closeTopDialog() {
void GuiManager::closeTopDialog(bool redraw) {
// Don't do anything if no dialog is open
if (_dialogStack.empty())
return;
@ -627,10 +627,12 @@ void GuiManager::closeTopDialog() {
giveFocusToDialog(dialog);
}
if (_redrawStatus != kRedrawFull)
_redrawStatus = kRedrawCloseDialog;
if (redraw) {
if (_redrawStatus != kRedrawFull)
_redrawStatus = kRedrawCloseDialog;
redraw();
this->redraw();
}
}
void GuiManager::setupCursor() {

View File

@ -71,6 +71,7 @@ typedef Common::FixedStack<Dialog *> DialogStack;
*/
class GuiManager : public Common::Singleton<GuiManager>, public CommandSender {
friend class Dialog;
friend class Tooltip;
friend class Common::Singleton<SingletonBaseType>;
GuiManager();
~GuiManager() override;
@ -211,7 +212,7 @@ protected:
void restoreState();
void openDialog(Dialog *dialog);
void closeTopDialog();
void closeTopDialog(bool redraw = true);
void redraw();