Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-06-12 09:14:13 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-06-12 09:14:13 +0300
commita2027c6587d62fcbd1ac372a0a92a2ec91ef8659 (patch)
tree1ecf4fe0850d36db95f4576cf54a4a26a7c4a408 /source/blender/editors
parent35da1afa09d98f1051391da53d17d81a586fe518 (diff)
UI: replace ui_draw_search_back w/ general code
Useful for drawing any kind of region-background.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/interface/interface_intern.h3
-rw-r--r--source/blender/editors/interface/interface_region_search.c10
-rw-r--r--source/blender/editors/interface/interface_widgets.c34
3 files changed, 26 insertions, 21 deletions
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 74ca7978b65..90a7ae954a4 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -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 */
diff --git a/source/blender/editors/interface/interface_region_search.c b/source/blender/editors/interface/interface_region_search.c
index aa4b731a3d5..e0dc149be17 100644
--- a/source/blender/editors/interface/interface_region_search.c
+++ b/source/blender/editors/interface/interface_region_search.c
@@ -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) {
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index ac8d900f560..fa099003010 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -4916,30 +4916,32 @@ uiWidgetColors *ui_tooltip_get_theme(void)
return wt->wcol_theme;
}
-void ui_draw_tooltip_background(uiStyle *UNUSED(style), uiBlock *UNUSED(block), rcti *rect)
+/**
+ * Generic drawing for background.
+ */
+void ui_draw_widget_back(uiWidgetTypeEnum type, bool use_shadow, const rcti *rect)
{
- uiWidgetType *wt = widget_type(UI_WTYPE_TOOLTIP);
+ 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 ends up using same function to draw the tooltip as menu_back */
- wt->draw(&wt->wcol, rect, 0, 0);
+ wt->draw(&wt->wcol, &rect_copy, 0, UI_CNR_ALL);
}
-void ui_draw_search_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect)
+void ui_draw_tooltip_background(uiStyle *UNUSED(style), uiBlock *UNUSED(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);
-
+ uiWidgetType *wt = widget_type(UI_WTYPE_TOOLTIP);
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);
+ /* wt->draw ends up using same function to draw the tooltip as menu_back */
+ wt->draw(&wt->wcol, rect, 0, 0);
}
-
/* 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)