diff options
author | frosch <frosch@openttd.org> | 2012-06-01 10:42:46 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2012-06-01 10:42:46 +0000 |
commit | 6207a6017f55729aa3fe365e00c1a4940a917c06 (patch) | |
tree | e8679a0733efb239b280c07e46b608009c687d08 /src/window.cpp | |
parent | b921c17ffb3d7f1a9abc8a52165c55cddd5e3d07 (diff) | |
download | openttd-6207a6017f55729aa3fe365e00c1a4940a917c06.tar.xz |
(svn r24307) -Codechange: Move all interaction of the dropdown window with widgets of the parent window to a method of the parent window.
Diffstat (limited to 'src/window.cpp')
-rw-r--r-- | src/window.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/window.cpp b/src/window.cpp index 6e2916f9e..ad04818ee 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -168,6 +168,39 @@ bool Window::IsWidgetHighlighted(byte widget_index) const } /** + * A dropdown window associated to this window has been closed. + * @param pt the point inside the window the mouse resides on after closure. + * @param widget the widget (button) that the dropdown is associated with. + * @param index the element in the dropdown that is selected. + * @param instant_close whether the dropdown was configured to close on mouse up. + */ +void Window::OnDropdownClose(Point pt, int widget, int index, bool instant_close) +{ + if (widget < 0) return; + + if (instant_close) { + /* Send event for selected option if we're still + * on the parent button of the dropdown (behaviour of the dropdowns in the main toolbar). */ + if (GetWidgetFromPos(this, pt.x, pt.y) == widget) { + this->OnDropdownSelect(widget, index); + } + } + + /* Raise the dropdown button */ + if (this->nested_array != NULL) { + NWidgetCore *nwi2 = this->GetWidget<NWidgetCore>(widget); + if ((nwi2->type & WWT_MASK) == NWID_BUTTON_DROPDOWN) { + nwi2->disp_flags &= ~ND_DROPDOWN_ACTIVE; + } else { + this->RaiseWidget(widget); + } + } else { + this->RaiseWidget(widget); + } + this->SetWidgetDirty(widget); +} + +/** * Return the Scrollbar to a widget index. * @param widnum Scrollbar widget index * @return Scrollbar to the widget |