mirror of https://github.com/OpenTTD/OpenTTD
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.pull/11562/head
parent
e2425b72c1
commit
3317e29847
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -242,6 +242,8 @@ public:
|
|||
WindowClass window_class; ///< Window class
|
||||
WindowNumber window_number; ///< Window number within the window class
|
||||
|
||||
int scale; ///< Scale of this window -- used to determine how to resize.
|
||||
|
||||
uint8_t timeout_timer; ///< Timer value of the WF_TIMEOUT for flags.
|
||||
uint8_t white_border_timer; ///< Timer value of the WF_WHITE_BORDER for flags.
|
||||
|
||||
|
|
Loading…
Reference in New Issue