summaryrefslogtreecommitdiff
path: root/src/window.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2013-05-26 19:27:44 +0000
committerfrosch <frosch@openttd.org>2013-05-26 19:27:44 +0000
commited851034f50d4a6614c40bdc45bd651fc1cf0a74 (patch)
treea833df0c25b4d30bea3ef39445668841808ba922 /src/window.cpp
parent23ba42b66ccf915230cab163cdeca19db6e95f76 (diff)
downloadopenttd-ed851034f50d4a6614c40bdc45bd651fc1cf0a74.tar.xz
(svn r25292) -Feature: Save stickyness of windows when Ctrl+Clicking the sticky button.
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/window.cpp b/src/window.cpp
index a50890d42..86702842d 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -95,7 +95,8 @@ WindowDesc::WindowDesc(WindowPosition def_pos, const char *ini_key, int16 def_wi
ini_key(ini_key),
flags(flags),
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>();
*_window_descs->Append() = this;
@@ -147,6 +148,19 @@ void WindowDesc::SaveToConfig()
}
/**
+ * 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.
* @param clickpos Vertical position of the mouse click.
* @param widget Widget number of the widget clicked in.
@@ -551,6 +565,7 @@ static void DispatchLeftClickEvent(Window *w, int x, int y, int click_count)
case WWT_STICKYBOX:
w->flags ^= WF_STICKY;
nw->SetDirty(w);
+ if (_ctrl_pressed) w->window_desc->pref_sticky = w->flags & WF_STICKY;
return;
default:
@@ -1574,6 +1589,7 @@ void Window::CreateNestedTree(bool fill_nested)
void Window::FinishInitNested(WindowNumber window_number)
{
this->InitializeData(window_number);
+ this->ApplyDefaults();
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->default_width, this->window_desc->default_height);