Keymaps now have a poll() function, rather than adding/removing
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 17 Sep 2009 21:36:02 +0000 (21:36 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 17 Sep 2009 21:36:02 +0000 (21:36 +0000)
their handlers based on notifiers, which is simpler and more
reliable.

This fixes for example editmode or uv edit keymaps not working
when creating a new 3dview or image space.

51 files changed:
source/blender/blenloader/intern/readfile.c
source/blender/editors/animation/anim_channels_edit.c
source/blender/editors/animation/anim_markers.c
source/blender/editors/animation/anim_ops.c
source/blender/editors/armature/armature_ops.c
source/blender/editors/curve/curve_ops.c
source/blender/editors/gpencil/gpencil_ops.c
source/blender/editors/include/ED_transform.h
source/blender/editors/interface/view2d_ops.c
source/blender/editors/mesh/mesh_ops.c
source/blender/editors/metaball/mball_ops.c
source/blender/editors/object/object_ops.c
source/blender/editors/physics/ed_pointcache.c
source/blender/editors/physics/editparticle.c
source/blender/editors/screen/area.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/space_action/action_ops.c
source/blender/editors/space_action/space_action.c
source/blender/editors/space_buttons/space_buttons.c
source/blender/editors/space_console/space_console.c
source/blender/editors/space_file/space_file.c
source/blender/editors/space_graph/graph_ops.c
source/blender/editors/space_graph/space_graph.c
source/blender/editors/space_image/space_image.c
source/blender/editors/space_logic/space_logic.c
source/blender/editors/space_nla/nla_ops.c
source/blender/editors/space_nla/space_nla.c
source/blender/editors/space_node/node_ops.c
source/blender/editors/space_node/space_node.c
source/blender/editors/space_outliner/outliner_ops.c
source/blender/editors/space_outliner/space_outliner.c
source/blender/editors/space_script/script_ops.c
source/blender/editors/space_script/space_script.c
source/blender/editors/space_sequencer/sequencer_ops.c
source/blender/editors/space_sequencer/space_sequencer.c
source/blender/editors/space_sound/space_sound.c
source/blender/editors/space_text/space_text.c
source/blender/editors/space_time/space_time.c
source/blender/editors/space_time/time_ops.c
source/blender/editors/space_view3d/space_view3d.c
source/blender/editors/space_view3d/view3d_ops.c
source/blender/editors/transform/transform_ops.c
source/blender/editors/uvedit/uvedit_ops.c
source/blender/makesdna/DNA_view3d_types.h
source/blender/makesdna/DNA_windowmanager_types.h
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_keymap.c
source/blender/windowmanager/intern/wm_operators.c
source/blender/windowmanager/intern/wm_window.c
source/blender/windowmanager/wm_event_system.h

index bb7262c01d49a82ad437f884ab210c168bf15a22..6518db2dc91314fa9f014ed19f4dcbbacab03733 100644 (file)
@@ -4826,7 +4826,6 @@ static void direct_link_region(FileData *fd, ARegion *ar, int spacetype)
                        rv3d->ri= NULL;
                        rv3d->sms= NULL;
                        rv3d->smooth_timer= NULL;
-                       rv3d->lastmode= 0;
                }
        }
        
