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:
authorMatt Ebb <matt@mke3.net>2010-01-26 04:02:10 +0300
committerMatt Ebb <matt@mke3.net>2010-01-26 04:02:10 +0300
commitba2257b57e56cc410288756de491969f4e207985 (patch)
tree4d058bcfad7168527b6f976d7d86bdb0a29d48ea /source/blender/windowmanager
parentaba738aa34bf8078e0b6e698166576faf1462d5d (diff)
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.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/WM_api.h2
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c61
2 files changed, 49 insertions, 14 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 4defd781db9..b4cedf82a50 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -131,7 +131,7 @@ wmKeyMapItem *WM_modalkeymap_add_item(struct wmKeyMap *km, int type, int val, in
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 */
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index 447a7ecb92f..ff06005c620 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -397,7 +397,7 @@ char *WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len)
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 @@ static wmKeyMapItem *wm_keymap_item_find_handlers(const bContext *C, ListBase *h
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 @@ static wmKeyMapItem *wm_keymap_item_find_handlers(const bContext *C, ListBase *h
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 @@ static wmKeyMapItem *wm_keymap_item_find_props(const bContext *C, const char *op
/* 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 @@ static wmKeyMapItem *wm_keymap_item_find_props(const bContext *C, const char *op
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 @@ char *WM_key_event_operator_string(const bContext *C, const char *opname, int op
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 *WM_keymap_item_find_id(wmKeyMap *keymap, int id)
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 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, char *opname)
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 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, char *opname)
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;
}