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
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2009-06-03 22:31:37 +0400
committerTon Roosendaal <ton@blender.org>2009-06-03 22:31:37 +0400
commit7c3c9df2c07f739448e804d2ed9fc3d596f5022a (patch)
tree85f0115de74f64caa11300703744a0a4796cfbda /source/blender/windowmanager
parent9b869755867bc47cf48ad2622503a57832745fbf (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/windowmanager')
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c89
-rw-r--r--source/blender/windowmanager/wm_event_types.h1
2 files changed, 90 insertions, 0 deletions
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index a76a9ea94bf..b020e4c24a8 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -373,6 +373,93 @@ static void WM_OT_debug_menu(wmOperatorType *ot)
RNA_def_int(ot->srna, "debugval", 0, -10000, 10000, "Debug Value", "", INT_MIN, INT_MAX);
}
+/* ***************** Search menu ************************* */
+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();
+
+ for(; ot; ot= ot->next) {
+
+ if(BLI_strcasestr(ot->name, str)) {
+ if(ot->poll==NULL || ot->poll((bContext *)C)) {
+ char name[256];
+ int len= strlen(ot->name);
+
+ /* display name for menu, can hold hotkey */
+ BLI_strncpy(name, ot->name, 256);
+
+ /* check for hotkey */
+ 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]= '|';
+ }
+
+ if(0==uiSearchItemAdd(items, name, ot))
+ break;
+ }
+ }
+ }
+}
+
+static uiBlock *wm_block_search_menu(bContext *C, ARegion *ar, void *arg_op)
+{
+ static char search[256]= "";
+ wmEvent event;
+ wmWindow *win= CTX_wm_window(C);
+ uiBlock *block;
+ uiBut *but;
+
+ block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
+ uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_RET_1);
+
+ but= uiDefSearchBut(block, search, 0, ICON_PROP_ON, 256, 10, 10, 180, 19, "");
+ uiButSetSearchFunc(but, operator_search_cb, NULL, operator_call_cb);
+
+ uiPopupBoundsBlock(block, 0.0f, 0, -20); /* move it downwards, mouse over button */
+ uiEndBlock(C, block);
+
+ event= *(win->eventstate); /* XXX huh huh? make api call */
+ event.type= EVT_BUT_OPEN;
+ event.val= KM_PRESS;
+ event.customdata= but;
+ event.customdatafree= FALSE;
+ wm_event_add(win, &event);
+
+ return block;
+}
+
+static int wm_search_menu_exec(bContext *C, wmOperator *op)
+{
+
+ return OPERATOR_FINISHED;
+}
+
+static int wm_search_menu_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+
+ uiPupBlock(C, wm_block_search_menu, op);
+
+ return OPERATOR_CANCELLED;
+}
+
+static void WM_OT_search_menu(wmOperatorType *ot)
+{
+ ot->name= "Search Menu";
+ ot->idname= "WM_OT_search_menu";
+
+ ot->invoke= wm_search_menu_invoke;
+ ot->exec= wm_search_menu_exec;
+ ot->poll= WM_operator_winactive;
+}
+
/* ************ window / screen operator definitions ************** */
@@ -1437,6 +1524,7 @@ void wm_operatortype_init(void)
WM_operatortype_append(WM_OT_save_mainfile);
WM_operatortype_append(WM_OT_ten_timer);
WM_operatortype_append(WM_OT_debug_menu);
+ WM_operatortype_append(WM_OT_search_menu);
}
/* default keymap for windows and screens, only call once per WM */
@@ -1461,6 +1549,7 @@ void wm_window_keymap(wmWindowManager *wm)
/* debug/testing */
WM_keymap_verify_item(keymap, "WM_OT_ten_timer", TKEY, KM_PRESS, KM_ALT|KM_CTRL, 0);
WM_keymap_verify_item(keymap, "WM_OT_debug_menu", DKEY, KM_PRESS, KM_ALT|KM_CTRL, 0);
+ WM_keymap_verify_item(keymap, "WM_OT_search_menu", FKEY, KM_PRESS, KM_ALT|KM_CTRL, 0);
}
diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h
index 4de7f645bfa..39c267b132c 100644
--- a/source/blender/windowmanager/wm_event_types.h
+++ b/source/blender/windowmanager/wm_event_types.h
@@ -238,6 +238,7 @@
#define EVT_FILESELECT_EXEC 3
#define EVT_FILESELECT_CANCEL 4
+#define EVT_BUT_OPEN 0x5021
#endif /* WM_EVENT_TYPES_H */