Fixed compilatin, reverted several of my changes
Conflicts: src/gfx.cpp src/widget.cpp src/widget_type.h src/window.cpp src/window_func.h
This commit is contained in:
@@ -362,14 +362,6 @@ void ShowDropDownListAt(Window *w, const DropDownList *list, int selected, int b
|
||||
/* Longest item in the list, if auto_width is enabled */
|
||||
uint max_item_width = 0;
|
||||
|
||||
if (auto_width) {
|
||||
/* Find the longest item in the list */
|
||||
for (const DropDownListItem * const *it = list->Begin(); it != list->End(); ++it) {
|
||||
const DropDownListItem *item = *it;
|
||||
max_item_width = max(max_item_width, item->Width() + 5);
|
||||
}
|
||||
}
|
||||
|
||||
/* Total length of list */
|
||||
int height = 0;
|
||||
|
||||
@@ -383,14 +375,11 @@ void ShowDropDownListAt(Window *w, const DropDownList *list, int selected, int b
|
||||
int screen_bottom = GetMainViewBottom();
|
||||
bool scroll = false;
|
||||
|
||||
enum { DISPLAY_BORDER = 20, TOP_BORDER = 4 };
|
||||
|
||||
/* Check if the dropdown will fully fit below the widget. */
|
||||
if (top + height + DISPLAY_BORDER >= screen_bottom) {
|
||||
/* If not, check if it will fit above the widget. */
|
||||
int screen_top = GetMainViewTop();
|
||||
if (w->top + wi_rect.top - TOP_BORDER > screen_top + height) {
|
||||
top = w->top + wi_rect.top - height - TOP_BORDER;
|
||||
/* Check if the dropdown will fully fit below the widget */
|
||||
if (top + height + 4 >= screen_bottom) {
|
||||
/* If not, check if it will fit above the widget */
|
||||
if (w->top + wi_rect.top - height > GetMainViewTop()) {
|
||||
top = w->top + wi_rect.top - height - 4;
|
||||
} else {
|
||||
/* ... and lastly if it won't, enable the scroll bar and fit the
|
||||
* list in below the widget */
|
||||
@@ -398,30 +387,9 @@ void ShowDropDownListAt(Window *w, const DropDownList *list, int selected, int b
|
||||
int rows = (screen_bottom - 4 - top) / avg_height;
|
||||
height = rows * avg_height;
|
||||
scroll = true;
|
||||
|
||||
/* ... and choose whether to put the list above or below the widget. */
|
||||
bool put_above = false;
|
||||
int available_height = screen_bottom - w->top - wi_rect.bottom;
|
||||
if (w->top + wi_rect.top - screen_top > available_height) {
|
||||
// Put it above.
|
||||
available_height = w->top + wi_rect.top - screen_top - DISPLAY_BORDER - TOP_BORDER;
|
||||
put_above = true;
|
||||
}
|
||||
|
||||
/* Check at least there is space for one item. */
|
||||
assert(available_height >= avg_height);
|
||||
|
||||
/* And lastly, fit the list,... */
|
||||
int rows = available_height / avg_height;
|
||||
height = rows * avg_height;
|
||||
|
||||
/* ... add space for the scrollbar,... */
|
||||
/* Add space for the scroll bar if we automatically determined
|
||||
* the width of the list. */
|
||||
max_item_width += NWidgetScrollbar::GetVerticalDimension().width;
|
||||
|
||||
/* ... and set the top position if needed. */
|
||||
if (put_above) {
|
||||
top = w->top + wi_rect.top - height - TOP_BORDER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user