index 72d8f71bc265ad4d519fe8b7b726d2bf0a8537cd..4afecdb55c08c1b3ad7e90147ec5827116f48105 100644 (file)
@@ -1572,7 +1572,7 @@ void ED_operatortypes_animchannels(void)
 
 void ED_keymap_animchannels(wmWindowManager *wm)
 {
-       ListBase *keymap = WM_keymap_listbase(wm, "Animation_Channels", 0, 0);
+       wmKeyMap *keymap = WM_keymap_find(wm, "Animation_Channels", 0, 0);
        
        /* selection */
                /* click-select */
index d33eece52c9f7fe08369cf9407dc410829f8bdb7..06fa3b715e0c9293464ea9b8d3773da943be89b6 100644 (file)
@@ -992,7 +992,7 @@ void ED_operatortypes_marker(void)
 /* called in screen_ops.c:ED_keymap_screen() */
 void ED_marker_keymap(wmWindowManager *wm)
 {
-       ListBase *keymap= WM_keymap_listbase(wm, "Markers", 0, 0);
+       wmKeyMap *keymap= WM_keymap_find(wm, "Markers", 0, 0);
        
        WM_keymap_verify_item(keymap, "MARKER_OT_add", MKEY, KM_PRESS, 0, 0);
        WM_keymap_verify_item(keymap, "MARKER_OT_move", EVT_TWEAK_S, KM_ANY, 0, 0);
index fedbe12c0e6603976a07358c4a2872e49651e849..186bdc3b7624b7687c53f9f5922a78cea00427e4 100644 (file)
@@ -406,7 +406,7 @@ void ED_operatortypes_anim(void)
 
 void ED_keymap_anim(wmWindowManager *wm)
 {
-       ListBase *keymap= WM_keymap_listbase(wm, "Animation", 0, 0);
+       wmKeyMap *keymap= WM_keymap_find(wm, "Animation", 0, 0);
        
        /* frame management */
                /* NOTE: 'ACTIONMOUSE' not 'LEFTMOUSE', as user may have swapped mouse-buttons */
index 389a0a5174a371a3fdc28a149c8e386846a0a1bf..4a61c8ddaf87f66e24bb7272d68ff508c9b9961c 100644 (file)
@@ -202,11 +202,12 @@ void ED_operatortypes_armature(void)
 
 void ED_keymap_armature(wmWindowManager *wm)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
        wmKeymapItem *kmi;
        
        /* Armature ------------------------ */
-       keymap= WM_keymap_listbase(wm, "Armature", 0, 0);
+       keymap= WM_keymap_find(wm, "Armature", 0, 0);
+       keymap->poll= ED_operator_editarmature;
        
        /* only set in editmode armature, by space_view3d listener */
 //     WM_keymap_add_item(keymap, "ARMATURE_OT_hide", HKEY, KM_PRESS, 0, 0);
@@ -280,7 +281,8 @@ void ED_keymap_armature(wmWindowManager *wm)
 
        /* Pose ------------------------ */
        /* only set in posemode, by space_view3d listener */
-       keymap= WM_keymap_listbase(wm, "Pose", 0, 0);
+       keymap= WM_keymap_find(wm, "Pose", 0, 0);
+       keymap->poll= ED_operator_posemode;
        
        WM_keymap_add_item(keymap, "POSE_OT_hide", HKEY, KM_PRESS, 0, 0);
        kmi= WM_keymap_add_item(keymap, "POSE_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0);
index 8a90dace40b7fd6ea6ef8af0ab16f003e4ce63b2..77c5ed1de2c4099e478b381ae9b9fe16013a2bd0 100644 (file)
@@ -163,7 +163,10 @@ void ED_operatortypes_curve(void)
 
 void ED_keymap_curve(wmWindowManager *wm)
 {
-       ListBase *keymap= WM_keymap_listbase(wm, "Font", 0, 0);
+       wmKeyMap *keymap;
+       
+       keymap= WM_keymap_find(wm, "Font", 0, 0);
+       keymap->poll= ED_operator_editfont;
        
        /* only set in editmode font, by space_view3d listener */
        RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_style_toggle", BKEY, KM_PRESS, KM_CTRL, 0)->ptr, "style", CU_BOLD);
@@ -212,7 +215,8 @@ void ED_keymap_curve(wmWindowManager *wm)
        WM_keymap_add_item(keymap, "FONT_OT_text_insert", KM_TEXTINPUT, KM_ANY, KM_ANY, 0); // last!
 
        /* only set in editmode curve, by space_view3d listener */
-       keymap= WM_keymap_listbase(wm, "Curve", 0, 0);
+       keymap= WM_keymap_find(wm, "Curve", 0, 0);
+       keymap->poll= ED_operator_editsurfcurve;
        
        WM_keymap_add_item(keymap, "OBJECT_OT_curve_add", AKEY, KM_PRESS, KM_SHIFT, 0);
        WM_keymap_add_item(keymap, "CURVE_OT_vertex_add", ACTIONMOUSE, KM_PRESS, KM_CTRL, 0);
index d33ad16dfb15b1f673d0e05044bb524bfcc1c09e..d311b39b9a34a3ebf32bad0b82f048ef97802a44 100644 (file)
@@ -47,7 +47,7 @@
 
 void ED_keymap_gpencil(wmWindowManager *wm)
 {
-       ListBase *keymap= WM_keymap_listbase(wm, "Grease Pencil", 0, 0);
+       wmKeyMap *keymap= WM_keymap_find(wm, "Grease Pencil", 0, 0);
        wmKeymapItem *kmi;
        
        /* Draw */
index 984def760ae2451545b837aa9c7cd1126cb8b1d5..96425f725e9086da750e85ffde2ea65355083615 100644 (file)
@@ -41,8 +41,9 @@ struct Object;
 struct uiLayout;
 struct EnumPropertyItem;
 struct wmOperatorType;
+struct wmKeyMap;
 
-void transform_keymap_for_space(struct wmWindowManager *wm, struct ListBase *keymap, int spaceid);
+void transform_keymap_for_space(struct wmWindowManager *wm, struct wmKeyMap *keymap, int spaceid);
 void transform_operatortypes(void);
 
 /* ******************** Macros & Prototypes *********************** */
index 3e009884dee30d847d1d370f5865711bca9239c5..33838418842afbf103780f1566bab7e64fee4e77 100644 (file)
@@ -1409,7 +1409,7 @@ void ui_view2d_operatortypes(void)
 
 void UI_view2d_keymap(wmWindowManager *wm)
 {
-       ListBase *keymap= WM_keymap_listbase(wm, "View2D", 0, 0);
+       wmKeyMap *keymap= WM_keymap_find(wm, "View2D", 0, 0);
        
        /* pan/scroll */
        WM_keymap_add_item(keymap, "VIEW2D_OT_pan", MIDDLEMOUSE, KM_PRESS, 0, 0);
@@ -1445,7 +1445,7 @@ void UI_view2d_keymap(wmWindowManager *wm)
        WM_keymap_add_item(keymap, "VIEW2D_OT_scroller_activate", LEFTMOUSE, KM_PRESS, 0, 0);
 
        /* Alternative keymap for buttons listview */
-       keymap= WM_keymap_listbase(wm, "View2D Buttons List", 0, 0);
+       keymap= WM_keymap_find(wm, "View2D Buttons List", 0, 0);
        WM_keymap_add_item(keymap, "VIEW2D_OT_pan", MIDDLEMOUSE, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_down", WHEELDOWNMOUSE, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_up", WHEELUPMOUSE, KM_PRESS, 0, 0);
index 6da42f28af4e0c78a5552dc9a91ed04cca0c287f..f22adc597c7e30f51b99f2cfcc0b47f1a3034912 100644 (file)
@@ -349,9 +349,12 @@ void ED_operatortypes_mesh(void)
 /* note mesh keymap also for other space? */
 void ED_keymap_mesh(wmWindowManager *wm)
 {      
-       ListBase *keymap= WM_keymap_listbase(wm, "EditMesh", 0, 0);
+       wmKeyMap *keymap;
        wmKeymapItem *kmi;
        
+       keymap= WM_keymap_find(wm, "EditMesh", 0, 0);
+       keymap->poll= ED_operator_editmesh;
+       
        WM_keymap_add_item(keymap, "MESH_OT_loopcut", ACTIONMOUSE, KM_PRESS, KM_CTRL, RKEY);
 
        /* selecting */
index b469bb3e400661b9b37fc41e6584c424926ae006..dd8a18f385c66fe0576115a02af905b17aac701f 100644 (file)
@@ -34,6 +34,8 @@
 #include "DNA_listBase.h"
 #include "DNA_windowmanager_types.h"
 
+#include "ED_screen.h"
+
 #include "mball_intern.h"
 
 void ED_operatortypes_metaball(void)
@@ -51,7 +53,10 @@ void ED_operatortypes_metaball(void)
 
 void ED_keymap_metaball(wmWindowManager *wm)
 {
-       ListBase *keymap= WM_keymap_listbase(wm, "Metaball", 0, 0);
+       wmKeyMap *keymap;
+       
+       keymap= WM_keymap_find(wm, "Metaball", 0, 0);
+       keymap->poll= ED_operator_editmball;
 
        WM_keymap_add_item(keymap, "OBJECT_OT_metaball_add", AKEY, KM_PRESS, KM_SHIFT, 0);
        
index dce09d47b2ca42f54472a4d7e3ce9b3d0c79301d..fdfe6ed501c2165bb7401993f2bfea19648bf408 100644 (file)
@@ -184,11 +184,19 @@ void ED_operatortypes_object(void)
        }
 }
 
+static int object_mode_poll(bContext *C)
+{
+       Object *ob= CTX_data_active_object(C);
+       return (!ob || ob->mode == OB_MODE_OBJECT);
+}
+
 void ED_keymap_object(wmWindowManager *wm)
 {
-       ListBase *keymap= WM_keymap_listbase(wm, "Object Non-modal", 0, 0);
+       wmKeyMap *keymap;
        wmKeymapItem *kmi;
        
+       keymap= WM_keymap_find(wm, "Object Non-modal", 0, 0);
+       
        /* Note: this keymap works disregarding mode */
        WM_keymap_add_item(keymap, "OBJECT_OT_editmode_toggle", TABKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "OBJECT_OT_posemode_toggle", TABKEY, KM_PRESS, KM_CTRL, 0);
@@ -203,7 +211,8 @@ void ED_keymap_object(wmWindowManager *wm)
        WM_keymap_add_item(keymap, "OBJECT_OT_center_set", CKEY, KM_PRESS, KM_ALT|KM_SHIFT|KM_CTRL, 0);
 
        /* Note: this keymap gets disabled in non-objectmode,  */
-       keymap= WM_keymap_listbase(wm, "Object Mode", 0, 0);
+       keymap= WM_keymap_find(wm, "Object Mode", 0, 0);
+       keymap->poll= object_mode_poll;
        
        WM_keymap_add_item(keymap, "OBJECT_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "OBJECT_OT_select_inverse", IKEY, KM_PRESS, KM_CTRL, 0);
@@ -246,7 +255,8 @@ void ED_keymap_object(wmWindowManager *wm)
        WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove_active", GKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0);
 
        /* Lattice */
-       keymap= WM_keymap_listbase(wm, "Lattice", 0, 0);
+       keymap= WM_keymap_find(wm, "Lattice", 0, 0);
+       keymap->poll= ED_operator_editlattice;
 
        WM_keymap_add_item(keymap, "LATTICE_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
 }
index f2c7b64032f737605ec1117fb4b1ee7466c34a5e..ed3aaf0cfd1824a1c9883f2ff2855d1d54238594 100644 (file)
@@ -347,7 +347,7 @@ void ED_operatortypes_pointcache(void)
 
 //void ED_keymap_pointcache(wmWindowManager *wm)
 //{
-//     ListBase *keymap= WM_keymap_listbase(wm, "Pointcache", 0, 0);
+//     wmKeyMap *keymap= WM_keymap_find(wm, "Pointcache", 0, 0);
 //     
 //     WM_keymap_add_item(keymap, "PHYSICS_OT_bake_all", AKEY, KM_PRESS, 0, 0);
 //     WM_keymap_add_item(keymap, "PHYSICS_OT_free_all", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
index 85ec215a3269c9aeb62de01b00886c5b32e91b10..6d1f2e5057b24a66a147c5ece9b40544dc9f62b6 100644 (file)
@@ -3973,7 +3973,10 @@ void ED_operatortypes_particle(void)
 
 void ED_keymap_particle(wmWindowManager *wm)
 {
-       ListBase *keymap= WM_keymap_listbase(wm, "Particle", 0, 0);
+       wmKeyMap *keymap;
+       
+       keymap= WM_keymap_find(wm, "Particle", 0, 0);
+       keymap->poll= PE_poll;
        
        WM_keymap_add_item(keymap, "PARTICLE_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "PARTICLE_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
index 07d0d1a85c567851f49cc24719a75c9cbef16bb5..87901d754949e1bcb64023dc2a276f70c00fc7a5 100644 (file)
@@ -824,24 +824,24 @@ static void ed_default_handlers(wmWindowManager *wm, ListBase *handlers, int fla
                UI_add_region_handlers(handlers);
        }
        if(flag & ED_KEYMAP_VIEW2D) {
-               ListBase *keymap= WM_keymap_listbase(wm, "View2D", 0, 0);
+               wmKeyMap *keymap= WM_keymap_find(wm, "View2D", 0, 0);
                WM_event_add_keymap_handler(handlers, keymap);
        }
        if(flag & ED_KEYMAP_MARKERS) {
-               ListBase *keymap= WM_keymap_listbase(wm, "Markers", 0, 0);
+               wmKeyMap *keymap= WM_keymap_find(wm, "Markers", 0, 0);
                WM_event_add_keymap_handler(handlers, keymap);
                // XXX need boundbox check urgently!!!
        }
        if(flag & ED_KEYMAP_ANIMATION) {
-               ListBase *keymap= WM_keymap_listbase(wm, "Animation", 0, 0);
+               wmKeyMap *keymap= WM_keymap_find(wm, "Animation", 0, 0);
                WM_event_add_keymap_handler(handlers, keymap);
        }
        if(flag & ED_KEYMAP_FRAMES) {
-               ListBase *keymap= WM_keymap_listbase(wm, "Frames", 0, 0);
+               wmKeyMap *keymap= WM_keymap_find(wm, "Frames", 0, 0);
                WM_event_add_keymap_handler(handlers, keymap);
        }
        if(flag & ED_KEYMAP_GPENCIL) {
-               ListBase *keymap= WM_keymap_listbase(wm, "Grease Pencil", 0, 0);
+               wmKeyMap *keymap= WM_keymap_find(wm, "Grease Pencil", 0, 0);
                WM_event_add_keymap_handler(handlers, keymap);
        }
 }
@@ -1353,7 +1353,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *contex
 
 void ED_region_panels_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
        
        // XXX quick hacks for files saved with 2.5 already (i.e. the builtin defaults file)
                // scrollbars for button regions
@@ -1366,7 +1366,7 @@ void ED_region_panels_init(wmWindowManager *wm, ARegion *ar)
        
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_PANELS_UI, ar->winx, ar->winy);
 
-       keymap= WM_keymap_listbase(wm, "View2D Buttons List", 0, 0);
+       keymap= WM_keymap_find(wm, "View2D Buttons List", 0, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 }
 
index 0bb1969ce3ce35ae1f9d698a2c26339fd1bf5b3f..605bd8682f574eec3489d72ea2e41278300492f2 100644 (file)
@@ -3291,10 +3291,10 @@ static void keymap_modal_set(wmWindowManager *wm)
 /* called in spacetypes.c */
 void ED_keymap_screen(wmWindowManager *wm)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
        
        /* Screen General ------------------------------------------------ */
-       keymap= WM_keymap_listbase(wm, "Screen", 0, 0);
+       keymap= WM_keymap_find(wm, "Screen", 0, 0);
        
        
        /* standard timers */
@@ -3361,7 +3361,7 @@ void ED_keymap_screen(wmWindowManager *wm)
        
        
        /* Anim Playback ------------------------------------------------ */
-       keymap= WM_keymap_listbase(wm, "Frames", 0, 0);
+       keymap= WM_keymap_find(wm, "Frames", 0, 0);
        
        /* frame offsets */
        RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", UPARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", 10);
index cd4a7b30efffc68a484fc860a12bd00796df6e8d..00b22232608d66dd8bd75d0c4706c7e441c9b53f 100644 (file)
@@ -91,7 +91,7 @@ void action_operatortypes(void)
 
 /* ************************** registration - keymaps **********************************/
 
-static void action_keymap_keyframes (wmWindowManager *wm, ListBase *keymap)
+static void action_keymap_keyframes (wmWindowManager *wm, wmKeyMap *keymap)
 {
        wmKeymapItem *kmi;
        
@@ -166,7 +166,7 @@ static void action_keymap_keyframes (wmWindowManager *wm, ListBase *keymap)
 
 void action_keymap(wmWindowManager *wm)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
        
        /* channels */
        /* Channels are not directly handled by the Action Editor module, but are inherited from the Animation module. 
@@ -175,7 +175,7 @@ void action_keymap(wmWindowManager *wm)
         */
        
        /* keyframes */
-       keymap= WM_keymap_listbase(wm, "Action_Keys", SPACE_ACTION, 0);
+       keymap= WM_keymap_find(wm, "Action_Keys", SPACE_ACTION, 0);
        action_keymap_keyframes(wm, keymap);
 }
 
index b7a3df563ea673626c31f7e14541311d9f5a2927..bceee73d5f052ee03fe81555e98e9c77d659876e 100644 (file)
@@ -153,12 +153,12 @@ static SpaceLink *action_duplicate(SpaceLink *sl)
 /* add handlers, stuff you only do once or on area/region changes */
 static void action_main_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
        
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
        
        /* own keymap */
-       keymap= WM_keymap_listbase(wm, "Action_Keys", SPACE_ACTION, 0); /* XXX weak? */
+       keymap= WM_keymap_find(wm, "Action_Keys", SPACE_ACTION, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 }
 
@@ -216,12 +216,12 @@ static void action_main_area_draw(const bContext *C, ARegion *ar)
 /* add handlers, stuff you only do once or on area/region changes */
 static void action_channel_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
        
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
        
        /* own keymap */
-       keymap= WM_keymap_listbase(wm, "Animation_Channels", 0, 0);     /* XXX weak? */
+       keymap= WM_keymap_find(wm, "Animation_Channels", 0, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 }
 
index c8ced42c2d228eed0afb0f4289870e5227b4689c..381beaa02954a28f7bd0395c6cb1ef2d51b78c97 100644 (file)
@@ -138,11 +138,11 @@ static SpaceLink *buttons_duplicate(SpaceLink *sl)
 /* add handlers, stuff you only do once or on area/region changes */
 static void buttons_main_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
 
        ED_region_panels_init(wm, ar);
 
-       keymap= WM_keymap_listbase(wm, "Buttons Generic", SPACE_BUTS, 0);
+       keymap= WM_keymap_find(wm, "Buttons Generic", SPACE_BUTS, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 }
 
@@ -216,7 +216,7 @@ void buttons_operatortypes(void)
 
 void buttons_keymap(struct wmWindowManager *wm)
 {
-       ListBase *keymap= WM_keymap_listbase(wm, "Buttons Generic", SPACE_BUTS, 0);
+       wmKeyMap *keymap= WM_keymap_find(wm, "Buttons Generic", SPACE_BUTS, 0);
        
        WM_keymap_add_item(keymap, "BUTTONS_OT_toolbox", RIGHTMOUSE, KM_PRESS, 0, 0);
 }
index dfaaa269970422e9aeb47230ee0334bd068b4d62..6526b569bbb2a07ac608203640a5b09b1752ef14 100644 (file)
@@ -147,12 +147,12 @@ static SpaceLink *console_duplicate(SpaceLink *sl)
 /* add handlers, stuff you only do once or on area/region changes */
 static void console_main_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
 
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
 
        /* own keymap */
-       keymap= WM_keymap_listbase(wm, "Console", SPACE_CONSOLE, 0);    /* XXX weak? */
+       keymap= WM_keymap_find(wm, "Console", SPACE_CONSOLE, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 }
 
@@ -231,7 +231,7 @@ void console_operatortypes(void)
 
 void console_keymap(struct wmWindowManager *wm)
 {
-       ListBase *keymap= WM_keymap_listbase(wm, "Console", SPACE_CONSOLE, 0);
+       wmKeyMap *keymap= WM_keymap_find(wm, "Console", SPACE_CONSOLE, 0);
        
        #ifdef __APPLE__
        RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", LEFTARROWKEY, KM_PRESS, KM_OSKEY, 0)->ptr, "type", LINE_BEGIN);
index 27948618d034ef481c046e282596b3791da9af08..99d649b28cc3db4305abe6d6457f72c4d6738053 100644 (file)
@@ -255,15 +255,15 @@ static void file_listener(ScrArea *sa, wmNotifier *wmn)
 /* add handlers, stuff you only do once or on area/region changes */
 static void file_main_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
        
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
        
        /* own keymaps */
-       keymap= WM_keymap_listbase(wm, "File", SPACE_FILE, 0);
+       keymap= WM_keymap_find(wm, "File", SPACE_FILE, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 
-       keymap= WM_keymap_listbase(wm, "FileMain", SPACE_FILE, 0);
+       keymap= WM_keymap_find(wm, "FileMain", SPACE_FILE, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
                                                           
 
@@ -375,7 +375,7 @@ void file_keymap(struct wmWindowManager *wm)
 {
        wmKeymapItem *kmi;
        /* keys for all areas */
-       ListBase *keymap= WM_keymap_listbase(wm, "File", SPACE_FILE, 0);
+       wmKeyMap *keymap= WM_keymap_find(wm, "File", SPACE_FILE, 0);
        WM_keymap_add_item(keymap, "FILE_OT_bookmark_toggle", NKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "FILE_OT_parent", PKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "FILE_OT_add_bookmark", BKEY, KM_PRESS, KM_CTRL, 0);
@@ -386,7 +386,7 @@ void file_keymap(struct wmWindowManager *wm)
        WM_keymap_add_item(keymap, "FILE_OT_delete", XKEY, KM_PRESS, 0, 0);
 
        /* keys for main area */
-       keymap= WM_keymap_listbase(wm, "FileMain", SPACE_FILE, 0);
+       keymap= WM_keymap_find(wm, "FileMain", SPACE_FILE, 0);
        WM_keymap_add_item(keymap, "FILE_OT_select", LEFTMOUSE, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "FILE_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "FILE_OT_select_border", BKEY, KM_PRESS, 0, 0);
@@ -407,7 +407,7 @@ void file_keymap(struct wmWindowManager *wm)
        RNA_int_set(kmi->ptr, "increment",-100);
        
        /* keys for button area (top) */
-       keymap= WM_keymap_listbase(wm, "FileButtons", SPACE_FILE, 0);
+       keymap= WM_keymap_find(wm, "FileButtons", SPACE_FILE, 0);
        WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, 0, 0);
        kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, 0, 0);
        RNA_int_set(kmi->ptr, "increment", 1);
@@ -426,12 +426,12 @@ void file_keymap(struct wmWindowManager *wm)
 
 static void file_channel_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
 
        ED_region_panels_init(wm, ar);
 
        /* own keymaps */
-       keymap= WM_keymap_listbase(wm, "File", SPACE_FILE, 0);  
+       keymap= WM_keymap_find(wm, "File", SPACE_FILE, 0);      
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 }
 
@@ -462,15 +462,15 @@ static void file_header_area_draw(const bContext *C, ARegion *ar)
 /* add handlers, stuff you only do once or on area/region changes */
 static void file_ui_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
 
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy);
 
        /* own keymap */
-       keymap= WM_keymap_listbase(wm, "File", SPACE_FILE, 0);  /* XXX weak? */
+       keymap= WM_keymap_find(wm, "File", SPACE_FILE, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 
-       keymap= WM_keymap_listbase(wm, "FileButtons", SPACE_FILE, 0);   /* XXX weak? */
+       keymap= WM_keymap_find(wm, "FileButtons", SPACE_FILE, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 }
 
index fc4c05915c988eaa3c6361c495a0ad64b7cb174d..b7d67c85ab926c771c64f49d6c2adbf904c80d86 100644 (file)
@@ -141,7 +141,7 @@ void graphedit_operatortypes(void)
 
 /* ************************** registration - keymaps **********************************/
 
-static void graphedit_keymap_keyframes (wmWindowManager *wm, ListBase *keymap)
+static void graphedit_keymap_keyframes (wmWindowManager *wm, wmKeyMap *keymap)
 {
        wmKeymapItem *kmi;
        
@@ -232,10 +232,10 @@ static void graphedit_keymap_keyframes (wmWindowManager *wm, ListBase *keymap)
 
 void graphedit_keymap(wmWindowManager *wm)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
        
        /* keymap for all regions */
-       keymap= WM_keymap_listbase(wm, "GraphEdit Generic", SPACE_IPO, 0);
+       keymap= WM_keymap_find(wm, "GraphEdit Generic", SPACE_IPO, 0);
        WM_keymap_add_item(keymap, "GRAPH_OT_properties", NKEY, KM_PRESS, 0, 0);
 
        /* channels */
@@ -245,7 +245,7 @@ void graphedit_keymap(wmWindowManager *wm)
         */
        
        /* keyframes */
-       keymap= WM_keymap_listbase(wm, "GraphEdit Keys", SPACE_IPO, 0);
+       keymap= WM_keymap_find(wm, "GraphEdit Keys", SPACE_IPO, 0);
        graphedit_keymap_keyframes(wm, keymap);
 }
 
index 8887d464f3003c4a54ebe247015ea6e9b03e5d89..e0b961b38f17c5f60a1d2b89bb18d8a94015ae41 100644 (file)
@@ -203,14 +203,14 @@ static SpaceLink *graph_duplicate(SpaceLink *sl)
 /* add handlers, stuff you only do once or on area/region changes */
 static void graph_main_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
        
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
        
        /* own keymap */
-       keymap= WM_keymap_listbase(wm, "GraphEdit Keys", SPACE_IPO, 0); /* XXX weak? */
+       keymap= WM_keymap_find(wm, "GraphEdit Keys", SPACE_IPO, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
-       keymap= WM_keymap_listbase(wm, "GraphEdit Generic", SPACE_IPO, 0);
+       keymap= WM_keymap_find(wm, "GraphEdit Generic", SPACE_IPO, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 }
 
@@ -281,14 +281,14 @@ static void graph_main_area_draw(const bContext *C, ARegion *ar)
 
 static void graph_channel_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
        
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
        
        /* own keymap */
-       keymap= WM_keymap_listbase(wm, "Animation_Channels", 0, 0);     /* XXX weak? */
+       keymap= WM_keymap_find(wm, "Animation_Channels", 0, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
-       keymap= WM_keymap_listbase(wm, "GraphEdit Generic", SPACE_IPO, 0);
+       keymap= WM_keymap_find(wm, "GraphEdit Generic", SPACE_IPO, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 }
 
@@ -352,11 +352,11 @@ static void graph_header_area_draw(const bContext *C, ARegion *ar)
 /* add handlers, stuff you only do once or on area/region changes */
 static void graph_buttons_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
        
        ED_region_panels_init(wm, ar);
 
-       keymap= WM_keymap_listbase(wm, "GraphEdit Generic", SPACE_IPO, 0);
+       keymap= WM_keymap_find(wm, "GraphEdit Generic", SPACE_IPO, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 }
 
index c57bc5773b0fc288c1cda109fda0483b34d9f53f..e57a059265fb8aae42e6801b668b3f910d069af6 100644 (file)
@@ -204,7 +204,7 @@ void image_operatortypes(void)
 
 void image_keymap(struct wmWindowManager *wm)
 {
-       ListBase *keymap= WM_keymap_listbase(wm, "Image Generic", SPACE_IMAGE, 0);
+       wmKeyMap *keymap= WM_keymap_find(wm, "Image Generic", SPACE_IMAGE, 0);
        
        WM_keymap_add_item(keymap, "IMAGE_OT_new", NKEY, KM_PRESS, KM_ALT, 0);
        WM_keymap_add_item(keymap, "IMAGE_OT_open", OKEY, KM_PRESS, KM_ALT, 0);
@@ -212,7 +212,7 @@ void image_keymap(struct wmWindowManager *wm)
        WM_keymap_add_item(keymap, "IMAGE_OT_save", SKEY, KM_PRESS, KM_ALT, 0);
        WM_keymap_add_item(keymap, "IMAGE_OT_properties", NKEY, KM_PRESS, 0, 0);
        
-       keymap= WM_keymap_listbase(wm, "Image", SPACE_IMAGE, 0);
+       keymap= WM_keymap_find(wm, "Image", SPACE_IMAGE, 0);
        
        WM_keymap_add_item(keymap, "IMAGE_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "IMAGE_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
@@ -398,23 +398,22 @@ static void image_main_area_set_view2d(SpaceImage *sima, ARegion *ar, Scene *sce
 /* add handlers, stuff you only do once or on area/region changes */
 static void image_main_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
        
        // image space manages own v2d
        // UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy);
 
        /* image paint polls for mode */
-       keymap= WM_keymap_listbase(wm, "ImagePaint", SPACE_IMAGE, 0);
+       keymap= WM_keymap_find(wm, "ImagePaint", SPACE_IMAGE, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 
-       /* XXX need context here?
-       keymap= WM_keymap_listbase(wm, "UVEdit", 0, 0);
-       WM_event_add_keymap_handler(&ar->handlers, keymap);*/
+       keymap= WM_keymap_find(wm, "UVEdit", 0, 0);
+       WM_event_add_keymap_handler(&ar->handlers, keymap);
        
        /* own keymaps */
-       keymap= WM_keymap_listbase(wm, "Image Generic", SPACE_IMAGE, 0);
+       keymap= WM_keymap_find(wm, "Image Generic", SPACE_IMAGE, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
-       keymap= WM_keymap_listbase(wm, "Image", SPACE_IMAGE, 0);
+       keymap= WM_keymap_find(wm, "Image", SPACE_IMAGE, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 }
 
@@ -457,29 +456,11 @@ static void image_main_area_draw(const bContext *C, ARegion *ar)
        UI_view2d_scrollers_free(scrollers);*/
 }
 
-static void image_modal_keymaps(wmWindowManager *wm, ARegion *ar, int stype)
-{
-       ListBase *keymap;
-       
-       keymap= WM_keymap_listbase(wm, "UVEdit", 0, 0);
-
-       if(stype==NS_EDITMODE_MESH)
-               WM_event_add_keymap_handler(&ar->handlers, keymap);
-       else
-               WM_event_remove_keymap_handler(&ar->handlers, keymap);
-}
-
 static void image_main_area_listener(ARegion *ar, wmNotifier *wmn)
 {
        /* context changes */
        switch(wmn->category) {
-               case NC_SCENE:
-                       switch(wmn->data) {
-                               case ND_MODE:
-                                       image_modal_keymaps(wmn->wm, ar, wmn->subtype);
-                                       break;
-                       }
-                       break;
+               /* nothing yet */
        }
 }
 
@@ -488,11 +469,11 @@ static void image_main_area_listener(ARegion *ar, wmNotifier *wmn)
 /* add handlers, stuff you only do once or on area/region changes */
 static void image_buttons_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
 
        ED_region_panels_init(wm, ar);
        
-       keymap= WM_keymap_listbase(wm, "Image Generic", SPACE_IMAGE, 0);
+       keymap= WM_keymap_find(wm, "Image Generic", SPACE_IMAGE, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 }
 
index 3c46522bba2025f8992b0bd32eb2600a88bba759..7043d625ab0f12b191fcb5112bbaba0690f914e6 100644 (file)
@@ -188,7 +188,7 @@ void logic_operatortypes(void)
 
 void logic_keymap(struct wmWindowManager *wm)
 {
-       ListBase *keymap= WM_keymap_listbase(wm, "Logic Generic", SPACE_LOGIC, 0);
+       wmKeyMap *keymap= WM_keymap_find(wm, "Logic Generic", SPACE_LOGIC, 0);
        
        WM_keymap_add_item(keymap, "LOGIC_OT_properties", NKEY, KM_PRESS, 0, 0);
 }
@@ -234,12 +234,12 @@ static int logic_context(const bContext *C, const char *member, bContextDataResu
 /* add handlers, stuff you only do once or on area/region changes */
 static void logic_main_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
        
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
 
        /* own keymaps */
-       keymap= WM_keymap_listbase(wm, "Logic Generic", SPACE_LOGIC, 0);
+       keymap= WM_keymap_find(wm, "Logic Generic", SPACE_LOGIC, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 }
 
@@ -276,11 +276,11 @@ static void logic_main_area_draw(const bContext *C, ARegion *ar)
 /* add handlers, stuff you only do once or on area/region changes */
 static void logic_buttons_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
 
        ED_region_panels_init(wm, ar);
        
-       keymap= WM_keymap_listbase(wm, "Logic Generic", SPACE_LOGIC, 0);
+       keymap= WM_keymap_find(wm, "Logic Generic", SPACE_LOGIC, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 }
 
index ad5f5174690af26652dc9e928059546b7b395c53..5ea2e99ad6ae7ea1dbbd7b51b28685ebe5811619 100644 (file)
@@ -167,7 +167,7 @@ void nla_operatortypes(void)
 
 /* ************************** registration - keymaps **********************************/
 
-static void nla_keymap_channels (wmWindowManager *wm, ListBase *keymap)
+static void nla_keymap_channels (wmWindowManager *wm, wmKeyMap *keymap)
 {
        /* NLA-specific (different to standard channels keymap) -------------------------- */
        /* selection */
@@ -210,7 +210,7 @@ static void nla_keymap_channels (wmWindowManager *wm, ListBase *keymap)
        RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_collapse", PADMINUS, KM_PRESS, KM_CTRL, 0)->ptr, "all", 1);
 }
 
-static void nla_keymap_main (wmWindowManager *wm, ListBase *keymap)
+static void nla_keymap_main (wmWindowManager *wm, wmKeyMap *keymap)
 {
        wmKeymapItem *kmi;
        
@@ -284,10 +284,10 @@ static void nla_keymap_main (wmWindowManager *wm, ListBase *keymap)
 
 void nla_keymap(wmWindowManager *wm)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
        
        /* keymap for all regions */
-       keymap= WM_keymap_listbase(wm, "NLA Generic", SPACE_NLA, 0);
+       keymap= WM_keymap_find(wm, "NLA Generic", SPACE_NLA, 0);
        WM_keymap_add_item(keymap, "NLA_OT_properties", NKEY, KM_PRESS, 0, 0);
        
        /* channels */
@@ -297,11 +297,11 @@ void nla_keymap(wmWindowManager *wm)
         *
         * However, those operations which involve clicking on channels and/or the placement of them in the view are implemented here instead
         */
-       keymap= WM_keymap_listbase(wm, "NLA Channels", SPACE_NLA, 0);
+       keymap= WM_keymap_find(wm, "NLA Channels", SPACE_NLA, 0);
        nla_keymap_channels(wm, keymap);
        
        /* data */
-       keymap= WM_keymap_listbase(wm, "NLA Data", SPACE_NLA, 0);
+       keymap= WM_keymap_find(wm, "NLA Data", SPACE_NLA, 0);
        nla_keymap_main(wm, keymap);
 }
 
index 89d4e7cddf239a16a7f3f7ad3ad820087235fa62..06ee34a6573a87a37a0c81c59a1a1a842763ec8b 100644 (file)
@@ -208,15 +208,15 @@ static SpaceLink *nla_duplicate(SpaceLink *sl)
 /* add handlers, stuff you only do once or on area/region changes */
 static void nla_channel_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
        
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
        
        /* own keymap */
        // TODO: cannot use generic copy, need special NLA version
-       keymap= WM_keymap_listbase(wm, "NLA Channels", SPACE_NLA, 0);   /* XXX weak? */
+       keymap= WM_keymap_find(wm, "NLA Channels", SPACE_NLA, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
-       keymap= WM_keymap_listbase(wm, "NLA Generic", SPACE_NLA, 0);
+       keymap= WM_keymap_find(wm, "NLA Generic", SPACE_NLA, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 }
 
@@ -254,14 +254,14 @@ static void nla_channel_area_draw(const bContext *C, ARegion *ar)
 /* add handlers, stuff you only do once or on area/region changes */
 static void nla_main_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
        
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
        
        /* own keymap */
-       keymap= WM_keymap_listbase(wm, "NLA Data", SPACE_NLA, 0);       /* XXX weak? */
+       keymap= WM_keymap_find(wm, "NLA Data", SPACE_NLA, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
-       keymap= WM_keymap_listbase(wm, "NLA Generic", SPACE_NLA, 0);
+       keymap= WM_keymap_find(wm, "NLA Generic", SPACE_NLA, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 }
 
@@ -354,11 +354,11 @@ static void nla_header_area_draw(const bContext *C, ARegion *ar)
 /* add handlers, stuff you only do once or on area/region changes */
 static void nla_buttons_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
        
        ED_region_panels_init(wm, ar);
        
-       keymap= WM_keymap_listbase(wm, "NLA Generic", SPACE_NLA, 0);
+       keymap= WM_keymap_find(wm, "NLA Generic", SPACE_NLA, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 }
 
index 4c2fbf7b9dcc7aca7d1a652b7fa51cee19c757d4..f47e9aa2a6f6186c70784e307ffe7a6c66a2b1a7 100644 (file)
@@ -69,7 +69,7 @@ void node_operatortypes(void)
 
 void node_keymap(struct wmWindowManager *wm)
 {
-       ListBase *keymap= WM_keymap_listbase(wm, "Node", SPACE_NODE, 0);
+       wmKeyMap *keymap= WM_keymap_find(wm, "Node", SPACE_NODE, 0);
        
        /* mouse select in nodes used to be both keys, it's UI elements... */
        RNA_enum_set(WM_keymap_add_item(keymap, "NODE_OT_select", ACTIONMOUSE, KM_PRESS, 0, 0)->ptr, "select_type", NODE_SELECT_MOUSE);
index d3a445b18c072e0e88f530ba26ee99bc5624a91b..12a5f33e1193d8801d037cc42faf12dda695d83d 100644 (file)
@@ -245,12 +245,12 @@ static void node_channel_area_draw(const bContext *C, ARegion *ar)
 /* Initialise main area, setting handlers. */
 static void node_main_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
        
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
        
        /* own keymap */
-       keymap= WM_keymap_listbase(wm, "Node", SPACE_NODE, 0);  /* XXX weak? */
+       keymap= WM_keymap_find(wm, "Node", SPACE_NODE, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 }
 
index 2e11eb379b4905bf24fb0715dc54fb59f3a8a188..a35b91249dbdca3488e8e1ba774d15dca34abab2 100644 (file)
@@ -76,7 +76,7 @@ void outliner_operatortypes(void)
 
 void outliner_keymap(wmWindowManager *wm)
 {
-       ListBase *keymap= WM_keymap_listbase(wm, "Outliner", SPACE_OUTLINER, 0);
+       wmKeyMap *keymap= WM_keymap_find(wm, "Outliner", SPACE_OUTLINER, 0);
        
        RNA_boolean_set(WM_keymap_add_item(keymap, "OUTLINER_OT_item_activate", LEFTMOUSE, KM_PRESS, 0, 0)->ptr, "extend", 0);
        RNA_boolean_set(WM_keymap_add_item(keymap, "OUTLINER_OT_item_activate", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend", 1);
index 5058a167a29ef072a1a58f039357cb2d8508efa6..e7e6c2d0128dae91533001e421294d720c94e7fc 100644 (file)
 
 static void outliner_main_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
        
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
        
        /* own keymap */
-       keymap= WM_keymap_listbase(wm, "Outliner", SPACE_OUTLINER, 0);  /* XXX weak? */
+       keymap= WM_keymap_find(wm, "Outliner", SPACE_OUTLINER, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 }
 
index 270cc1ffd8fa0bcce85c2a1049446cd033c03879..0e6ea9cf4fd52a269aff67c909aa197f44ee1eae 100644 (file)
@@ -65,7 +65,7 @@ void script_operatortypes(void)
 
 void script_keymap(wmWindowManager *wm)
 {
-       ListBase *keymap= WM_keymap_listbase(wm, "Script", SPACE_SCRIPT, 0);
+       wmKeyMap *keymap= WM_keymap_find(wm, "Script", SPACE_SCRIPT, 0);
 
        /* TODO - this is just while we have no way to load a text datablock */
        RNA_string_set(WM_keymap_add_item(keymap, "SCRIPT_OT_python_file_run", PKEY, KM_PRESS, KM_CTRL|KM_SHIFT|KM_ALT, 0)->ptr, "path", "test.py");
index 99233cc5020286ea0f3db2e4734f2e10c3fcc322..a0e73082701637cc325e4400737b17125e2215d4 100644 (file)
@@ -133,12 +133,12 @@ static SpaceLink *script_duplicate(SpaceLink *sl)
 /* add handlers, stuff you only do once or on area/region changes */
 static void script_main_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
        
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy);
        
        /* own keymap */
-       keymap= WM_keymap_listbase(wm, "Script", SPACE_SCRIPT, 0);      /* XXX weak? */
+       keymap= WM_keymap_find(wm, "Script", SPACE_SCRIPT, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 }
 
index 74f22b86b75ce6d38d760bfaa21a4fcd75626152..ac125c10b2dc725a34dde88e56c4eb408e4b278a 100644 (file)
@@ -105,7 +105,7 @@ void sequencer_operatortypes(void)
 
 void sequencer_keymap(wmWindowManager *wm)
 {
-       ListBase *keymap= WM_keymap_listbase(wm, "Sequencer", SPACE_SEQ, 0);
+       wmKeyMap *keymap= WM_keymap_find(wm, "Sequencer", SPACE_SEQ, 0);
        wmKeymapItem *kmi;
        
        WM_keymap_add_item(keymap, "SEQUENCER_OT_properties", NKEY, KM_PRESS, 0, 0);
index 26ffd88ae674fcab58927f1e8d611b018de534b4..c2756b05946cf342ef087af4883e9c131a8f1c77 100644 (file)
@@ -185,12 +185,12 @@ static SpaceLink *sequencer_duplicate(SpaceLink *sl)
 /* add handlers, stuff you only do once or on area/region changes */
 static void sequencer_main_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
        
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
        
        /* own keymap */
-       keymap= WM_keymap_listbase(wm, "Sequencer", SPACE_SEQ, 0);      /* XXX weak? */
+       keymap= WM_keymap_find(wm, "Sequencer", SPACE_SEQ, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 }
 
index f8ef2b21ae7df01da1550e85f989c4cc92d62240..6713e19b6dedfca4ffdf73d7f1ba9dacd434c132 100644 (file)
@@ -142,12 +142,12 @@ static SpaceLink *sound_duplicate(SpaceLink *sl)
 /* add handlers, stuff you only do once or on area/region changes */
 static void sound_main_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
        
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
        
        /* own keymap */
-       keymap= WM_keymap_listbase(wm, "Sound", SPACE_SOUND, 0);        /* XXX weak? */
+       keymap= WM_keymap_find(wm, "Sound", SPACE_SOUND, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 }
 
index 1f919fc9cd763629b4e88aaa9d0dbef171306779..e068c1a70bb19550a3d10cc6bb815380ff8b4416 100644 (file)
@@ -208,7 +208,9 @@ static void text_operatortypes(void)
 
 static void text_keymap(struct wmWindowManager *wm)
 {
-       ListBase *keymap= WM_keymap_listbase(wm, "Text", SPACE_TEXT, 0);
+       wmKeyMap *keymap;
+       
+       keymap= WM_keymap_find(wm, "Text", SPACE_TEXT, 0);
        
        #ifdef __APPLE__
        RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", LEFTARROWKEY, KM_PRESS, KM_OSKEY, 0)->ptr, "type", LINE_BEGIN);
@@ -329,12 +331,12 @@ static int text_context(const bContext *C, const char *member, bContextDataResul
 /* add handlers, stuff you only do once or on area/region changes */
 static void text_main_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
        
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy);
        
        /* own keymap */
-       keymap= WM_keymap_listbase(wm, "Text", SPACE_TEXT, 0);  /* XXX weak? */
+       keymap= WM_keymap_find(wm, "Text", SPACE_TEXT, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 }
 
index 8f7486f81d955e99c9e07f4eb796892ce18ebf8a..0f05eb0149dc224915f91118fdf5ea2f86370aa3 100644 (file)
@@ -202,12 +202,12 @@ static void time_draw_keyframes(const bContext *C, SpaceTime *stime, ARegion *ar
 /* add handlers, stuff you only do once or on area/region changes */
 static void time_main_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
        
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
        
        /* own keymap */
-       keymap= WM_keymap_listbase(wm, "TimeLine", SPACE_TIME, 0);      /* XXX weak? */
+       keymap= WM_keymap_find(wm, "TimeLine", SPACE_TIME, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 }
 
index a833cca095c8d1a6bd30cb70451f0da74691992b..2b073f269bffb19ea4351b7129a6c6c2fcc917e5 100644 (file)
@@ -142,7 +142,7 @@ void time_operatortypes(void)
 
 void time_keymap(wmWindowManager *wm)
 {
-       ListBase *keymap= WM_keymap_listbase(wm, "TimeLine", SPACE_TIME, 0);
+       wmKeyMap *keymap= WM_keymap_find(wm, "TimeLine", SPACE_TIME, 0);
        
        WM_keymap_add_item(keymap, "TIME_OT_start_frame_set", SKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "TIME_OT_end_frame_set", EKEY, KM_PRESS, 0, 0);
index b5e5de928b5d484a90f20f4a968c5214e23bd212..15e12e73b49c9bc350565766a681493e2249f9ab 100644 (file)
@@ -275,101 +275,60 @@ static SpaceLink *view3d_duplicate(SpaceLink *sl)
        return (SpaceLink *)v3dn;
 }
 
-static void view3d_modal_keymaps(wmWindowManager *wm, ARegion *ar, int stype)
-{
-       RegionView3D *rv3d= ar->regiondata;
-       ListBase *keymap;
-       
-       /* copy last mode, then we can re-init the region maps */
-       rv3d->lastmode= stype;
-       
-       keymap= WM_keymap_listbase(wm, "Object Mode", 0, 0);
-       if(ELEM(stype, 0, NS_MODE_OBJECT))
-               WM_event_add_keymap_handler(&ar->handlers, keymap);
-       else
-               WM_event_remove_keymap_handler(&ar->handlers, keymap);
-       
-       keymap= WM_keymap_listbase(wm, "EditMesh", 0, 0);
-       if(stype==NS_EDITMODE_MESH)
-               WM_event_add_keymap_handler(&ar->handlers, keymap);
-       else
-               WM_event_remove_keymap_handler(&ar->handlers, keymap);
-       
-       keymap= WM_keymap_listbase(wm, "Curve", 0, 0);
-       if(stype==NS_EDITMODE_CURVE)
-               WM_event_add_keymap_handler(&ar->handlers, keymap);
-       else
-               WM_event_remove_keymap_handler(&ar->handlers, keymap);
-       
-       keymap= WM_keymap_listbase(wm, "Armature", 0, 0);
-       if(stype==NS_EDITMODE_ARMATURE)
-               WM_event_add_keymap_handler(&ar->handlers, keymap);
-       else
-               WM_event_remove_keymap_handler(&ar->handlers, keymap);
-               
-       keymap= WM_keymap_listbase(wm, "Pose", 0, 0);
-       if(stype==NS_MODE_POSE)
-               WM_event_add_keymap_handler(&ar->handlers, keymap);
-       else
-               WM_event_remove_keymap_handler(&ar->handlers, keymap);
-
-       keymap= WM_keymap_listbase(wm, "Metaball", 0, 0);
-       if(stype==NS_EDITMODE_MBALL)
-               WM_event_add_keymap_handler(&ar->handlers, keymap);
-       else
-               WM_event_remove_keymap_handler(&ar->handlers, keymap);
-       
-       keymap= WM_keymap_listbase(wm, "Lattice", 0, 0);
-       if(stype==NS_EDITMODE_LATTICE)
-               WM_event_add_keymap_handler(&ar->handlers, keymap);
-       else
-               WM_event_remove_keymap_handler(&ar->handlers, keymap);
-
-       /* armature sketching needs to take over mouse */
-       keymap= WM_keymap_listbase(wm, "Armature_Sketch", 0, 0);
-       if(stype==NS_EDITMODE_ARMATURE)
-               WM_event_add_keymap_handler_priority(&ar->handlers, keymap, 10);
-       else
-               WM_event_remove_keymap_handler(&ar->handlers, keymap);
-
-       keymap= WM_keymap_listbase(wm, "Particle", 0, 0);
-       if(stype==NS_MODE_PARTICLE)
-               WM_event_add_keymap_handler(&ar->handlers, keymap);
-       else
-               WM_event_remove_keymap_handler(&ar->handlers, keymap);
-
-       /* editfont keymap swallows all... */
-       keymap= WM_keymap_listbase(wm, "Font", 0, 0);
-       if(stype==NS_EDITMODE_TEXT)
-               WM_event_add_keymap_handler_priority(&ar->handlers, keymap, 10);
-       else
-               WM_event_remove_keymap_handler(&ar->handlers, keymap);
-}
-
 /* add handlers, stuff you only do once or on area/region changes */
 static void view3d_main_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       RegionView3D *rv3d= ar->regiondata;
-       ListBase *keymap;
+       wmKeyMap *keymap;
        
        /* own keymap */
-       keymap= WM_keymap_listbase(wm, "View3D Generic", SPACE_VIEW3D, 0);
+       keymap= WM_keymap_find(wm, "View3D Generic", SPACE_VIEW3D, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
-       keymap= WM_keymap_listbase(wm, "View3D", SPACE_VIEW3D, 0);
+
+       keymap= WM_keymap_find(wm, "View3D", SPACE_VIEW3D, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
        
        /* object ops. */
-       keymap= WM_keymap_listbase(wm, "Object Non-modal", 0, 0);
+       keymap= WM_keymap_find(wm, "Object Non-modal", 0, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
        
        /* pose is not modal, operator poll checks for this */
-       keymap= WM_keymap_listbase(wm, "Pose", 0, 0);
+       keymap= WM_keymap_find(wm, "Pose", 0, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
        
-       /* modal ops keymaps */
-       view3d_modal_keymaps(wm, ar, rv3d->lastmode);
        /* operator poll checks for modes */
-       keymap= WM_keymap_listbase(wm, "ImagePaint", 0, 0);
+       keymap= WM_keymap_find(wm, "ImagePaint", 0, 0);
+       WM_event_add_keymap_handler(&ar->handlers, keymap);
+
+       keymap= WM_keymap_find(wm, "Object Mode", 0, 0);
+       WM_event_add_keymap_handler(&ar->handlers, keymap);
+       
+       keymap= WM_keymap_find(wm, "EditMesh", 0, 0);
+       WM_event_add_keymap_handler(&ar->handlers, keymap);
+       
+       keymap= WM_keymap_find(wm, "Curve", 0, 0);
+       WM_event_add_keymap_handler(&ar->handlers, keymap);
+       
+       keymap= WM_keymap_find(wm, "Armature", 0, 0);
+       WM_event_add_keymap_handler(&ar->handlers, keymap);
+
+       keymap= WM_keymap_find(wm, "Pose", 0, 0);
+       WM_event_add_keymap_handler(&ar->handlers, keymap);
+
+       keymap= WM_keymap_find(wm, "Metaball", 0, 0);
+       WM_event_add_keymap_handler(&ar->handlers, keymap);
+       
+       keymap= WM_keymap_find(wm, "Lattice", 0, 0);
+       WM_event_add_keymap_handler(&ar->handlers, keymap);
+
+       /* armature sketching needs to take over mouse */
+       keymap= WM_keymap_find(wm, "Armature_Sketch", 0, 0);
+       WM_event_add_keymap_handler(&ar->handlers, keymap);
+
+       keymap= WM_keymap_find(wm, "Particle", 0, 0);
+       WM_event_add_keymap_handler(&ar->handlers, keymap);
+
+       /* editfont keymap swallows all... */
+       keymap= WM_keymap_find(wm, "Font", 0, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 }
 
@@ -444,7 +403,6 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn)
                                        ED_region_tag_redraw(ar);
                                        break;
                                case ND_MODE:
-                                       view3d_modal_keymaps(wmn->wm, ar, wmn->subtype);
                                        ED_region_tag_redraw(ar);
                                        break;
                        }
@@ -516,7 +474,7 @@ static void view3d_main_area_cursor(wmWindow *win, ScrArea *sa, ARegion *ar)
 /* add handlers, stuff you only do once or on area/region changes */
 static void view3d_header_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap= WM_keymap_listbase(wm, "View3D Generic", SPACE_VIEW3D, 0);
+       wmKeyMap *keymap= WM_keymap_find(wm, "View3D Generic", SPACE_VIEW3D, 0);
        
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
@@ -552,11 +510,11 @@ static void view3d_header_area_listener(ARegion *ar, wmNotifier *wmn)
 /* add handlers, stuff you only do once or on area/region changes */
 static void view3d_buttons_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
 
        ED_region_panels_init(wm, ar);
        
-       keymap= WM_keymap_listbase(wm, "View3D Generic", SPACE_VIEW3D, 0);
+       keymap= WM_keymap_find(wm, "View3D Generic", SPACE_VIEW3D, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 }
 
@@ -618,16 +576,14 @@ static void view3d_buttons_area_listener(ARegion *ar, wmNotifier *wmn)
 /* add handlers, stuff you only do once or on area/region changes */
 static void view3d_tools_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
        
        ED_region_panels_init(wm, ar);
 
-       keymap= WM_keymap_listbase(wm, "View3D Generic", SPACE_VIEW3D, 0);
+       keymap= WM_keymap_find(wm, "View3D Generic", SPACE_VIEW3D, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 }
 
-
-
 static void view3d_tools_area_draw(const bContext *C, ARegion *ar)
 {
        ED_region_panels(C, ar, 1, CTX_data_mode_string(C), -1);
index e179809adc908cce3a043951ce35dae015019241..9ffdef478b3390fc94428a4dfc3c8f1a00f55fb8 100644 (file)
@@ -103,14 +103,16 @@ void view3d_operatortypes(void)
 
 void view3d_keymap(wmWindowManager *wm)
 {
-       ListBase *keymap= WM_keymap_listbase(wm, "View3D Generic", SPACE_VIEW3D, 0);
+       wmKeyMap *keymap;
        wmKeymapItem *km;
        
+       keymap= WM_keymap_find(wm, "View3D Generic", SPACE_VIEW3D, 0);
+       
        WM_keymap_add_item(keymap, "VIEW3D_OT_properties", NKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "VIEW3D_OT_toolbar", TKEY, KM_PRESS, 0, 0);
        
        /* only for region 3D window */
-       keymap= WM_keymap_listbase(wm, "View3D", SPACE_VIEW3D, 0);
+       keymap= WM_keymap_find(wm, "View3D", SPACE_VIEW3D, 0);
        
        /* paint poll checks mode */
        WM_keymap_verify_item(keymap, "PAINT_OT_vertex_paint", LEFTMOUSE, KM_PRESS, 0, 0);
index 8d7e8f20ad557b65c5fa5c0ddd9f038949c47b72..7dfae33bc398af1f4d96f4397033ff213af11f92 100644 (file)
@@ -621,7 +621,7 @@ void transform_operatortypes(void)
        WM_operatortype_append(TFM_OT_select_orientation);
 }
 
-void transform_keymap_for_space(struct wmWindowManager *wm, struct ListBase *keymap, int spaceid)
+void transform_keymap_for_space(struct wmWindowManager *wm, struct wmKeyMap *keymap, int spaceid)
 {
        wmKeymapItem *km;
        
index cb05109d984550451e85c26ddcfa31af4bbc7b48..611eee00d79760e26cdde5bd46b5e8553666f28e 100644 (file)
@@ -3072,7 +3072,10 @@ void ED_operatortypes_uvedit(void)
 
 void ED_keymap_uvedit(wmWindowManager *wm)
 {
-       ListBase *keymap= WM_keymap_listbase(wm, "UVEdit", 0, 0);
+       wmKeyMap *keymap;
+       
+       keymap= WM_keymap_find(wm, "UVEdit", 0, 0);
+       keymap->poll= ED_operator_uvedit;
        
        /* pick selection */
        WM_keymap_add_item(keymap, "UV_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
index e221524eac2bedf188b650498001c225c63c4e5a..d42ccd62694959c3fd9489597530b1078b367ebb 100644 (file)
@@ -89,9 +89,7 @@ typedef struct RegionView3D {
        float camdx, camdy;                             /* camera view offsets, 1.0 = viewplane moves entire width/height */
        float pixsize;
        float ofs[3];
-       short camzoom, viewbut;
-       
-       int lastmode;                                   /* for modal keymap switching, int because it stores notifier code */
+       short camzoom, viewbut, pad[2];
        
        short rflag, viewlock;
        short persp;
index 4274cb7ebc03fe0ebb73a2614fb9087ee7da33ac..00fbc04844c5478f8fa0408e5a6bb66f61343b9d 100644 (file)
@@ -265,6 +265,9 @@ typedef struct wmKeyMap {
        short pad;
        
        void *items;            /* struct EnumPropertyItem for now */
+
+       /* verify if the keymap is enabled in the current context */
+       int (*poll)(struct bContext *);
 } wmKeyMap;
 
 
index 6610c5d8931a37870b718c2b2a23034b166a1b8d..b2edbc324eaa6133cef1dfc1a8b39e90d5fad51e 100644 (file)
@@ -83,12 +83,12 @@ void                WM_paint_cursor_end(struct wmWindowManager *wm, void *handle);
 
                        /* keymap */
 void           WM_keymap_init          (struct bContext *C);
-wmKeymapItem *WM_keymap_verify_item(ListBase *lb, char *idname, short type, 
+wmKeymapItem *WM_keymap_verify_item(wmKeyMap *keymap, char *idname, short type, 
                                                                 short val, int modifier, short keymodifier);
-wmKeymapItem *WM_keymap_add_item(ListBase *lb, char *idname, short type, 
+wmKeymapItem *WM_keymap_add_item(wmKeyMap *keymap, char *idname, short type, 
                                                                 short val, int modifier, short keymodifier);
-void           WM_keymap_tweak (ListBase *lb, short type, short val, int modifier, short keymodifier);
-ListBase       *WM_keymap_listbase     (struct wmWindowManager *wm, const char *nameid, 
+void           WM_keymap_tweak (wmKeyMap *keymap, short type, short val, int modifier, short keymodifier);
+wmKeyMap       *WM_keymap_find (struct wmWindowManager *wm, const char *nameid,
                                                                 short spaceid, short regionid);
 
 wmKeyMap       *WM_modalkeymap_add(struct wmWindowManager *wm, const char *nameid, struct EnumPropertyItem *items);
@@ -104,13 +104,13 @@ void              WM_key_event_operator_change(const struct bContext *C, const char *opname,
 
                        /* handlers */
 
-struct wmEventHandler *WM_event_add_keymap_handler(ListBase *handlers, ListBase *keymap);
+struct wmEventHandler *WM_event_add_keymap_handler(ListBase *handlers, wmKeyMap *keymap);
                                                /* boundbox, optional subwindow boundbox for offset */
-struct wmEventHandler *WM_event_add_keymap_handler_bb(ListBase *handlers, ListBase *keymap, rcti *bb, rcti *swinbb);
+struct wmEventHandler *WM_event_add_keymap_handler_bb(ListBase *handlers, wmKeyMap *keymap, rcti *bb, rcti *swinbb);
                                                /* priority not implemented, it adds in begin */
-struct wmEventHandler *WM_event_add_keymap_handler_priority(ListBase *handlers, ListBase *keymap, int priority);
+struct wmEventHandler *WM_event_add_keymap_handler_priority(ListBase *handlers, wmKeyMap *keymap, int priority);
 
-void           WM_event_remove_keymap_handler(ListBase *handlers, ListBase *keymap);
+void           WM_event_remove_keymap_handler(ListBase *handlers, wmKeyMap *keymap);
 
 struct wmEventHandler *WM_event_add_ui_handler(const struct bContext *C, ListBase *handlers,
                        int (*func)(struct bContext *C, struct wmEvent *event, void *userdata),
index 9d5bd13ea259ed307a8ff55f54ae79959ccead1b..22c5788b0ae13cd748c864d74474072377d0a502 100644 (file)
@@ -1014,16 +1014,19 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
                                action= WM_HANDLER_BREAK;
 
                        if(handler->keymap) {
+                               wmKeyMap *keymap= handler->keymap;
                                wmKeymapItem *kmi;
                                
-                               for(kmi= handler->keymap->first; kmi; kmi= kmi->next) {
-                                       if(wm_eventmatch(event, kmi)) {
-                                               
-                                               event->keymap_idname= kmi->idname;      /* weak, but allows interactive callback to not use rawkey */
-                                               
-                                               action= wm_handler_operator_call(C, handlers, handler, event, kmi->ptr);
-                                               if(action==WM_HANDLER_BREAK)  /* not wm_event_always_pass(event) here, it denotes removed handler */
-                                                       break;
+                               if(!keymap->poll || keymap->poll(C)) {
+                                       for(kmi= keymap->keymap.first; kmi; kmi= kmi->next) {
+                                               if(wm_eventmatch(event, kmi)) {
+                                                       
+                                                       event->keymap_idname= kmi->idname;      /* weak, but allows interactive callback to not use rawkey */
+                                                       
+                                                       action= wm_handler_operator_call(C, handlers, handler, event, kmi->ptr);
+                                                       if(action==WM_HANDLER_BREAK)  /* not wm_event_always_pass(event) here, it denotes removed handler */
+                                                               break;
+                                               }
                                        }
                                }
                        }
@@ -1304,10 +1307,15 @@ wmEventHandler *WM_event_add_modal_handler(bContext *C, ListBase *handlers, wmOp
        return handler;
 }
 
-wmEventHandler *WM_event_add_keymap_handler(ListBase *handlers, ListBase *keymap)
+wmEventHandler *WM_event_add_keymap_handler(ListBase *handlers, wmKeyMap *keymap)
 {
        wmEventHandler *handler;
 
+       if(!keymap) {
+               printf("WM_event_add_keymap_handler called with NULL keymap\n");
+               return NULL;
+       }
+
        /* only allow same keymap once */
        for(handler= handlers->first; handler; handler= handler->next)
                if(handler->keymap==keymap)
@@ -1321,7 +1329,7 @@ wmEventHandler *WM_event_add_keymap_handler(ListBase *handlers, ListBase *keymap
 }
 
 /* priorities not implemented yet, for time being just insert in begin of list */
-wmEventHandler *WM_event_add_keymap_handler_priority(ListBase *handlers, ListBase *keymap, int priority)
+wmEventHandler *WM_event_add_keymap_handler_priority(ListBase *handlers, wmKeyMap *keymap, int priority)
 {
        wmEventHandler *handler;
        
@@ -1334,7 +1342,7 @@ wmEventHandler *WM_event_add_keymap_handler_priority(ListBase *handlers, ListBas
        return handler;
 }
 
-wmEventHandler *WM_event_add_keymap_handler_bb(ListBase *handlers, ListBase *keymap, rcti *bblocal, rcti *bbwin)
+wmEventHandler *WM_event_add_keymap_handler_bb(ListBase *handlers, wmKeyMap *keymap, rcti *bblocal, rcti *bbwin)
 {
        wmEventHandler *handler= WM_event_add_keymap_handler(handlers, keymap);
        
@@ -1345,7 +1353,7 @@ wmEventHandler *WM_event_add_keymap_handler_bb(ListBase *handlers, ListBase *key
        return handler;
 }
 
-void WM_event_remove_keymap_handler(ListBase *handlers, ListBase *keymap)
+void WM_event_remove_keymap_handler(ListBase *handlers, wmKeyMap *keymap)
 {
        wmEventHandler *handler;
        
index 5566aeba260ef974491a8c40a1936262b655a9de..7d25fb8172efe03d2f02ba12254ea859e4764853 100644 (file)
@@ -96,17 +96,17 @@ static void keymap_properties_set(wmKeymapItem *kmi)
 }
 
 /* if item was added, then bail out */
-wmKeymapItem *WM_keymap_verify_item(ListBase *lb, char *idname, short type, short val, int modifier, short keymodifier)
+wmKeymapItem *WM_keymap_verify_item(wmKeyMap *keymap, char *idname, short type, short val, int modifier, short keymodifier)
 {
        wmKeymapItem *kmi;
        
-       for(kmi= lb->first; kmi; kmi= kmi->next)
+       for(kmi= keymap->keymap.first; kmi; kmi= kmi->next)
                if(strncmp(kmi->idname, idname, OP_MAX_TYPENAME)==0)
                        break;
        if(kmi==NULL) {
                kmi= MEM_callocN(sizeof(wmKeymapItem), "keymap entry");
                
-               BLI_addtail(lb, kmi);
+               BLI_addtail(&keymap->keymap, kmi);
                BLI_strncpy(kmi->idname, idname, OP_MAX_TYPENAME);
                
                keymap_event_set(kmi, type, val, modifier, keymodifier);
@@ -116,11 +116,11 @@ wmKeymapItem *WM_keymap_verify_item(ListBase *lb, char *idname, short type, shor
 }
 
 /* always add item */
-wmKeymapItem *WM_keymap_add_item(ListBase *lb, char *idname, short type, short val, int modifier, short keymodifier)
+wmKeymapItem *WM_keymap_add_item(wmKeyMap *keymap, char *idname, short type, short val, int modifier, short keymodifier)
 {
        wmKeymapItem *kmi= MEM_callocN(sizeof(wmKeymapItem), "keymap entry");
        
-       BLI_addtail(lb, kmi);
+       BLI_addtail(&keymap->keymap, kmi);
        BLI_strncpy(kmi->idname, idname, OP_MAX_TYPENAME);
 
        keymap_event_set(kmi, type, val, modifier, keymodifier);
@@ -134,14 +134,14 @@ wmKeymapItem *WM_keymap_add_item(ListBase *lb, char *idname, short type, short v
    space/region ids are same as DNA_space_types.h */
 /* gets free'd in wm.c */
 
-static wmKeyMap *wm_keymap_add(wmWindowManager *wm, const char *nameid, short spaceid, short regionid)
+wmKeyMap *WM_keymap_find(wmWindowManager *wm, const char *nameid, short spaceid, short regionid)
 {
        wmKeyMap *km;
        
        for(km= wm->keymaps.first; km; km= km->next)
                if(km->spaceid==spaceid && km->regionid==regionid)
                        if(0==strncmp(nameid, km->nameid, KMAP_MAX_NAME))
-                               break;
+                               return km;
        
        if(km==NULL) {
                km= MEM_callocN(sizeof(struct wmKeyMap), "keymap list");
@@ -154,19 +154,13 @@ static wmKeyMap *wm_keymap_add(wmWindowManager *wm, const char *nameid, short sp
        return km;
 }
 
-ListBase *WM_keymap_listbase(wmWindowManager *wm, const char *nameid, short spaceid, short regionid)
-{
-       wmKeyMap *km= wm_keymap_add(wm, nameid, spaceid, regionid);
-       return &km->keymap;
-}
-
 /* ****************** modal keymaps ************ */
 
 /* modal maps get linked to a running operator, and filter the keys before sending to modal() callback */
 
 wmKeyMap *WM_modalkeymap_add(wmWindowManager *wm, const char *nameid, EnumPropertyItem *items)
 {
-       wmKeyMap *km= wm_keymap_add(wm, nameid, 0, 0);
+       wmKeyMap *km= WM_keymap_find(wm, nameid, 0, 0);
        km->is_modal= 1;
        km->items= items;
        
@@ -242,15 +236,18 @@ static char *wm_keymap_item_to_string(wmKeymapItem *kmi, char *str, int len)
        return str;
 }
 
-static wmKeymapItem *wm_keymap_item_find_handlers(ListBase *handlers, const char *opname, int opcontext, IDProperty *properties, int compare_props)
+static wmKeymapItem *wm_keymap_item_find_handlers(const bContext *C, ListBase *handlers, const char *opname, int opcontext, IDProperty *properties, int compare_props)
 {
        wmEventHandler *handler;
+       wmKeyMap *keymap;
        wmKeymapItem *kmi;
 
        /* find keymap item in handlers */
        for(handler=handlers->first; handler; handler=handler->next) {
-               if(handler->keymap) {
-                       for(kmi=handler->keymap->first; kmi; kmi=kmi->next) {
+               keymap= handler->keymap;
+
+               if(keymap && (!keymap->poll || keymap->poll((bContext*)C))) {
+                       for(kmi=keymap->keymap.first; kmi; kmi=kmi->next) {
                                if(strcmp(kmi->idname, opname) == 0 && WM_key_event_string(kmi->type)[0]) {
                                        if(compare_props) {
                                                if(kmi->ptr && IDP_EqualsProperties(properties, kmi->ptr->data))
@@ -272,11 +269,11 @@ static wmKeymapItem *wm_keymap_item_find(const bContext *C, const char *opname,
 
        /* look into multiple handler lists to find the item */
        if(CTX_wm_window(C))
-               found= wm_keymap_item_find_handlers(&CTX_wm_window(C)->handlers, opname, opcontext, properties, compare_props);
+               found= wm_keymap_item_find_handlers(C, &CTX_wm_window(C)->handlers, opname, opcontext, properties, compare_props);
        
 
        if(CTX_wm_area(C) && found==NULL)
-               found= wm_keymap_item_find_handlers(&CTX_wm_area(C)->handlers, opname, opcontext, properties, compare_props);
+               found= wm_keymap_item_find_handlers(C, &CTX_wm_area(C)->handlers, opname, opcontext, properties, compare_props);
 
        if(found==NULL) {
                if(ELEM(opcontext, WM_OP_EXEC_REGION_WIN, WM_OP_INVOKE_REGION_WIN)) {
@@ -287,12 +284,12 @@ static wmKeymapItem *wm_keymap_item_find(const bContext *C, const char *opname,
                                                break;
 
                                if(ar)
-                                       found= wm_keymap_item_find_handlers(&ar->handlers, opname, opcontext, properties, compare_props);
+                                       found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props);
                        }
                }
                else {
                        if(CTX_wm_region(C))
-                               found= wm_keymap_item_find_handlers(&CTX_wm_region(C)->handlers, opname, opcontext, properties, compare_props);
+                               found= wm_keymap_item_find_handlers(C, &CTX_wm_region(C)->handlers, opname, opcontext, properties, compare_props);
                }
        }
        
index 86a02e2731a0e5e1fd2b25147dfba23fbf7349a5..2e2d463bbd92ddb751afb7fb54ea74a321f8e2fe 100644 (file)
@@ -2098,7 +2098,7 @@ void wm_operatortype_init(void)
 /* default keymap for windows and screens, only call once per WM */
 void wm_window_keymap(wmWindowManager *wm)
 {
-       ListBase *keymap= WM_keymap_listbase(wm, "Window", 0, 0);
+       wmKeyMap *keymap= WM_keymap_find(wm, "Window", 0, 0);
        
        /* items to make WM work */
        WM_keymap_verify_item(keymap, "WM_OT_jobs_timer", TIMERJOBS, KM_ANY, KM_ANY, 0);
index d70516ef02efe370b83cf2d156d75e0fc022217c..cbb5bed4c00422c93318d3365ec91bb3d6d6d9dd 100644 (file)
@@ -331,7 +331,7 @@ static void wm_window_add_ghostwindow(wmWindowManager *wm, char *title, wmWindow
 /* called in wm_check, also inits stuff after file read */
 void wm_window_add_ghostwindows(wmWindowManager *wm)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
        wmWindow *win;
        
        /* no commandline prefsize? then we set this */
@@ -367,10 +367,10 @@ void wm_window_add_ghostwindows(wmWindowManager *wm)
                   win->eventstate= MEM_callocN(sizeof(wmEvent), "window event state");
                
                /* add keymap handlers (1 handler for all keys in map!) */
-               keymap= WM_keymap_listbase(wm, "Window", 0, 0);
+               keymap= WM_keymap_find(wm, "Window", 0, 0);
                WM_event_add_keymap_handler(&win->handlers, keymap);
                
-               keymap= WM_keymap_listbase(wm, "Screen", 0, 0);
+               keymap= WM_keymap_find(wm, "Screen", 0, 0);
                WM_event_add_keymap_handler(&win->handlers, keymap);
                
                wm_window_title(wm, win);
index 9a3bba9af1d69f3880acadfbd268deac66c0b6b8..4360e49e37125f75ce89046ad67e8d14c857a8db 100644 (file)
@@ -43,7 +43,7 @@ typedef struct wmEventHandler {
        int type, flag;                         /* type default=0, rest is custom */
        
        /* keymap handler */
-       ListBase *keymap;                       /* pointer to builtin/custom keymaps */
+       wmKeyMap *keymap;                       /* pointer to builtin/custom keymaps */
        
        rcti *bblocal, *bbwin;          /* optional local and windowspace bb */