Changeset - r28256:2bc91b6194f4
[Not reviewed]
master
0 2 0
Peter Nelson - 12 months ago 2023-11-29 12:35:02
peter1138@openttd.org
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.
2 files changed with 6 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/window.cpp
Show inline comments
 
@@ -958,8 +958,9 @@ void Window::ReInit(int rx, int ry, bool
 
	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 win
 
 * 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);
 
}
src/window_gui.h
Show inline comments
 
@@ -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.
 

	
0 comments (0 inline, 0 general)