[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26269] trunk/blender/source/blender: Fix [#20798] - Add/change/remove shortcut options dissapearing from buttons @ Tool Shelf
Matt Ebb
matt at mke3.net
Tue Jan 26 02:02:10 CET 2010
Revision: 26269
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26269
Author: broken
Date: 2010-01-26 02:02:10 +0100 (Tue, 26 Jan 2010)
Log Message:
-----------
Fix [#20798] - Add/change/remove shortcut options dissapearing from buttons @ Tool Shelf
Made the RMB menus for manipulating shortcuts a bit more robust (only dealing with mouse
clicks/key events, rather than all tweaks/timers/etc) and added ability to add key shortcuts for
transform tools from the RMB menu.
Modified Paths:
--------------
trunk/blender/source/blender/editors/interface/interface_handlers.c
trunk/blender/source/blender/windowmanager/WM_api.h
trunk/blender/source/blender/windowmanager/intern/wm_keymap.c
Modified: trunk/blender/source/blender/editors/interface/interface_handlers.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_handlers.c 2010-01-26 00:59:53 UTC (rev 26268)
+++ trunk/blender/source/blender/editors/interface/interface_handlers.c 2010-01-26 01:02:10 UTC (rev 26269)
@@ -3456,7 +3456,7 @@
uiLayout *layout;
uiStyle *style= U.uistyles.first;
IDProperty *prop= (but->opptr)? but->opptr->data: NULL;
- int kmi_id = WM_key_event_operator_id(C, but->optype->idname, but->opcontext, prop, &km);
+ int kmi_id = WM_key_event_operator_id(C, but->optype->idname, but->opcontext, prop, 1, &km);
kmi = WM_keymap_item_find_id(km, kmi_id);
@@ -3524,7 +3524,7 @@
wmKeyMap *km;
wmKeyMapItem *kmi;
IDProperty *prop= (but->opptr)? but->opptr->data: NULL;
- int kmi_id = WM_key_event_operator_id(C, but->optype->idname, but->opcontext, prop, &km);
+ int kmi_id = WM_key_event_operator_id(C, but->optype->idname, but->opcontext, prop, 1, &km);
kmi = WM_keymap_item_find_id(km, kmi_id);
WM_keymap_remove_item(km, kmi);
@@ -3662,10 +3662,12 @@
uiBut *but2;
IDProperty *prop= (but->opptr)? but->opptr->data: NULL;
int w = uiLayoutGetWidth(layout);
- char buf[512];
+ wmKeyMap *km;
+ int kmi_id= WM_key_event_operator_id(C, but->optype->idname, but->opcontext, prop, 1, &km);
+ wmKeyMapItem *kmi = WM_keymap_item_find_id(km, kmi_id);
/* keyboard shortcuts */
- if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, buf, sizeof(buf))) {
+ if ((kmi) && ISKEYBOARD(kmi->type)) {
// would rather use a block but, but gets weirdly positioned...
//uiDefBlockBut(block, menu_change_shortcut, but, "Change Shortcut", 0, 0, uiLayoutGetWidth(layout), UI_UNIT_Y, "");
Modified: trunk/blender/source/blender/windowmanager/WM_api.h
===================================================================
--- trunk/blender/source/blender/windowmanager/WM_api.h 2010-01-26 00:59:53 UTC (rev 26268)
+++ trunk/blender/source/blender/windowmanager/WM_api.h 2010-01-26 01:02:10 UTC (rev 26269)
@@ -131,7 +131,7 @@
void WM_modalkeymap_assign(struct wmKeyMap *km, char *opname);
const char *WM_key_event_string(short type);
-int WM_key_event_operator_id(const struct bContext *C, const char *opname, int opcontext, struct IDProperty *properties, struct wmKeyMap **keymap_r);
+int WM_key_event_operator_id(const struct bContext *C, const char *opname, int opcontext, struct IDProperty *properties, int hotkey, struct wmKeyMap **keymap_r);
char *WM_key_event_operator_string(const struct bContext *C, const char *opname, int opcontext, struct IDProperty *properties, char *str, int len);
/* handlers */
Modified: trunk/blender/source/blender/windowmanager/intern/wm_keymap.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_keymap.c 2010-01-26 00:59:53 UTC (rev 26268)
+++ trunk/blender/source/blender/windowmanager/intern/wm_keymap.c 2010-01-26 01:02:10 UTC (rev 26269)
@@ -397,7 +397,7 @@
return str;
}
-static wmKeyMapItem *wm_keymap_item_find_handlers(const bContext *C, ListBase *handlers, const char *opname, int opcontext, IDProperty *properties, int compare_props, wmKeyMap **keymap_r)
+static wmKeyMapItem *wm_keymap_item_find_handlers(const bContext *C, ListBase *handlers, const char *opname, int opcontext, IDProperty *properties, int compare_props, int hotkey, wmKeyMap **keymap_r)
{
wmWindowManager *wm= CTX_wm_manager(C);
wmEventHandler *handler;
@@ -411,6 +411,10 @@
if(keymap && (!keymap->poll || keymap->poll((bContext*)C))) {
for(kmi=keymap->items.first; kmi; kmi=kmi->next) {
if(strcmp(kmi->idname, opname) == 0 && WM_key_event_string(kmi->type)[0]) {
+ if (hotkey)
+ if (!ISHOTKEY(kmi->type))
+ continue;
+
if(compare_props) {
if(kmi->ptr && IDP_EqualsProperties(properties, kmi->ptr->data)) {
if(keymap_r) *keymap_r= keymap;
@@ -429,7 +433,7 @@
return NULL;
}
-static wmKeyMapItem *wm_keymap_item_find_props(const bContext *C, const char *opname, int opcontext, IDProperty *properties, int compare_props, wmKeyMap **keymap_r)
+static wmKeyMapItem *wm_keymap_item_find_props(const bContext *C, const char *opname, int opcontext, IDProperty *properties, int compare_props, int hotkey, wmKeyMap **keymap_r)
{
wmWindow *win= CTX_wm_window(C);
ScrArea *sa= CTX_wm_area(C);
@@ -438,11 +442,11 @@
/* look into multiple handler lists to find the item */
if(win)
- found= wm_keymap_item_find_handlers(C, &win->handlers, opname, opcontext, properties, compare_props, keymap_r);
+ found= wm_keymap_item_find_handlers(C, &win->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
if(sa && found==NULL)
- found= wm_keymap_item_find_handlers(C, &sa->handlers, opname, opcontext, properties, compare_props, keymap_r);
+ found= wm_keymap_item_find_handlers(C, &sa->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
if(found==NULL) {
if(ELEM(opcontext, WM_OP_EXEC_REGION_WIN, WM_OP_INVOKE_REGION_WIN)) {
@@ -453,31 +457,31 @@
break;
if(ar)
- found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, keymap_r);
+ found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, hotkey, compare_props, keymap_r);
}
}
else {
if(ar)
- found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, keymap_r);
+ found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, hotkey, compare_props, keymap_r);
}
}
return found;
}
-static wmKeyMapItem *wm_keymap_item_find(const bContext *C, const char *opname, int opcontext, IDProperty *properties, wmKeyMap **keymap_r)
+static wmKeyMapItem *wm_keymap_item_find(const bContext *C, const char *opname, int opcontext, IDProperty *properties, int hotkey, wmKeyMap **keymap_r)
{
- wmKeyMapItem *found= wm_keymap_item_find_props(C, opname, opcontext, properties, 1, keymap_r);
+ wmKeyMapItem *found= wm_keymap_item_find_props(C, opname, opcontext, properties, 1, hotkey, keymap_r);
if(!found)
- found= wm_keymap_item_find_props(C, opname, opcontext, properties, 0, keymap_r);
+ found= wm_keymap_item_find_props(C, opname, opcontext, properties, 0, hotkey, keymap_r);
return found;
}
char *WM_key_event_operator_string(const bContext *C, const char *opname, int opcontext, IDProperty *properties, char *str, int len)
{
- wmKeyMapItem *kmi= wm_keymap_item_find(C, opname, opcontext, properties, NULL);
+ wmKeyMapItem *kmi= wm_keymap_item_find(C, opname, opcontext, properties, 0, NULL);
if(kmi) {
WM_keymap_item_to_string(kmi, str, len);
@@ -487,9 +491,9 @@
return NULL;
}
-int WM_key_event_operator_id(const bContext *C, const char *opname, int opcontext, IDProperty *properties, wmKeyMap **keymap_r)
+int WM_key_event_operator_id(const bContext *C, const char *opname, int opcontext, IDProperty *properties, int hotkey, wmKeyMap **keymap_r)
{
- wmKeyMapItem *kmi= wm_keymap_item_find(C, opname, opcontext, properties, keymap_r);
+ wmKeyMapItem *kmi= wm_keymap_item_find(C, opname, opcontext, properties, hotkey, keymap_r);
if(kmi)
return kmi->id;
@@ -708,8 +712,9 @@
wmKeyMapItem *kmi;
for (kmi=keymap->items.first; kmi; kmi=kmi->next) {
- if (kmi->id == id)
+ if (kmi->id == id) {
return kmi;
+ }
}
return NULL;
@@ -747,6 +752,7 @@
else if (strstr(opname, "OBJECT_OT")) {
km = WM_keymap_find_all(C, "Object Mode", 0, 0);
}
+
/* Editing Modes */
else if (strstr(opname, "MESH_OT")) {
@@ -848,5 +854,34 @@
km = WM_keymap_find_all(C, "Console", sl->spacetype, 0);
}
+ /* Transform */
+ else if (strstr(opname, "TRANSFORM_OT")) {
+
+ /* check for relevant editor */
+ switch(sl->spacetype) {
+ case SPACE_VIEW3D:
+ km = WM_keymap_find_all(C, "3D View", sl->spacetype, 0);
+ break;
+ case SPACE_IPO:
+ km = WM_keymap_find_all(C, "Graph Editor", sl->spacetype, 0);
+ break;
+ case SPACE_ACTION:
+ km = WM_keymap_find_all(C, "Dopesheet", sl->spacetype, 0);
+ break;
+ case SPACE_NLA:
+ km = WM_keymap_find_all(C, "NLA Editor", sl->spacetype, 0);
+ break;
+ case SPACE_IMAGE:
+ km = WM_keymap_find_all(C, "UV Editor", sl->spacetype, 0);
+ break;
+ case SPACE_NODE:
+ km = WM_keymap_find_all(C, "Node Editor", sl->spacetype, 0);
+ break;
+ case SPACE_SEQ:
+ km = WM_keymap_find_all(C, "Sequencer", sl->spacetype, 0);
+ break;
+ }
+ }
+
return km;
}
More information about the Bf-blender-cvs
mailing list