diff options
author | Ton Roosendaal <ton@blender.org> | 2009-06-03 22:31:37 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2009-06-03 22:31:37 +0400 |
commit | 7c3c9df2c07f739448e804d2ed9fc3d596f5022a (patch) | |
tree | 85f0115de74f64caa11300703744a0a4796cfbda /source/blender/editors/space_info | |
parent | 9b869755867bc47cf48ad2622503a57832745fbf (diff) |
2.5
Further work on new "text search" button.
- Now allows to browse items (mouse, arrow key)
- Assigns active value
- Uses different backdrop to distinguish from popup menus
- Cleaned API for it, so it can be used nicely generic
Also added a search menu, which shows all currently working
operators: CTRL+ALT+F. (mind the looks, it needs some tweaks!)
To make a menu activating a button I've added a new event...
could use some tweaks.
Important note: the callback to pass on "old string" for text
button (bone rename) couldn't work yet, added first code for new
callback, but has to be worked on further. When bone rename gets
added it can be tested.
Diffstat (limited to 'source/blender/editors/space_info')
-rw-r--r-- | source/blender/editors/space_info/info_header.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/source/blender/editors/space_info/info_header.c b/source/blender/editors/space_info/info_header.c index 38e778848b9..09f5640dbf6 100644 --- a/source/blender/editors/space_info/info_header.c +++ b/source/blender/editors/space_info/info_header.c @@ -387,6 +387,14 @@ static void scene_idpoin_handle(bContext *C, ID *id, int event) } } +static void operator_call_cb(struct bContext *C, void *arg1, void *arg2) +{ + wmOperatorType *ot= arg2; + + if(ot) + WM_operator_name_call(C, ot->idname, WM_OP_INVOKE_DEFAULT, NULL); +} + static void operator_search_cb(const struct bContext *C, void *arg, char *str, uiSearchItems *items) { wmOperatorType *ot = WM_operatortype_first(); @@ -395,19 +403,19 @@ static void operator_search_cb(const struct bContext *C, void *arg, char *str, u if(BLI_strcasestr(ot->name, str)) { if(ot->poll==NULL || ot->poll((bContext *)C)) { + char name[256]; int len= strlen(ot->name); - BLI_strncpy(items->names[items->totitem], ot->name, items->maxstrlen); + /* display name for menu, can hold hotkey */ + BLI_strncpy(name, ot->name, 256); /* 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]= '|'; - } + if(len < 256-6) { + if(WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, &name[len+1], 256-len-1)) + name[len]= '|'; } - items->totitem++; - if(items->totitem>=items->maxitem) + if(0==uiSearchItemAdd(items, name, ot)) break; } } @@ -483,7 +491,7 @@ void info_header_buttons(const bContext *C, ARegion *ar) 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); + uiButSetSearchFunc(but, operator_search_cb, NULL, operator_call_cb); xco+= 125; } |