mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-06 22:37:22 +00:00
(svn r11901) -Add: add two widgets for dropdowns, one raised and one inset, to eventually replace use of two widgets for each dropdown control.
This commit is contained in:
parent
c74cf439fa
commit
c313676c66
@ -472,6 +472,28 @@ void DrawWindowWidgets(const Window *w)
|
|||||||
DrawStringCenteredTruncated(r.left + 2, r.right - 2, r.top + 2, wi->data, 0x84);
|
DrawStringCenteredTruncated(r.left + 2, r.right - 2, r.top + 2, wi->data, 0x84);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case WWT_DROPDOWN: {
|
||||||
|
assert(r.bottom - r.top == 11); // ensure consistent size
|
||||||
|
|
||||||
|
StringID str = wi->data;
|
||||||
|
DrawFrameRect(r.left, r.top, r.right - 12, r.bottom, wi->color, FR_NONE);
|
||||||
|
DrawFrameRect(r.right - 11, r.top, r.right, r.bottom, wi->color, clicked ? FR_LOWERED : FR_NONE);
|
||||||
|
DrawString(r.right - (clicked ? 8 : 9), r.top + (clicked ? 2 : 1), STR_0225, TC_BLACK);
|
||||||
|
if (str != STR_NULL) DrawStringTruncated(r.left + 2, r.top + 1, str, TC_BLACK, r.right - r.left - 12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case WWT_DROPDOWNIN: {
|
||||||
|
assert(r.bottom - r.top == 11); // ensure consistent size
|
||||||
|
|
||||||
|
StringID str = wi->data;
|
||||||
|
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, FR_LOWERED | FR_DARKENED);
|
||||||
|
DrawFrameRect(r.right - 11, r.top + 1, r.right - 1, r.bottom - 1, wi->color, clicked ? FR_LOWERED : FR_NONE);
|
||||||
|
DrawString(r.right - (clicked ? 8 : 9), r.top + (clicked ? 2 : 1), STR_0225, TC_BLACK);
|
||||||
|
if (str != STR_NULL) DrawStringTruncated(r.left + 2, r.top + 2, str, TC_BLACK, r.right - r.left - 12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (w->IsWidgetDisabled(i)) {
|
if (w->IsWidgetDisabled(i)) {
|
||||||
|
@ -220,7 +220,7 @@ void ShowDropDownList(Window *w, DropDownList *list, int selected, int button)
|
|||||||
const Widget *wi = &w->widget[button];
|
const Widget *wi = &w->widget[button];
|
||||||
|
|
||||||
/* The preferred position is just below the dropdown calling widget */
|
/* 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;
|
int height = list->size() * 10 + 4;
|
||||||
|
|
||||||
/* Check if the status bar is visible, as we don't want to draw over it */
|
/* 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;
|
int screen_top = w3 == NULL ? 0 : w3->top + w3->height;
|
||||||
|
|
||||||
/* If not, check if it will fit above the widget */
|
/* If not, check if it will fit above the widget */
|
||||||
if (w->top + wi->top - height - 1 > screen_top) {
|
if (w->top + wi->top - height > screen_top) {
|
||||||
top = w->top + wi->top - height - 1;
|
top = w->top + wi->top - height;
|
||||||
} else {
|
} else {
|
||||||
/* ... and lastly if it won't, enable the scroll bar and fit the
|
/* ... and lastly if it won't, enable the scroll bar and fit the
|
||||||
* list in below the widget */
|
* 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(
|
Window *dw = AllocateWindow(
|
||||||
w->left + wi[-1].left + 1,
|
w->left + wil->left,
|
||||||
top,
|
top,
|
||||||
wi->right - wi[-1].left + 1,
|
wi->right - wil->left + 1,
|
||||||
height,
|
height,
|
||||||
DropDownMenuWndProc,
|
DropDownMenuWndProc,
|
||||||
WC_DROPDOWN_MENU,
|
WC_DROPDOWN_MENU,
|
||||||
_dropdown_menu_widgets);
|
_dropdown_menu_widgets);
|
||||||
|
|
||||||
dw->widget[0].color = wi->color;
|
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->widget[0].bottom = height - 1;
|
||||||
|
|
||||||
dw->SetWidgetHiddenState(1, !scroll);
|
dw->SetWidgetHiddenState(1, !scroll);
|
||||||
|
@ -492,6 +492,8 @@ enum WindowWidgetTypes {
|
|||||||
WWT_SCROLL2BAR, ///< 2nd vertical scrollbar
|
WWT_SCROLL2BAR, ///< 2nd vertical scrollbar
|
||||||
WWT_RESIZEBOX,
|
WWT_RESIZEBOX,
|
||||||
WWT_CLOSEBOX,
|
WWT_CLOSEBOX,
|
||||||
|
WWT_DROPDOWN, ///< Raised drop down list (regular)
|
||||||
|
WWT_DROPDOWNIN, ///< Inset drop down list (used on game options only)
|
||||||
WWT_LAST, ///< Last Item. use WIDGETS_END to fill up padding!!
|
WWT_LAST, ///< Last Item. use WIDGETS_END to fill up padding!!
|
||||||
|
|
||||||
WWT_MASK = 0x1F,
|
WWT_MASK = 0x1F,
|
||||||
|
Loading…
Reference in New Issue
Block a user