diff options
author | peter1138 <peter1138@openttd.org> | 2008-01-17 18:09:15 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2008-01-17 18:09:15 +0000 |
commit | c313676c66c580318f6534cbedeb1dd95cfad979 (patch) | |
tree | fa083ad3eb559492f9ce334358aedfc49ec5d130 /src/widgets/dropdown.cpp | |
parent | c74cf439fa22a7c8e0517b0773dc6800e4ee7bb5 (diff) | |
download | openttd-c313676c66c580318f6534cbedeb1dd95cfad979.tar.xz |
(svn r11901) -Add: add two widgets for dropdowns, one raised and one inset, to eventually replace use of two widgets for each dropdown control.
Diffstat (limited to 'src/widgets/dropdown.cpp')
-rw-r--r-- | src/widgets/dropdown.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index bed6895ed..2e937c8b4 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -220,7 +220,7 @@ void ShowDropDownList(Window *w, DropDownList *list, int selected, int button) const Widget *wi = &w->widget[button]; /* The preferred position is just below the dropdown calling widget */ - int top = w->top + wi->bottom + 2; + int top = w->top + wi->bottom + 1; int height = list->size() * 10 + 4; /* Check if the status bar is visible, as we don't want to draw over it */ @@ -235,8 +235,8 @@ void ShowDropDownList(Window *w, DropDownList *list, int selected, int button) int screen_top = w3 == NULL ? 0 : w3->top + w3->height; /* If not, check if it will fit above the widget */ - if (w->top + wi->top - height - 1 > screen_top) { - top = w->top + wi->top - height - 1; + if (w->top + wi->top - height > screen_top) { + top = w->top + wi->top - height; } else { /* ... and lastly if it won't, enable the scroll bar and fit the * list in below the widget */ @@ -246,17 +246,21 @@ void ShowDropDownList(Window *w, DropDownList *list, int selected, int button) } } + /* XXX Temporary fix to make dropdown compatible with separate widgets */ + const Widget *wil = wi; + if (wi->type != WWT_DROPDOWN && wi->type != WWT_DROPDOWNIN) wil--; + Window *dw = AllocateWindow( - w->left + wi[-1].left + 1, + w->left + wil->left, top, - wi->right - wi[-1].left + 1, + wi->right - wil->left + 1, height, DropDownMenuWndProc, WC_DROPDOWN_MENU, _dropdown_menu_widgets); dw->widget[0].color = wi->color; - dw->widget[0].right = wi->right - wi[-1].left; + dw->widget[0].right = wi->right - wil->left; dw->widget[0].bottom = height - 1; dw->SetWidgetHiddenState(1, !scroll); |