Fix #11516: Adjust window size by interface scale during ReInit.

To simplify this and ensure that scaling only occurs once, regardless of
resize nesting, each window now remembers interface scale.
This commit is contained in:
Peter Nelson
2023-11-29 12:35:02 +00:00
committed by Peter Nelson
parent e2425b72c1
commit 3317e29847
2 changed files with 6 additions and 3 deletions

View File

@@ -958,8 +958,9 @@ void Window::ReInit(int rx, int ry, bool reposition)
this->SetDirty(); // Mark whole current window as dirty.
/* Save current size. */
int window_width = this->width;
int window_height = this->height;
int window_width = this->width * _gui_scale / this->scale;
int window_height = this->height * _gui_scale / this->scale;
this->scale = _gui_scale;
this->OnInit();
/* Re-initialize the window from the ground up. No need to change the nested_array, as all widgets stay where they are. */
@@ -1770,7 +1771,7 @@ void Window::InitNested(WindowNumber window_number)
* Empty constructor, initialization has been moved to #InitNested() called from the constructor of the derived class.
* @param desc The description of the window.
*/
Window::Window(WindowDesc *desc) : window_desc(desc), mouse_capture_widget(-1)
Window::Window(WindowDesc *desc) : window_desc(desc), scale(_gui_scale), mouse_capture_widget(-1)
{
this->z_position = _z_windows.insert(_z_windows.end(), this);
}