mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r25292) -Feature: Save stickyness of windows when Ctrl+Clicking the sticky button.
This commit is contained in:
parent
23ba42b66c
commit
ed851034f5
|
@ -32,6 +32,10 @@ cat = SC_ADVANCED
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[SDT_BOOL]
|
||||||
|
var = pref_sticky
|
||||||
|
def = false
|
||||||
|
|
||||||
[SDT_END]
|
[SDT_END]
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -95,7 +95,8 @@ WindowDesc::WindowDesc(WindowPosition def_pos, const char *ini_key, int16 def_wi
|
||||||
ini_key(ini_key),
|
ini_key(ini_key),
|
||||||
flags(flags),
|
flags(flags),
|
||||||
nwid_parts(nwid_parts),
|
nwid_parts(nwid_parts),
|
||||||
nwid_length(nwid_length)
|
nwid_length(nwid_length),
|
||||||
|
pref_sticky(false)
|
||||||
{
|
{
|
||||||
if (_window_descs == NULL) _window_descs = new SmallVector<WindowDesc*, 16>();
|
if (_window_descs == NULL) _window_descs = new SmallVector<WindowDesc*, 16>();
|
||||||
*_window_descs->Append() = this;
|
*_window_descs->Append() = this;
|
||||||
|
@ -146,6 +147,19 @@ void WindowDesc::SaveToConfig()
|
||||||
delete ini;
|
delete ini;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read default values from WindowDesc configuration an apply them to the window.
|
||||||
|
*/
|
||||||
|
void Window::ApplyDefaults()
|
||||||
|
{
|
||||||
|
if (this->nested_root != NULL && this->nested_root->GetWidgetOfType(WWT_STICKYBOX) != NULL) {
|
||||||
|
if (this->window_desc->pref_sticky) this->flags |= WF_STICKY;
|
||||||
|
} else {
|
||||||
|
/* There is no stickybox; clear the preference in case someone tried to be funny */
|
||||||
|
this->window_desc->pref_sticky = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute the row of a widget that a user clicked in.
|
* Compute the row of a widget that a user clicked in.
|
||||||
* @param clickpos Vertical position of the mouse click.
|
* @param clickpos Vertical position of the mouse click.
|
||||||
|
@ -551,6 +565,7 @@ static void DispatchLeftClickEvent(Window *w, int x, int y, int click_count)
|
||||||
case WWT_STICKYBOX:
|
case WWT_STICKYBOX:
|
||||||
w->flags ^= WF_STICKY;
|
w->flags ^= WF_STICKY;
|
||||||
nw->SetDirty(w);
|
nw->SetDirty(w);
|
||||||
|
if (_ctrl_pressed) w->window_desc->pref_sticky = w->flags & WF_STICKY;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -1574,6 +1589,7 @@ void Window::CreateNestedTree(bool fill_nested)
|
||||||
void Window::FinishInitNested(WindowNumber window_number)
|
void Window::FinishInitNested(WindowNumber window_number)
|
||||||
{
|
{
|
||||||
this->InitializeData(window_number);
|
this->InitializeData(window_number);
|
||||||
|
this->ApplyDefaults();
|
||||||
Point pt = this->OnInitialPosition(this->nested_root->smallest_x, this->nested_root->smallest_y, window_number);
|
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->InitializePositionSize(pt.x, pt.y, this->nested_root->smallest_x, this->nested_root->smallest_y);
|
||||||
this->FindWindowPlacementAndResize(this->window_desc->default_width, this->window_desc->default_height);
|
this->FindWindowPlacementAndResize(this->window_desc->default_width, this->window_desc->default_height);
|
||||||
|
|
|
@ -181,6 +181,8 @@ struct WindowDesc : ZeroedMemoryAllocator {
|
||||||
const NWidgetPart *nwid_parts; ///< Nested widget parts describing the window.
|
const NWidgetPart *nwid_parts; ///< Nested widget parts describing the window.
|
||||||
int16 nwid_length; ///< Length of the #nwid_parts array.
|
int16 nwid_length; ///< Length of the #nwid_parts array.
|
||||||
|
|
||||||
|
bool pref_sticky; ///< Preferred stickyness.
|
||||||
|
|
||||||
static void LoadFromConfig();
|
static void LoadFromConfig();
|
||||||
static void SaveToConfig();
|
static void SaveToConfig();
|
||||||
};
|
};
|
||||||
|
@ -508,6 +510,8 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void OnInit() { }
|
virtual void OnInit() { }
|
||||||
|
|
||||||
|
virtual void ApplyDefaults();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute the initial position of the window.
|
* Compute the initial position of the window.
|
||||||
* @param sm_width Smallest width of the window.
|
* @param sm_width Smallest width of the window.
|
||||||
|
|
Loading…
Reference in New Issue