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
path: root/source
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2009-06-24 20:44:54 +0400
committerTon Roosendaal <ton@blender.org>2009-06-24 20:44:54 +0400
commit627abe0acf2b52d06fc26e93462f5261cf508879 (patch)
tree75570a4492b4e35aebdab06a633da73bf016ecb2 /source
parent5b26f520bb50f17b0a2193daf9b8b10616c4707b (diff)
2.5
Added support for icons in search menu. It already displays icons for saved materials etc. from old files. Have to add previewrenders for this still.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/include/UI_interface.h2
-rw-r--r--source/blender/editors/interface/interface_intern.h2
-rw-r--r--source/blender/editors/interface/interface_regions.c11
-rw-r--r--source/blender/editors/interface/interface_templates.c17
-rw-r--r--source/blender/editors/interface/interface_utils.c19
-rw-r--r--source/blender/editors/interface/interface_widgets.c10
-rw-r--r--source/blender/editors/space_info/info_header.c2
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c2
8 files changed, 55 insertions, 10 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 86516f9c973..2f054f7a08a 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -454,7 +454,7 @@ typedef void (*uiButSearchFunc)(const struct bContext *C, void *arg, char *str,
typedef void (*uiBlockHandleFunc)(struct bContext *C, void *arg, int event);
/* use inside searchfunc to add items */
-int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin);
+int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin, int iconid);
/* bfunc gets search item *poin as arg2, or if NULL the old string */
void uiButSetSearchFunc (uiBut *but, uiButSearchFunc sfunc, void *arg1, uiButHandleFunc bfunc);
/* height in pixels, it's using hardcoded values still */
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);
+ }
}
diff --git a/source/blender/editors/space_info/info_header.c b/source/blender/editors/space_info/info_header.c
index c8dd3df8425..7b65a70117c 100644
--- a/source/blender/editors/space_info/info_header.c
+++ b/source/blender/editors/space_info/info_header.c
@@ -415,7 +415,7 @@ static void operator_search_cb(const struct bContext *C, void *arg, char *str, u
name[len]= '|';
}
- if(0==uiSearchItemAdd(items, name, ot))
+ if(0==uiSearchItemAdd(items, name, ot, 0))
break;
}
}
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 33f4ff11679..76a7b18fa12 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -402,7 +402,7 @@ static void operator_search_cb(const struct bContext *C, void *arg, char *str, u
name[len]= '|';
}
- if(0==uiSearchItemAdd(items, name, ot))
+ if(0==uiSearchItemAdd(items, name, ot, 0))
break;
}
}