diff options
Diffstat (limited to 'source/blender/editors/interface')
5 files changed, 52 insertions, 7 deletions
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 3b40bd7c29a..379c11a6f31 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -420,7 +420,7 @@ extern void ui_draw_but(const struct bContext *C, ARegion *ar, struct uiStyle *s struct ThemeUI; void ui_widget_color_init(struct ThemeUI *tui); -void ui_draw_menu_item(struct uiFontStyle *fstyle, rcti *rect, char *name, int state); +void ui_draw_menu_item(struct uiFontStyle *fstyle, rcti *rect, char *name, int iconid, int state); /* interface_style.c */ void uiStyleInit(void); diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index f7a0e97d05d..a1dae39d687 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -40,6 +40,7 @@ #include "BLI_dynstr.h" #include "BKE_context.h" +#include "BKE_icons.h" #include "BKE_report.h" #include "BKE_screen.h" #include "BKE_texture.h" @@ -433,7 +434,7 @@ struct uiSearchItems { char **names; void **pointers; - + int *icons; }; typedef struct uiSearchboxData { @@ -448,7 +449,7 @@ typedef struct uiSearchboxData { /* exported for use by search callbacks */ /* returns zero if nothing to add */ -int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin) +int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin, int iconid) { if(items->totitem>=items->maxitem) { @@ -464,6 +465,7 @@ int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin) BLI_strncpy(items->names[items->totitem], name, items->maxstrlen); items->pointers[items->totitem]= poin; + items->icons[items->totitem]= iconid; items->totitem++; @@ -639,7 +641,8 @@ static void ui_searchbox_region_draw(const bContext *C, ARegion *ar) for(a=0; a<data->items.totitem; a++) { ui_searchbox_butrect(&rect, data, a); - ui_draw_menu_item(&data->fstyle, &rect, data->items.names[a], (a+1)==data->active?UI_ACTIVE:0); + /* widget itself */ + ui_draw_menu_item(&data->fstyle, &rect, data->items.names[a], data->items.icons[a], (a+1)==data->active?UI_ACTIVE:0); } /* indicate more */ @@ -666,6 +669,7 @@ static void ui_searchbox_region_free(ARegion *ar) MEM_freeN(data->items.names[a]); MEM_freeN(data->items.names); MEM_freeN(data->items.pointers); + MEM_freeN(data->items.icons); MEM_freeN(data); ar->regiondata= NULL; @@ -794,6 +798,7 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) data->items.totitem= 0; data->items.names= MEM_callocN(SEARCH_ITEMS*sizeof(void *), "search names"); data->items.pointers= MEM_callocN(SEARCH_ITEMS*sizeof(void *), "search pointers"); + data->items.icons= MEM_callocN(SEARCH_ITEMS*sizeof(int), "search icons"); for(x1=0; x1<SEARCH_ITEMS; x1++) data->items.names[x1]= MEM_callocN(but->hardmax+1, "search pointers"); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index facc0bb6537..3856a0577fa 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -146,9 +146,24 @@ static void id_search_cb(const struct bContext *C, void *arg_litem, char *str, u ID *id; for(id= lb->first; id; id= id->next) { + int iconid= 0; + + /* icon */ + switch(GS(id->name)) + { + case ID_MA: /* fall through */ + case ID_TE: /* fall through */ + case ID_IM: /* fall through */ + case ID_WO: /* fall through */ + case ID_LA: /* fall through */ + iconid= BKE_icon_getid(id); + break; + default: + break; + } if(BLI_strcasestr(id->name+2, str)) { - if(0==uiSearchItemAdd(items, id->name+2, id)) + if(0==uiSearchItemAdd(items, id->name+2, id, iconid)) break; } } diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index dff8e13aad5..69104c87e64 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -43,6 +43,7 @@ #include "BKE_colortools.h" #include "BKE_context.h" #include "BKE_idprop.h" +#include "BKE_icons.h" #include "BKE_library.h" #include "BKE_main.h" #include "BKE_texture.h" @@ -306,9 +307,25 @@ static void id_search_cb(const struct bContext *C, void *arg_params, char *str, ID *id; for(id= params->lb->first; id; id= id->next) { + int iconid= 0; + + + /* icon */ + switch(GS(id->name)) + { + case ID_MA: /* fall through */ + case ID_TE: /* fall through */ + case ID_IM: /* fall through */ + case ID_WO: /* fall through */ + case ID_LA: /* fall through */ + iconid= BKE_icon_getid(id); + break; + default: + break; + } if(BLI_strcasestr(id->name+2, str)) { - if(0==uiSearchItemAdd(items, id->name+2, id)) + if(0==uiSearchItemAdd(items, id->name+2, id, iconid)) break; } } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index fa3abd8a3ad..735cfe742c6 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -2356,7 +2356,7 @@ void ui_draw_search_back(uiStyle *style, uiBlock *block, rcti *rect) /* helper call to draw a menu item without button */ /* state: UI_ACTIVE or 0 */ -void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, char *name, int state) +void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, char *name, int iconid, int state) { uiWidgetType *wt= widget_type(UI_WTYPE_MENU_ITEM); rcti _rect= *rect; @@ -2370,6 +2370,7 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, char *name, int state) /* text location offset */ rect->xmin+=5; + if(iconid) rect->xmin+= ICON_HEIGHT; /* cut string in 2 parts? */ cpoin= strchr(name, '|'); @@ -2392,5 +2393,12 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, char *name, int state) /* restore rect, was messed with */ *rect= _rect; + if(iconid) { + int xs= rect->xmin+4; + int ys= 1 + (rect->ymin+rect->ymax- ICON_HEIGHT)/2; + glEnable(GL_BLEND); + UI_icon_draw_aspect_blended(xs, ys, iconid, 1.2f, 0); /* XXX scale weak get from fstyle? */ + glDisable(GL_BLEND); + } } |