mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-04 06:00:15 +00:00
(svn r17915) -Codechange: Allow windows to compute their own initial position.
This commit is contained in:
parent
256adf9c8a
commit
2a7d0de0b0
@ -1310,6 +1310,11 @@ static Point LocalGetWindowPlacement(const WindowDesc *desc, int16 sm_width, int
|
||||
return pt;
|
||||
}
|
||||
|
||||
/* virtual */ Point Window::OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number)
|
||||
{
|
||||
return LocalGetWindowPlacement(desc, sm_width, sm_height, window_number);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the positions of a new window from a WindowDesc and open it.
|
||||
*
|
||||
@ -1356,7 +1361,7 @@ void Window::FinishInitNested(const WindowDesc *desc, WindowNumber window_number
|
||||
{
|
||||
this->InitializeData(desc->cls, NULL, window_number);
|
||||
this->desc_flags = desc->flags;
|
||||
Point pt = LocalGetWindowPlacement(desc, this->nested_root->smallest_x, this->nested_root->smallest_y, window_number);
|
||||
Point pt = this->OnInitialPosition(desc, 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(desc->default_width, desc->default_height);
|
||||
}
|
||||
|
@ -638,6 +638,18 @@ public:
|
||||
|
||||
/*** Event handling ***/
|
||||
|
||||
/**
|
||||
* Compute the initial position of the window.
|
||||
* @param *desc The pointer to the WindowDesc of the window to create.
|
||||
* @param sm_width Smallest width of the window.
|
||||
* @param sm_height Smallest height of the window.
|
||||
* @param window_number The window number of the new window.
|
||||
* @return Initial position of the top-left corner of the window.
|
||||
*
|
||||
* @note Due to the way C++ works, only windows with nested widgets can usefully override this function.
|
||||
*/
|
||||
virtual Point OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number);
|
||||
|
||||
/**
|
||||
* The window must be repainted.
|
||||
* @note This method should not change any state, it should only use drawing functions.
|
||||
|
Loading…
Reference in New Issue
Block a user