diff options
author | Ton Roosendaal <ton@blender.org> | 2010-11-29 18:25:06 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2010-11-29 18:25:06 +0300 |
commit | 1c0d7d6815dce04bd9ba48444eb93b5ad63b65b5 (patch) | |
tree | cb5e64f84744d1a2d8161ade41cfec3003acfbc1 /source | |
parent | 8272ec2302848f28bc8fdcb2e043420902dfdd56 (diff) |
For all buttons with search-menu option, the button will show a
red-alert drawing when input doesn't exist. Will help debugging
when messing with uv-layer names, vertex groups, etc.
Also closes bugreport #24905
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/interface/interface.c | 8 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_regions.c | 35 |
3 files changed, 41 insertions, 3 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 62225adda3e..061bff7187f 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -3394,6 +3394,7 @@ uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxle return but; } + /* arg is user value, searchfunc and handlefunc both get it as arg */ /* if active set, button opens with this item visible and selected */ void uiButSetSearchFunc(uiBut *but, uiButSearchFunc sfunc, void *arg, uiButHandleFunc bfunc, void *active) @@ -3402,6 +3403,13 @@ void uiButSetSearchFunc(uiBut *but, uiButSearchFunc sfunc, void *arg, uiButHandl but->search_arg= arg; uiButSetFunc(but, bfunc, arg, active); + + /* search buttons show red-alert if item doesn't exist, not for menus */ + if(0==(but->block->flag & UI_BLOCK_LOOP)) { + /* skip empty buttons, not all buttons need input, we only show invalid */ + if(but->drawstr[0]) + ui_but_search_test(but); + } } /* Program Init/Exit */ diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 001bd4b9157..34eb78a40d8 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -421,6 +421,7 @@ void ui_searchbox_autocomplete(struct bContext *C, struct ARegion *ar, uiBut *bu void ui_searchbox_event(struct bContext *C, struct ARegion *ar, uiBut *but, struct wmEvent *event); void ui_searchbox_apply(uiBut *but, struct ARegion *ar); void ui_searchbox_free(struct bContext *C, struct ARegion *ar); +void ui_but_search_test(uiBut *but); typedef uiBlock* (*uiBlockHandleCreateFunc)(struct bContext *C, struct uiPopupBlockHandle *handle, void *arg1); diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index d67d63423f2..0747d772cdf 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -611,9 +611,12 @@ int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin, int icon return 1; } - BLI_strncpy(items->names[items->totitem], name, items->maxstrlen); - items->pointers[items->totitem]= poin; - items->icons[items->totitem]= iconid; + if(items->names) + BLI_strncpy(items->names[items->totitem], name, items->maxstrlen); + if(items->pointers) + items->pointers[items->totitem]= poin; + if(items->icons) + items->icons[items->totitem]= iconid; items->totitem++; @@ -1077,6 +1080,32 @@ void ui_searchbox_free(bContext *C, ARegion *ar) ui_remove_temporary_region(C, CTX_wm_screen(C), ar); } +/* sets red alert if button holds a string it can't find */ +void ui_but_search_test(uiBut *but) +{ + uiSearchItems *items= MEM_callocN(sizeof(uiSearchItems), "search items"); + char *strp[2], str[256]; + + items->maxitem= 1; + items->maxstrlen= 256; + strp[0]= str; + items->names= strp; + + /* changed flag makes search only find name */ + but->changed= TRUE; + but->search_func(but->block->evil_C, but->search_arg, but->drawstr, items); + but->changed= 0; + + if(items->totitem==0) + uiButSetFlag(but, UI_BUT_REDALERT); + else if(items->totitem==1) { + if(strcmp(but->drawstr, str)!=0) + uiButSetFlag(but, UI_BUT_REDALERT); + } + + MEM_freeN(items); +} + /************************* Creating Menu Blocks **********************/ |