UI: replace ui_draw_search_back w/ general code
Useful for drawing any kind of region-background.
This commit is contained in:
parent
35da1afa09
commit
a2027c6587
|
@ -757,8 +757,9 @@ void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect);
|
|||
void ui_draw_popover_back(ARegion *ar, struct uiStyle *style, uiBlock *block, rcti *rect);
|
||||
void ui_draw_pie_center(uiBlock *block);
|
||||
uiWidgetColors *ui_tooltip_get_theme(void);
|
||||
|
||||
void ui_draw_widget_back(uiWidgetTypeEnum type, bool use_shadow, const rcti *rect);
|
||||
void ui_draw_tooltip_background(uiStyle *UNUSED(style), uiBlock *block, rcti *rect);
|
||||
void ui_draw_search_back(struct uiStyle *style, uiBlock *block, rcti *rect);
|
||||
|
||||
extern void ui_draw_but(const struct bContext *C, ARegion *ar, struct uiStyle *style, uiBut *but, rcti *rect);
|
||||
/* theme color init */
|
||||
|
|
|
@ -404,8 +404,9 @@ static void ui_searchbox_region_draw_cb(const bContext *C, ARegion *ar)
|
|||
/* pixel space */
|
||||
wmOrtho2_region_pixelspace(ar);
|
||||
|
||||
if (data->noback == false)
|
||||
ui_draw_search_back(NULL, NULL, &data->bbox); /* style not used yet */
|
||||
if (data->noback == false) {
|
||||
ui_draw_widget_back(UI_WTYPE_BOX, true, &data->bbox);
|
||||
}
|
||||
|
||||
/* draw text */
|
||||
if (data->items.totitem) {
|
||||
|
@ -681,8 +682,9 @@ static void ui_searchbox_region_draw_cb__operator(const bContext *UNUSED(C), ARe
|
|||
/* pixel space */
|
||||
wmOrtho2_region_pixelspace(ar);
|
||||
|
||||
if (data->noback == false)
|
||||
ui_draw_search_back(NULL, NULL, &data->bbox); /* style not used yet */
|
||||
if (data->noback == false) {
|
||||
ui_draw_widget_back(UI_WTYPE_BOX, true, &data->bbox);
|
||||
}
|
||||
|
||||
/* draw text */
|
||||
if (data->items.totitem) {
|
||||
|
|
|
@ -4916,6 +4916,24 @@ uiWidgetColors *ui_tooltip_get_theme(void)
|
|||
return wt->wcol_theme;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic drawing for background.
|
||||
*/
|
||||
void ui_draw_widget_back(uiWidgetTypeEnum type, bool use_shadow, const rcti *rect)
|
||||
{
|
||||
uiWidgetType *wt = widget_type(type);
|
||||
|
||||
if (use_shadow) {
|
||||
glEnable(GL_BLEND);
|
||||
widget_softshadow(rect, UI_CNR_ALL, 0.25f * U.widget_unit);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
rcti rect_copy = *rect;
|
||||
wt->state(wt, 0);
|
||||
wt->draw(&wt->wcol, &rect_copy, 0, UI_CNR_ALL);
|
||||
}
|
||||
|
||||
void ui_draw_tooltip_background(uiStyle *UNUSED(style), uiBlock *UNUSED(block), rcti *rect)
|
||||
{
|
||||
uiWidgetType *wt = widget_type(UI_WTYPE_TOOLTIP);
|
||||
|
@ -4924,22 +4942,6 @@ void ui_draw_tooltip_background(uiStyle *UNUSED(style), uiBlock *UNUSED(block),
|
|||
wt->draw(&wt->wcol, rect, 0, 0);
|
||||
}
|
||||
|
||||
void ui_draw_search_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect)
|
||||
{
|
||||
uiWidgetType *wt = widget_type(UI_WTYPE_BOX);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
widget_softshadow(rect, UI_CNR_ALL, 0.25f * U.widget_unit);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
wt->state(wt, 0);
|
||||
if (block)
|
||||
wt->draw(&wt->wcol, rect, block->flag, UI_CNR_ALL);
|
||||
else
|
||||
wt->draw(&wt->wcol, rect, 0, UI_CNR_ALL);
|
||||
}
|
||||
|
||||
|
||||
/* helper call to draw a menu item without button */
|
||||
/* state: UI_ACTIVE or 0 */
|
||||
void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state, bool use_sep)
|
||||
|
|
Loading…
Reference in New Issue