summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-08-12 11:53:11 +0000
committerfrosch <frosch@openttd.org>2010-08-12 11:53:11 +0000
commit28048826f8a1c37bc88294c526ce1ba9f048d65e (patch)
tree635c579a1359ccefbd8cff7c9c9c1ddb9ff84596
parent419c269e56c26227daff7a5f283c3a8c9f12234d (diff)
downloadopenttd-28048826f8a1c37bc88294c526ce1ba9f048d65e.tar.xz
(svn r20466) -Codechange: USe NWID_SELECTION to hide the scrollbar in dropdowns.
-rw-r--r--src/widgets/dropdown.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp
index b690b286f..4609d07e2 100644
--- a/src/widgets/dropdown.cpp
+++ b/src/widgets/dropdown.cpp
@@ -69,14 +69,17 @@ static void DeleteDropDownList(DropDownList *list)
/** Widget numbers of the dropdown menu. */
enum DropdownMenuWidgets {
- DDM_ITEMS, ///< Panel showing the dropdown items.
- DDM_SCROLL, ///< Scrollbar.
+ DDM_ITEMS, ///< Panel showing the dropdown items.
+ DDM_SHOW_SCROLL, ///< Hide scrollbar if too few items.
+ DDM_SCROLL, ///< Scrollbar.
};
static const NWidgetPart _nested_dropdown_menu_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_PANEL, COLOUR_END, DDM_ITEMS), SetMinimalSize(1, 1), SetScrollbar(DDM_SCROLL), EndContainer(),
- NWidget(NWID_VSCROLLBAR, COLOUR_END, DDM_SCROLL),
+ NWidget(NWID_SELECTION, INVALID_COLOUR, DDM_SHOW_SCROLL),
+ NWidget(NWID_VSCROLLBAR, COLOUR_END, DDM_SCROLL),
+ EndContainer(),
EndContainer(),
};
@@ -128,11 +131,9 @@ struct DropdownWindow : Window {
nwi->colour = wi_colour;
nwi = this->GetWidget<NWidgetCore>(DDM_SCROLL);
- if (scroll) {
- nwi->colour = wi_colour;
- } else {
- nwi->min_x = 0; // Make scrollbar invisible.
- }
+ nwi->colour = wi_colour;
+
+ this->GetWidget<NWidgetStacked>(DDM_SHOW_SCROLL)->SetDisplayedPlane(scroll ? 0 : SZSP_NONE);
this->FinishInitNested(&_dropdown_desc, 0);
this->flags4 &= ~WF_WHITE_BORDER_MASK;