diff options
author | Ton Roosendaal <ton@blender.org> | 2009-06-02 22:10:06 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2009-06-02 22:10:06 +0400 |
commit | ca24322413e78b60ece51902da1b8a9ac22d13ba (patch) | |
tree | f9111a453452e478a941fa4f35344bc4f382020b /source/blender/editors/space_info | |
parent | 67494dcad3330b1c056cef4b9aa21030c856cf5d (diff) |
2.5
Part one of new text button type: SEARCH_MENU
This opens a popup showing all matches for a typed string, nice
for object names, materials, operators, and so on.
Warning: Currently menu doesn't function yet! Only draws choices.
As test I've added an operator search button in top bar. It only
shows operators that can be used in this context now. Also that
is part of the WIP, tomorrow more fun :)
Diffstat (limited to 'source/blender/editors/space_info')
-rw-r--r-- | source/blender/editors/space_info/info_header.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/source/blender/editors/space_info/info_header.c b/source/blender/editors/space_info/info_header.c index fd5d851b0c2..38e778848b9 100644 --- a/source/blender/editors/space_info/info_header.c +++ b/source/blender/editors/space_info/info_header.c @@ -387,6 +387,32 @@ static void scene_idpoin_handle(bContext *C, ID *id, int event) } } +static void operator_search_cb(const struct bContext *C, void *arg, char *str, uiSearchItems *items) +{ + wmOperatorType *ot = WM_operatortype_first(); + + for(; ot; ot= ot->next) { + + if(BLI_strcasestr(ot->name, str)) { + if(ot->poll==NULL || ot->poll((bContext *)C)) { + int len= strlen(ot->name); + + BLI_strncpy(items->names[items->totitem], ot->name, items->maxstrlen); + + /* check for hotkey */ + if(len < items->maxstrlen-6) { + if(WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, items->names[items->totitem]+len+1, items->maxstrlen-len-1)) { + items->names[items->totitem][len]= '|'; + } + } + + items->totitem++; + if(items->totitem>=items->maxitem) + break; + } + } + } +} void info_header_buttons(const bContext *C, ARegion *ar) { @@ -453,6 +479,16 @@ void info_header_buttons(const bContext *C, ARegion *ar) xco+= 90; } + { + static char search[256]= ""; + uiBut *but= uiDefSearchBut(block, search, 0, ICON_PROP_ON, 256, xco+5, yco, 120, 19, ""); + + uiButSetSearchFunc(but, operator_search_cb, NULL); + + xco+= 125; + } + + /* always as last */ UI_view2d_totRect_set(&ar->v2d, xco+XIC+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin); |