mirror of https://github.com/OpenTTD/OpenTTD
pull/11901/head
parent
8c5ad1ade7
commit
d3c673e20b
|
@ -1447,8 +1447,8 @@ void Window::FindWindowPlacementAndResize(int def_width, int def_height)
|
||||||
ResizeWindow(this, enlarge_x, enlarge_y);
|
ResizeWindow(this, enlarge_x, enlarge_y);
|
||||||
/* ResizeWindow() calls this->OnResize(). */
|
/* ResizeWindow() calls this->OnResize(). */
|
||||||
} else {
|
} else {
|
||||||
/* Always call OnResize; that way the scrollbars and matrices get initialized. */
|
/* Schedule OnResize; that way the scrollbars and matrices get initialized. */
|
||||||
this->OnResize();
|
this->ScheduleResize();
|
||||||
}
|
}
|
||||||
|
|
||||||
int nx = this->left;
|
int nx = this->left;
|
||||||
|
@ -2050,8 +2050,8 @@ void ResizeWindow(Window *w, int delta_x, int delta_y, bool clamp_to_screen)
|
||||||
|
|
||||||
EnsureVisibleCaption(w, w->left, w->top);
|
EnsureVisibleCaption(w, w->left, w->top);
|
||||||
|
|
||||||
/* Always call OnResize to make sure everything is initialised correctly if it needs to be. */
|
/* Schedule OnResize to make sure everything is initialised correctly if it needs to be. */
|
||||||
w->OnResize();
|
w->ScheduleResize();
|
||||||
w->SetDirty();
|
w->SetDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3054,6 +3054,7 @@ void UpdateWindows()
|
||||||
|
|
||||||
/* Process invalidations before anything else. */
|
/* Process invalidations before anything else. */
|
||||||
for (Window *w : Window::Iterate()) {
|
for (Window *w : Window::Iterate()) {
|
||||||
|
w->ProcessScheduledResize();
|
||||||
w->ProcessScheduledInvalidations();
|
w->ProcessScheduledInvalidations();
|
||||||
w->ProcessHighlightedInvalidations();
|
w->ProcessHighlightedInvalidations();
|
||||||
}
|
}
|
||||||
|
@ -3111,6 +3112,26 @@ void SetWindowClassesDirty(WindowClass cls)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mark this window as resized and in need of OnResize() event.
|
||||||
|
*/
|
||||||
|
void Window::ScheduleResize()
|
||||||
|
{
|
||||||
|
this->scheduled_resize = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process scheduled OnResize() event.
|
||||||
|
*/
|
||||||
|
void Window::ProcessScheduledResize()
|
||||||
|
{
|
||||||
|
/* Sometimes OnResize() resizes the window again, in which case we can reprocess immediately. */
|
||||||
|
while (this->scheduled_resize) {
|
||||||
|
this->scheduled_resize = false;
|
||||||
|
this->OnResize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark this window's data as invalid (in need of re-computing)
|
* Mark this window's data as invalid (in need of re-computing)
|
||||||
* @param data The data to invalidate with
|
* @param data The data to invalidate with
|
||||||
|
|
|
@ -274,6 +274,7 @@ protected:
|
||||||
virtual void FindWindowPlacementAndResize(int def_width, int def_height);
|
virtual void FindWindowPlacementAndResize(int def_width, int def_height);
|
||||||
|
|
||||||
std::vector<int> scheduled_invalidation_data; ///< Data of scheduled OnInvalidateData() calls.
|
std::vector<int> scheduled_invalidation_data; ///< Data of scheduled OnInvalidateData() calls.
|
||||||
|
bool scheduled_resize; ///< Set if window has been resized.
|
||||||
|
|
||||||
/* Protected to prevent deletion anywhere outside Window::DeleteClosedWindows(). */
|
/* Protected to prevent deletion anywhere outside Window::DeleteClosedWindows(). */
|
||||||
virtual ~Window();
|
virtual ~Window();
|
||||||
|
@ -559,6 +560,8 @@ public:
|
||||||
|
|
||||||
void SetShaded(bool make_shaded);
|
void SetShaded(bool make_shaded);
|
||||||
|
|
||||||
|
void ScheduleResize();
|
||||||
|
void ProcessScheduledResize();
|
||||||
void InvalidateData(int data = 0, bool gui_scope = true);
|
void InvalidateData(int data = 0, bool gui_scope = true);
|
||||||
void ProcessScheduledInvalidations();
|
void ProcessScheduledInvalidations();
|
||||||
void ProcessHighlightedInvalidations();
|
void ProcessHighlightedInvalidations();
|
||||||
|
|
Loading…
Reference in New Issue