Add: parameter for ReInit() to reposition window to default.

This commit is contained in:
Peter Nelson 2023-04-25 09:13:33 +01:00 committed by PeterN
parent 55d981aec3
commit e8df28d7f3
2 changed files with 9 additions and 2 deletions

View File

@ -1010,9 +1010,10 @@ void Window::SetDirty() const
* Re-initialize a window, and optionally change its size.
* @param rx Horizontal resize of the window.
* @param ry Vertical resize of the window.
* @param reposition If set, reposition the window to default location.
* @note For just resizing the window, use #ResizeWindow instead.
*/
void Window::ReInit(int rx, int ry)
void Window::ReInit(int rx, int ry, bool reposition)
{
this->SetDirty(); // Mark whole current window as dirty.
@ -1039,6 +1040,12 @@ void Window::ReInit(int rx, int ry)
if (this->resize.step_width > 1) dx -= dx % (int)this->resize.step_width;
if (this->resize.step_height > 1) dy -= dy % (int)this->resize.step_height;
if (reposition) {
Point pt = this->OnInitialPosition(this->nested_root->smallest_x, this->nested_root->smallest_y, window_number);
this->InitializePositionSize(pt.x, pt.y, this->nested_root->smallest_x, this->nested_root->smallest_y);
this->FindWindowPlacementAndResize(this->window_desc->GetDefaultWidth(), this->window_desc->GetDefaultHeight());
}
ResizeWindow(this, dx, dy);
/* ResizeWindow() does this->SetDirty() already, no need to do it again here. */
}

View File

@ -449,7 +449,7 @@ public:
static void DeleteClosedWindows();
void SetDirty() const;
void ReInit(int rx = 0, int ry = 0);
void ReInit(int rx = 0, int ry = 0, bool reposition = false);
/** Is window shaded currently? */
inline bool IsShaded() const