summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeterN <peter1138@openttd.org>2021-05-03 16:39:20 +0100
committerGitHub <noreply@github.com>2021-05-03 16:39:20 +0100
commit08781d96ed385158a5b452be1779260a92204e4e (patch)
treeb5e9872c22d678499e0a8a110d9be51fca9e8f4e
parent0bc6f3234664cbd71dab89ddf75b14616cced160 (diff)
downloadopenttd-08781d96ed385158a5b452be1779260a92204e4e.tar.xz
Fix: Query windows may be partially drawn initially. (#9184)
Query window was not marked dirty after being moved on init. It was then marked dirty once the white border flash completed.
-rw-r--r--src/misc_gui.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index b2de45140..e9ee7b193 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -1162,12 +1162,9 @@ struct QueryWindow : public Window {
this->caption = caption;
this->message = message;
this->proc = callback;
+ this->parent = parent;
this->InitNested(WN_CONFIRM_POPUP_QUERY);
-
- this->parent = parent;
- this->left = parent->left + (parent->width / 2) - (this->width / 2);
- this->top = parent->top + (parent->height / 2) - (this->height / 2);
}
~QueryWindow()
@@ -1175,6 +1172,14 @@ struct QueryWindow : public Window {
if (this->proc != nullptr) this->proc(this->parent, false);
}
+ void FindWindowPlacementAndResize(int def_width, int def_height) override
+ {
+ /* Position query window over the calling window, ensuring it's within screen bounds. */
+ this->left = Clamp(parent->left + (parent->width / 2) - (this->width / 2), 0, _screen.width - this->width);
+ this->top = Clamp(parent->top + (parent->height / 2) - (this->height / 2), 0, _screen.height - this->height);
+ this->SetDirty();
+ }
+
void SetStringParameters(int widget) const override
{
switch (widget) {