Commit: a2027c6587d62fcbd1ac372a0a92a2ec91ef8659
Author: Campbell Barton
Date:   Tue Jun 12 08:14:13 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBa2027c6587d62fcbd1ac372a0a92a2ec91ef8659

UI: replace ui_draw_search_back w/ general code

Useful for drawing any kind of region-background.

===================================================================

M       source/blender/editors/interface/interface_intern.h
M       source/blender/editors/interface/interface_region_search.c
M       source/blender/editors/interface/interface_widgets.c

===================================================================

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)

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to