diff options
Diffstat (limited to 'source/blender')
107 files changed, 1436 insertions, 600 deletions
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index b983c6f7dc4..7c62c8c6dd4 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -44,6 +44,7 @@ struct SpaceType; struct wmNotifier; struct wmWindow; struct wmWindowManager; +struct wmKeyConfig; struct uiLayout; struct uiMenuItem; @@ -81,7 +82,7 @@ typedef struct SpaceType { /* register operator types on startup */ void (*operatortypes)(void); /* add default items to WM keymap */ - void (*keymap)(struct wmWindowManager *); + void (*keymap)(struct wmKeyConfig *); /* return context data */ int (*context)(const struct bContext *, const char*, struct bContextDataResult *); @@ -122,7 +123,7 @@ typedef struct ARegionType { /* register operator types on startup */ void (*operatortypes)(void); /* add own items to keymap */ - void (*keymap)(struct wmWindowManager *); + void (*keymap)(struct wmKeyConfig *); /* allows default cursor per region */ void (*cursor)(struct wmWindow *, struct ScrArea *, struct ARegion *ar); diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index f261b020717..2df5b7c173c 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -74,6 +74,7 @@ #include "BKE_displist.h" #include "BKE_font.h" #include "BKE_global.h" +#include "BKE_idprop.h" #include "BKE_library.h" #include "BKE_ipo.h" #include "BKE_main.h" @@ -406,10 +407,26 @@ static int handle_subversion_warning(Main *main) void BKE_userdef_free(void) { + wmKeyMap *km; + wmKeyMapItem *kmi; + + for(km=U.keymaps.first; km; km=km->next) { + for(kmi=km->items.first; kmi; kmi=kmi->next) { + if(kmi->properties) { + IDP_FreeProperty(kmi->properties); + MEM_freeN(kmi->properties); + } + if(kmi->ptr) + MEM_freeN(kmi->ptr); + } + + BLI_freelistN(&km->items); + } BLI_freelistN(&U.uistyles); BLI_freelistN(&U.uifonts); BLI_freelistN(&U.themes); + BLI_freelistN(&U.keymaps); } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index ae18d7cac01..f2bf8b19bc6 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -4446,11 +4446,13 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm) } wm->operators.first= wm->operators.last= NULL; - wm->keymaps.first= wm->keymaps.last= NULL; wm->paintcursors.first= wm->paintcursors.last= NULL; wm->queue.first= wm->queue.last= NULL; BKE_reports_init(&wm->reports, RPT_STORE); + wm->keyconfigs.first= wm->keyconfigs.last= NULL; + wm->defaultconf= NULL; + wm->jobs.first= wm->jobs.last= NULL; wm->windrawable= NULL; @@ -5276,6 +5278,33 @@ static char *dataname(short id_code) } +static BHead *read_data_into_oldnewmap(FileData *fd, BHead *bhead, char *allocname) +{ + bhead = blo_nextbhead(fd, bhead); + + while(bhead && bhead->code==DATA) { + void *data; +#if 0 + /* XXX DUMB DEBUGGING OPTION TO GIVE NAMES for guarded malloc errors */ + short *sp= fd->filesdna->structs[bhead->SDNAnr]; + char *allocname = fd->filesdna->types[ sp[0] ]; + char *tmp= malloc(100); + + strcpy(tmp, allocname); + data= read_struct(fd, bhead, tmp); +#endif + data= read_struct(fd, bhead, allocname); + + if (data) { + oldnewmap_insert(fd->datamap, bhead->old, data, 0); + } + + bhead = blo_nextbhead(fd, bhead); + } + + return bhead; +} + static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, int flag, ID **id_r) { /* this routine reads a libblock and its direct data. Use link functions @@ -5317,32 +5346,11 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, int flag, ID return blo_nextbhead(fd, bhead); } - bhead = blo_nextbhead(fd, bhead); - /* need a name for the mallocN, just for debugging and sane prints on leaks */ allocname= dataname(GS(id->name)); - /* read all data */ - - while(bhead && bhead->code==DATA) { - void *data; -#if 0 - /* XXX DUMB DEBUGGING OPTION TO GIVE NAMES for guarded malloc errors */ - short *sp= fd->filesdna->structs[bhead->SDNAnr]; - char *allocname = fd->filesdna->types[ sp[0] ]; - char *tmp= malloc(100); - - strcpy(tmp, allocname); - data= read_struct(fd, bhead, tmp); -#endif - data= read_struct(fd, bhead, allocname); - - if (data) { - oldnewmap_insert(fd->datamap, bhead->old, data, 0); - } - - bhead = blo_nextbhead(fd, bhead); - } + /* read all data into fd->datamap */ + bhead= read_data_into_oldnewmap(fd, bhead, allocname); /* init pointers direct data */ switch( GS(id->name) ) { @@ -9975,23 +9983,39 @@ static void lib_link_all(FileData *fd, Main *main) static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead) { - Link *link; + UserDef *user; + wmKeyMap *keymap; + wmKeyMapItem *kmi; - bfd->user= read_struct(fd, bhead, "user def"); - bfd->user->themes.first= bfd->user->themes.last= NULL; - // XXX - bfd->user->uifonts.first= bfd->user->uifonts.last= NULL; - bfd->user->uistyles.first= bfd->user->uistyles.last= NULL; + bfd->user= user= read_struct(fd, bhead, "user def"); - bhead = blo_nextbhead(fd, bhead); + /* read all data into fd->datamap */ + bhead= read_data_into_oldnewmap(fd, bhead, "user def"); - /* read all attached data */ - while(bhead && bhead->code==DATA) { - link= read_struct(fd, bhead, "user def data"); - BLI_addtail(&bfd->user->themes, link); - bhead = blo_nextbhead(fd, bhead); + link_list(fd, &user->themes); + link_list(fd, &user->keymaps); + + for(keymap=user->keymaps.first; keymap; keymap=keymap->next) { + keymap->modal_items= NULL; + keymap->poll= NULL; + + link_list(fd, &keymap->items); + for(kmi=keymap->items.first; kmi; kmi=kmi->next) { + kmi->properties= newdataadr(fd, kmi->properties); + if(kmi->properties) + IDP_DirectLinkProperty(kmi->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); + kmi->ptr= NULL; + } } + // XXX + user->uifonts.first= user->uifonts.last= NULL; + user->uistyles.first= user->uistyles.last= NULL; + + /* free fd->datamap again */ + oldnewmap_free_unused(fd->datamap); + oldnewmap_clear(fd->datamap); + return bhead; } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 25cbd4b65e7..e3d061d8e4b 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -537,13 +537,23 @@ static void write_renderinfo(WriteData *wd, Main *mainvar) /* for renderdeamon static void write_userdef(WriteData *wd) { bTheme *btheme; + wmKeyMap *keymap; + wmKeyMapItem *kmi; writestruct(wd, USER, "UserDef", 1, &U); - btheme= U.themes.first; - while(btheme) { + for(btheme= U.themes.first; btheme; btheme=btheme->next) writestruct(wd, DATA, "bTheme", 1, btheme); - btheme= btheme->next; + + for(keymap= U.keymaps.first; keymap; keymap=keymap->next) { + writestruct(wd, DATA, "wmKeyMap", 1, keymap); + + for(kmi=keymap->items.first; kmi; kmi=kmi->next) { + writestruct(wd, DATA, "wmKeyMapItem", 1, kmi); + + if(kmi->properties) + IDP_WriteProperty(kmi->properties, wd); + } } } diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index 83f5fca5af5..7ee591f8cab 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -1687,9 +1687,9 @@ void ED_operatortypes_animchannels(void) WM_operatortype_append(ANIM_OT_channels_visibility_toggle); } -void ED_keymap_animchannels(wmWindowManager *wm) +void ED_keymap_animchannels(wmKeyConfig *keyconf) { - wmKeyMap *keymap = WM_keymap_find(wm, "Animation_Channels", 0, 0); + wmKeyMap *keymap = WM_keymap_find(keyconf, "Animation_Channels", 0, 0); /* selection */ /* click-select */ diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 6c44086af41..f4ecb9d5def 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -990,9 +990,9 @@ void ED_operatortypes_marker(void) } /* called in screen_ops.c:ED_keymap_screen() */ -void ED_marker_keymap(wmWindowManager *wm) +void ED_marker_keymap(wmKeyConfig *keyconf) { - wmKeyMap *keymap= WM_keymap_find(wm, "Markers", 0, 0); + wmKeyMap *keymap= WM_keymap_find(keyconf, "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); diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c index 83b2e2688c9..35eac6d23f1 100644 --- a/source/blender/editors/animation/anim_ops.c +++ b/source/blender/editors/animation/anim_ops.c @@ -416,9 +416,9 @@ void ED_operatortypes_anim(void) WM_operatortype_append(ANIM_OT_keying_set_path_remove); } -void ED_keymap_anim(wmWindowManager *wm) +void ED_keymap_anim(wmKeyConfig *keyconf) { - wmKeyMap *keymap= WM_keymap_find(wm, "Animation", 0, 0); + wmKeyMap *keymap= WM_keymap_find(keyconf, "Animation", 0, 0); /* frame management */ /* NOTE: 'ACTIONMOUSE' not 'LEFTMOUSE', as user may have swapped mouse-buttons */ diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index d465c1f8c9a..2bf414ef969 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -205,13 +205,13 @@ void ED_operatortypes_armature(void) WM_operatortype_append(ARMATURE_OT_test); // XXX temp test for context iterators... to be removed } -void ED_keymap_armature(wmWindowManager *wm) +void ED_keymap_armature(wmKeyConfig *keyconf) { wmKeyMap *keymap; - wmKeymapItem *kmi; + wmKeyMapItem *kmi; /* Armature ------------------------ */ - keymap= WM_keymap_find(wm, "Armature", 0, 0); + keymap= WM_keymap_find(keyconf, "Armature", 0, 0); keymap->poll= ED_operator_editarmature; /* only set in editmode armature, by space_view3d listener */ @@ -297,7 +297,7 @@ void ED_keymap_armature(wmWindowManager *wm) /* Pose ------------------------ */ /* only set in posemode, by space_view3d listener */ - keymap= WM_keymap_find(wm, "Pose", 0, 0); + keymap= WM_keymap_find(keyconf, "Pose", 0, 0); keymap->poll= ED_operator_posemode; // XXX: set parent is object-based operator, but it should also be available here... diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c index 77c5ed1de2c..a71ff8347e8 100644 --- a/source/blender/editors/curve/curve_ops.c +++ b/source/blender/editors/curve/curve_ops.c @@ -161,11 +161,11 @@ void ED_operatortypes_curve(void) WM_operatortype_append(CURVE_OT_specials_menu); } -void ED_keymap_curve(wmWindowManager *wm) +void ED_keymap_curve(wmKeyConfig *keyconf) { wmKeyMap *keymap; - keymap= WM_keymap_find(wm, "Font", 0, 0); + keymap= WM_keymap_find(keyconf, "Font", 0, 0); keymap->poll= ED_operator_editfont; /* only set in editmode font, by space_view3d listener */ @@ -215,7 +215,7 @@ 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_find(wm, "Curve", 0, 0); + keymap= WM_keymap_find(keyconf, "Curve", 0, 0); keymap->poll= ED_operator_editsurfcurve; WM_keymap_add_item(keymap, "OBJECT_OT_curve_add", AKEY, KM_PRESS, KM_SHIFT, 0); diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c index d311b39b9a3..6237e193a13 100644 --- a/source/blender/editors/gpencil/gpencil_ops.c +++ b/source/blender/editors/gpencil/gpencil_ops.c @@ -45,10 +45,10 @@ /* ****************************************** */ /* Generic Editing Keymap */ -void ED_keymap_gpencil(wmWindowManager *wm) +void ED_keymap_gpencil(wmKeyConfig *keyconf) { - wmKeyMap *keymap= WM_keymap_find(wm, "Grease Pencil", 0, 0); - wmKeymapItem *kmi; + wmKeyMap *keymap= WM_keymap_find(keyconf, "Grease Pencil", 0, 0); + wmKeyMapItem *kmi; /* Draw */ /* draw */ diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index d9439956569..97f4dd915e4 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -34,7 +34,7 @@ struct ListBase; struct AnimData; struct bContext; -struct wmWindowManager; +struct wmKeyConfig; struct ScrArea; struct ARegion; struct View2D; @@ -487,11 +487,11 @@ void ANIM_pose_to_action_sync(struct Object *ob, struct ScrArea *sa); /* generic animation channels */ void ED_operatortypes_animchannels(void); -void ED_keymap_animchannels(struct wmWindowManager *wm); +void ED_keymap_animchannels(struct wmKeyConfig *keyconf); /* generic time editing */ void ED_operatortypes_anim(void); -void ED_keymap_anim(struct wmWindowManager *wm); +void ED_keymap_anim(struct wmKeyConfig *keyconf); /* ************************************************ */ diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index 8bdfe41ef80..6479030bcd1 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -35,7 +35,7 @@ struct Bone; struct bArmature; struct bPoseChannel; struct wmOperator; -struct wmWindowManager; +struct wmKeyConfig; struct ListBase; struct View3D; struct ViewContext; @@ -92,7 +92,7 @@ typedef struct EditBone /* armature_ops.c */ void ED_operatortypes_armature(void); -void ED_keymap_armature(struct wmWindowManager *wm); +void ED_keymap_armature(struct wmKeyConfig *keyconf); /* editarmature.c */ void ED_armature_from_edit(struct Object *obedit); diff --git a/source/blender/editors/include/ED_curve.h b/source/blender/editors/include/ED_curve.h index 4149c6a9cca..fea684971b2 100644 --- a/source/blender/editors/include/ED_curve.h +++ b/source/blender/editors/include/ED_curve.h @@ -36,11 +36,11 @@ struct Scene; struct Text; struct View3D; struct wmOperator; -struct wmWindowManager; +struct wmKeyConfig; /* curve_ops.c */ void ED_operatortypes_curve(void); -void ED_keymap_curve (struct wmWindowManager *wm); +void ED_keymap_curve (struct wmKeyConfig *keyconf); /* editcurve.c */ void undo_push_curve (struct bContext *C, char *name); diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h index 388da9a2acc..ff95f8ce6eb 100644 --- a/source/blender/editors/include/ED_gpencil.h +++ b/source/blender/editors/include/ED_gpencil.h @@ -41,7 +41,7 @@ struct bGPDframe; struct PointerRNA; struct Panel; struct ImBuf; -struct wmWindowManager; +struct wmKeyConfig; /* ------------- Grease-Pencil Helpers ---------------- */ @@ -62,7 +62,7 @@ struct bGPdata *gpencil_data_get_active(struct bContext *C); /* ----------- Grease Pencil Operators ----------------- */ -void ED_keymap_gpencil(struct wmWindowManager *wm); +void ED_keymap_gpencil(struct wmKeyConfig *keyconf); void ED_operatortypes_gpencil(void); /* ------------ Grease-Pencil Drawing API ------------------ */ diff --git a/source/blender/editors/include/ED_markers.h b/source/blender/editors/include/ED_markers.h index 4b7a2954206..58ca85bb74c 100644 --- a/source/blender/editors/include/ED_markers.h +++ b/source/blender/editors/include/ED_markers.h @@ -28,7 +28,7 @@ #ifndef ED_MARKERS_H #define ED_MARKERS_H -struct wmWindowManager; +struct wmKeyConfig; struct bContext; struct TimeMarker; @@ -56,7 +56,7 @@ void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, short sel); /* called in screen_ops.c:ED_operatortypes_screen() */ void ED_operatortypes_marker(void); /* called in screen_ops.c:ED_keymap_screen() */ -void ED_marker_keymap(struct wmWindowManager *wm); +void ED_marker_keymap(struct wmKeyConfig *keyconf); #endif /* ED_MARKERS_H */ diff --git a/source/blender/editors/include/ED_mball.h b/source/blender/editors/include/ED_mball.h index 49c1d856a27..6708a73e088 100644 --- a/source/blender/editors/include/ED_mball.h +++ b/source/blender/editors/include/ED_mball.h @@ -28,10 +28,10 @@ struct bContext; struct Object; -struct wmWindowManager; +struct wmKeyConfig; void ED_operatortypes_metaball(void); -void ED_keymap_metaball(struct wmWindowManager *wm); +void ED_keymap_metaball(struct wmKeyConfig *keyconf); struct MetaElem *add_metaball_primitive(struct bContext *C, int type, int newname); diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index fd88f9889ae..cf0e6eb01c3 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -38,6 +38,7 @@ struct EditFace; struct bContext; struct wmOperator; struct wmWindowManager; +struct wmKeyConfig; struct ReportList; struct EditSelection; struct ViewContext; @@ -84,13 +85,13 @@ int join_mesh_exec(struct bContext *C, struct wmOperator *op); /* mesh_ops.c */ void ED_operatortypes_mesh(void); -void ED_keymap_mesh(struct wmWindowManager *wm); +void ED_keymap_mesh(struct wmKeyConfig *keyconf); /* editmesh.c */ void ED_spacetypes_init(void); -void ED_keymap_mesh(struct wmWindowManager *wm); +void ED_keymap_mesh(struct wmKeyConfig *keyconf); void make_editMesh(struct Scene *scene, struct Object *ob); void load_editMesh(struct Scene *scene, struct Object *ob); diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index 363795afeab..ec763fe3dfc 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -28,7 +28,7 @@ #ifndef ED_OBJECT_H #define ED_OBJECT_H -struct wmWindowManager; +struct wmKeyConfig; struct Scene; struct Object; struct bContext; @@ -44,7 +44,7 @@ struct ModifierData; /* object_edit.c */ void ED_operatortypes_object(void); -void ED_keymap_object(struct wmWindowManager *wm); +void ED_keymap_object(struct wmKeyConfig *keyconf); /* send your own notifier for select! */ void ED_base_object_select(struct Base *base, short mode); diff --git a/source/blender/editors/include/ED_particle.h b/source/blender/editors/include/ED_particle.h index a052142102d..3d7fc5ea15b 100644 --- a/source/blender/editors/include/ED_particle.h +++ b/source/blender/editors/include/ED_particle.h @@ -36,7 +36,7 @@ struct ParticleEditSettings; struct ParticleSystem; struct RadialControl; struct rcti; -struct wmWindowManager; +struct wmKeyConfig; struct PTCacheEdit; struct Scene; diff --git a/source/blender/editors/include/ED_physics.h b/source/blender/editors/include/ED_physics.h index ee340c54e7d..df303d7c9f1 100644 --- a/source/blender/editors/include/ED_physics.h +++ b/source/blender/editors/include/ED_physics.h @@ -30,9 +30,11 @@ #ifndef ED_PHYSICS_H #define ED_PHYSICS_H +struct wmKeyConfig; + /* operators */ void ED_operatortypes_physics(void); -void ED_keymap_physics(struct wmWindowManager *wm); +void ED_keymap_physics(struct wmKeyConfig *keyconf); #endif /* ED_PHYSICS_H */ diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 63b6a067389..18c86306e44 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -37,6 +37,7 @@ struct wmWindowManager; struct wmWindow; struct wmNotifier; struct wmEvent; +struct wmKeyConfig; struct bContext; struct SpaceType; struct Scene; @@ -63,7 +64,7 @@ void region_scissor_winrct(struct ARegion *ar, struct rcti *winrct); /* spaces */ void ED_spacetypes_init(void); -void ED_spacetypes_keymap(struct wmWindowManager *wm); +void ED_spacetypes_keymap(struct wmKeyConfig *keyconf); int ED_area_header_switchbutton(const struct bContext *C, struct uiBlock *block, int yco); int ED_area_header_standardbuttons(const struct bContext *C, struct uiBlock *block, int yco); void ED_area_overdraw(struct bContext *C); @@ -107,7 +108,7 @@ void ED_screen_new_window(struct bContext *C, struct rcti *position, int type); void ED_update_for_newframe(const struct bContext *C, int mute); void ED_operatortypes_screen(void); -void ED_keymap_screen(struct wmWindowManager *wm); +void ED_keymap_screen(struct wmKeyConfig *keyconf); /* operators; context poll callbacks */ int ED_operator_screenactive(struct bContext *C); diff --git a/source/blender/editors/include/ED_sculpt.h b/source/blender/editors/include/ED_sculpt.h index a08f0576f42..764efb4ef0c 100644 --- a/source/blender/editors/include/ED_sculpt.h +++ b/source/blender/editors/include/ED_sculpt.h @@ -29,14 +29,14 @@ #define ED_SCULPT_H struct bContext; -struct wmWindowManager; +struct wmKeyConfig; /* sculpt.c */ void ED_operatortypes_sculpt(void); /* paint_ops.c */ void ED_operatortypes_paint(void); -void ED_keymap_paint(struct wmWindowManager *wm); +void ED_keymap_paint(struct wmKeyConfig *keyconf); /* paint_image.c */ void undo_imagepaint_step(int step); diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h index 7f08e95aceb..a7ffefba8df 100644 --- a/source/blender/editors/include/ED_transform.h +++ b/source/blender/editors/include/ED_transform.h @@ -42,8 +42,9 @@ struct uiLayout; struct EnumPropertyItem; struct wmOperatorType; struct wmKeyMap; +struct wmKeyConfig; -void transform_keymap_for_space(struct wmWindowManager *wm, struct wmKeyMap *keymap, int spaceid); +void transform_keymap_for_space(struct wmKeyConfig *keyconf, struct wmKeyMap *keymap, int spaceid); void transform_operatortypes(void); /* ******************** Macros & Prototypes *********************** */ diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h index 74a9be75db6..8823437cf79 100644 --- a/source/blender/editors/include/ED_uvedit.h +++ b/source/blender/editors/include/ED_uvedit.h @@ -34,11 +34,11 @@ struct Object; struct MTFace; struct EditFace; struct Image; -struct wmWindowManager; +struct wmKeyConfig; /* uvedit_ops.c */ void ED_operatortypes_uvedit(void); -void ED_keymap_uvedit(struct wmWindowManager *wm); +void ED_keymap_uvedit(struct wmKeyConfig *keyconf); void ED_uvedit_assign_image(struct Scene *scene, struct Object *obedit, struct Image *ima, struct Image *previma); void ED_uvedit_set_tile(struct bContext *C, struct Scene *scene, struct Object *obedit, struct Image *ima, int curtile, int dotile); diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 35598db9e02..3c6ed1137ae 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -147,6 +147,7 @@ typedef struct uiLayout uiLayout; #define UI_BUT_INACTIVE (1<<23) #define UI_BUT_LAST_ACTIVE (1<<24) #define UI_BUT_UNDO (1<<25) +#define UI_BUT_IMMEDIATE (1<<26) #define UI_PANEL_WIDTH 340 #define UI_COMPACT_PANEL_WIDTH 160 @@ -572,6 +573,8 @@ void UI_exit(void); #define UI_ITEM_R_SLIDER 4 #define UI_ITEM_R_TOGGLE 8 #define UI_ITEM_R_ICON_ONLY 16 +#define UI_ITEM_R_EVENT 32 +#define UI_ITEM_R_FULL_EVENT 64 uiLayout *uiBlockLayout(uiBlock *block, int dir, int type, int x, int y, int size, int em, struct uiStyle *style); void uiBlockSetCurLayout(uiBlock *block, uiLayout *layout); diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index 38c4d82e6da..8fbff25589d 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -128,7 +128,7 @@ struct View2D; struct View2DGrid; struct View2DScrollers; -struct wmWindowManager; +struct wmKeyConfig; struct bScreen; struct ScrArea; struct ARegion; @@ -196,7 +196,7 @@ void UI_view2d_text_cache_draw(struct ARegion *ar); /* operators */ void ui_view2d_operatortypes(void); -void UI_view2d_keymap(struct wmWindowManager *wm); +void UI_view2d_keymap(struct wmKeyConfig *keyconf); #endif /* UI_VIEW2D_H */ diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 3e5cc0e6d67..fcc41e4f533 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1958,7 +1958,10 @@ void ui_check_but(uiBut *but) if (but->flag & UI_SELECT) { short *sp= (short *)but->func_arg3; - strcpy(but->drawstr, but->str); + if(but->flag & UI_BUT_IMMEDIATE) + strcpy(but->drawstr, but->str); + else + strcpy(but->drawstr, ""); if(*sp) { char *str= but->drawstr; @@ -1974,10 +1977,10 @@ void ui_check_but(uiBut *but) } else strcat(but->drawstr, "Press a key "); - } else { - /* XXX todo, button currently only used temporarily */ - strcpy(but->drawstr, WM_key_event_string((short) ui_get_but_val(but))); } + else + strcpy(but->drawstr, but->str); + break; case BUT_TOGDUAL: diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 8dea3fa1fc3..195129eac8f 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1858,6 +1858,7 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data if(data->state == BUTTON_STATE_HIGHLIGHT) { if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) { but->drawstr[0]= 0; + *(short *)but->func_arg3= 0; button_activate_state(C, but, BUTTON_STATE_WAIT_KEY_EVENT); return WM_UI_HANDLER_BREAK; } @@ -1868,9 +1869,12 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data if(event->type == MOUSEMOVE) return WM_UI_HANDLER_CONTINUE; - if(ELEM(event->type, ESCKEY, LEFTMOUSE)) { + if(event->type == ESCKEY) { /* data->cancel doesnt work, this button opens immediate */ - ui_set_but_val(but, 0); + if(but->flag & UI_BUT_IMMEDIATE) + ui_set_but_val(but, 0); + else + data->cancel= 1; button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_BREAK; } @@ -3325,6 +3329,7 @@ static uiBlock *menu_change_hotkey(bContext *C, ARegion *ar, void *arg_but) strcat(buf, " |"); but= uiDefHotKeyevtButS(block, 0, buf, 0, 0, 200, 20, dummy, dummy+1, ""); + uiButSetFlag(but, UI_BUT_IMMEDIATE); uiButSetFunc(but, do_menu_change_hotkey, arg_but, dummy); uiPopupBoundsBlock(block, 6.0f, 50, -10); @@ -3782,8 +3787,11 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA button_activate_state(C, but, BUTTON_STATE_HIGHLIGHT); /* activate right away */ - if(but->type==HOTKEYEVT) - button_activate_state(C, but, BUTTON_STATE_WAIT_KEY_EVENT); + if(but->flag & UI_BUT_IMMEDIATE) { + if(but->type==HOTKEYEVT) + button_activate_state(C, but, BUTTON_STATE_WAIT_KEY_EVENT); + /* .. more to be added here */ + } if(type == BUTTON_ACTIVATE_OPEN) { button_activate_state(C, but, BUTTON_STATE_MENU_OPEN); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index b15be940eef..eb81044852a 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -476,8 +476,20 @@ static void ui_item_enum_row(uiLayout *layout, uiBlock *block, PointerRNA *ptr, MEM_freeN(item); } +/* callback for keymap item change button */ +static void ui_keymap_but_cb(bContext *C, void *but_v, void *key_v) +{ + uiBut *but= but_v; + short modifier= *((short*)key_v); + + RNA_boolean_set(&but->rnapoin, "shift", (modifier & KM_SHIFT) != 0); + RNA_boolean_set(&but->rnapoin, "ctrl", (modifier & KM_CTRL) != 0); + RNA_boolean_set(&but->rnapoin, "alt", (modifier & KM_ALT) != 0); + RNA_boolean_set(&but->rnapoin, "oskey", (modifier & KM_OSKEY) != 0); +} + /* create label + button for RNA property */ -static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index, int x, int y, int w, int h, int icon_only) +static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index, int x, int y, int w, int h, int flag) { uiLayout *sub; uiBut *but=NULL; @@ -507,10 +519,26 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, char *name, i /* BUTTONS_OT_file_browse calls uiFileBrowseContextProperty */ but= uiDefIconButO(block, BUT, "BUTTONS_OT_file_browse", WM_OP_INVOKE_DEFAULT, ICON_FILESEL, x, y, UI_UNIT_X, h, "Browse for file or directory."); } - else if(subtype == PROP_DIRECTION) - uiDefButR(block, BUT_NORMAL, 0, name, 0, 0, 100, 100, ptr, RNA_property_identifier(prop), index, 0, 0, -1, -1, NULL); + else if(subtype == PROP_DIRECTION) { + uiDefButR(block, BUT_NORMAL, 0, name, x, y, 100, 100, ptr, RNA_property_identifier(prop), index, 0, 0, -1, -1, NULL); + } + else if(flag & UI_ITEM_R_EVENT) { + uiDefButR(block, KEYEVT, 0, name, x, y, w, h, ptr, RNA_property_identifier(prop), index, 0, 0, -1, -1, NULL); + } + else if(flag & UI_ITEM_R_FULL_EVENT) { + if(RNA_struct_is_a(ptr->type, &RNA_KeyMapItem)) { + static short dummy = 0; + char buf[128]; + + WM_keymap_item_to_string(ptr->data, buf, sizeof(buf)); + + but= uiDefButR(block, HOTKEYEVT, 0, buf, x, y, w, h, ptr, RNA_property_identifier(prop), 0, 0, 0, -1, -1, NULL); + but->func_arg3= &dummy; // XXX abuse + uiButSetFunc(but, ui_keymap_but_cb, but, &dummy); + } + } else - but= uiDefAutoButR(block, ptr, prop, index, (type == PROP_ENUM && !icon_only)? NULL: "", icon, x, y, w, h); + but= uiDefAutoButR(block, ptr, prop, index, (type == PROP_ENUM && !(flag & UI_ITEM_R_ICON_ONLY))? NULL: "", icon, x, y, w, h); uiBlockSetCurLayout(block, layout); return but; @@ -897,7 +925,7 @@ void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, Proper ui_item_enum_row(layout, block, ptr, prop, name, 0, 0, w, h, icon_only); /* property with separate label */ else if(type == PROP_ENUM || type == PROP_STRING || type == PROP_POINTER) { - but= ui_item_with_label(layout, block, name, icon, ptr, prop, index, 0, 0, w, h, icon_only); + but= ui_item_with_label(layout, block, name, icon, ptr, prop, index, 0, 0, w, h, flag); ui_but_add_search(but, ptr, prop, NULL, NULL); } /* single button */ diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index 1d56ed4fb6a..eca4eef230c 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -126,10 +126,12 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind void uiDefAutoButsRNA(const bContext *C, uiLayout *layout, PointerRNA *ptr, int columns) { uiLayout *split, *col; + int flag; char *name; RNA_STRUCT_BEGIN(ptr, prop) { - if(strcmp(RNA_property_identifier(prop), "rna_type") == 0) + flag= RNA_property_flag(prop); + if(flag & PROP_HIDDEN) continue; name= (char*)RNA_property_ui_name(prop); diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 0af5a5cac97..ef37f6e530a 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -1407,9 +1407,9 @@ void ui_view2d_operatortypes(void) WM_operatortype_append(VIEW2D_OT_reset); } -void UI_view2d_keymap(wmWindowManager *wm) +void UI_view2d_keymap(wmKeyConfig *keyconf) { - wmKeyMap *keymap= WM_keymap_find(wm, "View2D", 0, 0); + wmKeyMap *keymap= WM_keymap_find(keyconf, "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_find(wm, "View2D Buttons List", 0, 0); + keymap= WM_keymap_find(keyconf, "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); diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index 4c9f63f910c..4669f7a6741 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -1240,36 +1240,34 @@ static EnumPropertyItem *select_similar_type_itemf(bContext *C, PointerRNA *ptr, EnumPropertyItem *item= NULL; int totitem= 0; - if(C==NULL) { - /* needed for doc generation */ - RNA_enum_items_add(&item, &totitem, prop_simvertex_types); - RNA_enum_items_add(&item, &totitem, prop_simedge_types); - RNA_enum_items_add(&item, &totitem, prop_simface_types); - RNA_enum_item_end(&item, &totitem); - *free= 1; + if(C) { + obedit= CTX_data_edit_object(C); - return item; - } - - obedit= CTX_data_edit_object(C); - - if(obedit && obedit->type == OB_MESH) { - EditMesh *em= BKE_mesh_get_editmesh(obedit->data); + if(obedit && obedit->type == OB_MESH) { + EditMesh *em= BKE_mesh_get_editmesh(obedit->data); - if(em->selectmode & SCE_SELECT_VERTEX) - RNA_enum_items_add(&item, &totitem, prop_simvertex_types); - else if(em->selectmode & SCE_SELECT_EDGE) - RNA_enum_items_add(&item, &totitem, prop_simedge_types); - else if(em->selectmode & SCE_SELECT_FACE) - RNA_enum_items_add(&item, &totitem, prop_simface_types); - RNA_enum_item_end(&item, &totitem); + if(em->selectmode & SCE_SELECT_VERTEX) + RNA_enum_items_add(&item, &totitem, prop_simvertex_types); + else if(em->selectmode & SCE_SELECT_EDGE) + RNA_enum_items_add(&item, &totitem, prop_simedge_types); + else if(em->selectmode & SCE_SELECT_FACE) + RNA_enum_items_add(&item, &totitem, prop_simface_types); + RNA_enum_item_end(&item, &totitem); - *free= 1; + *free= 1; - return item; + return item; + } } + + /* needed for doc generation */ + RNA_enum_items_add(&item, &totitem, prop_simvertex_types); + RNA_enum_items_add(&item, &totitem, prop_simedge_types); + RNA_enum_items_add(&item, &totitem, prop_simface_types); + RNA_enum_item_end(&item, &totitem); + *free= 1; - return NULL; + return item; } void MESH_OT_select_similar(wmOperatorType *ot) @@ -1290,7 +1288,7 @@ void MESH_OT_select_similar(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - prop= RNA_def_enum(ot->srna, "type", prop_simvertex_types, 0, "Type", ""); + prop= RNA_def_enum(ot->srna, "type", prop_simvertex_types, SIMVERT_NORMAL, "Type", ""); RNA_def_enum_funcs(prop, select_similar_type_itemf); } diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 13d73faeb98..6f94db38316 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -348,12 +348,12 @@ void ED_operatortypes_mesh(void) } /* note mesh keymap also for other space? */ -void ED_keymap_mesh(wmWindowManager *wm) +void ED_keymap_mesh(wmKeyConfig *keyconf) { wmKeyMap *keymap; - wmKeymapItem *kmi; + wmKeyMapItem *kmi; - keymap= WM_keymap_find(wm, "EditMesh", 0, 0); + keymap= WM_keymap_find(keyconf, "EditMesh", 0, 0); keymap->poll= ED_operator_editmesh; WM_keymap_add_item(keymap, "MESH_OT_loopcut", RKEY, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/metaball/mball_ops.c b/source/blender/editors/metaball/mball_ops.c index dd8a18f385c..01da90212a0 100644 --- a/source/blender/editors/metaball/mball_ops.c +++ b/source/blender/editors/metaball/mball_ops.c @@ -51,11 +51,11 @@ void ED_operatortypes_metaball(void) WM_operatortype_append(MBALL_OT_select_random_metaelems); } -void ED_keymap_metaball(wmWindowManager *wm) +void ED_keymap_metaball(wmKeyConfig *keyconf) { wmKeyMap *keymap; - keymap= WM_keymap_find(wm, "Metaball", 0, 0); + keymap= WM_keymap_find(keyconf, "Metaball", 0, 0); keymap->poll= ED_operator_editmball; WM_keymap_add_item(keymap, "OBJECT_OT_metaball_add", AKEY, KM_PRESS, KM_SHIFT, 0); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 82135bf3804..f2f24c099bc 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -196,12 +196,12 @@ static int object_mode_poll(bContext *C) return (!ob || ob->mode == OB_MODE_OBJECT); } -void ED_keymap_object(wmWindowManager *wm) +void ED_keymap_object(wmKeyConfig *keyconf) { wmKeyMap *keymap; - wmKeymapItem *kmi; + wmKeyMapItem *kmi; - keymap= WM_keymap_find(wm, "Object Non-modal", 0, 0); + keymap= WM_keymap_find(keyconf, "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); @@ -217,7 +217,7 @@ 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_find(wm, "Object Mode", 0, 0); + keymap= WM_keymap_find(keyconf, "Object Mode", 0, 0); keymap->poll= object_mode_poll; WM_keymap_add_item(keymap, "OBJECT_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); @@ -264,7 +264,7 @@ 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_find(wm, "Lattice", 0, 0); + keymap= WM_keymap_find(keyconf, "Lattice", 0, 0); keymap->poll= ED_operator_editlattice; WM_keymap_add_item(keymap, "LATTICE_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c index ddc5fb9c9b6..0ebbfa6b701 100644 --- a/source/blender/editors/physics/physics_ops.c +++ b/source/blender/editors/physics/physics_ops.c @@ -83,11 +83,11 @@ static void operatortypes_particle(void) WM_operatortype_append(PARTICLE_OT_dupliob_move_down); } -static void keymap_particle(wmWindowManager *wm) +static void keymap_particle(wmKeyConfig *keyconf) { wmKeyMap *keymap; - keymap= WM_keymap_find(wm, "Particle", 0, 0); + keymap= WM_keymap_find(keyconf, "Particle", 0, 0); keymap->poll= PE_poll; WM_keymap_add_item(keymap, "PARTICLE_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); @@ -166,10 +166,10 @@ void ED_operatortypes_physics(void) operatortypes_pointcache(); } -void ED_keymap_physics(wmWindowManager *wm) +void ED_keymap_physics(wmKeyConfig *keyconf) { - keymap_particle(wm); - //keymap_pointcache(wm); + keymap_particle(keyconf); + //keymap_pointcache(keyconf); } diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index fb782837d5e..f539020c93d 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -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) { - wmKeyMap *keymap= WM_keymap_find(wm, "View2D", 0, 0); + wmKeyMap *keymap= WM_keymap_find(wm->defaultconf, "View2D", 0, 0); WM_event_add_keymap_handler(handlers, keymap); } if(flag & ED_KEYMAP_MARKERS) { - wmKeyMap *keymap= WM_keymap_find(wm, "Markers", 0, 0); + wmKeyMap *keymap= WM_keymap_find(wm->defaultconf, "Markers", 0, 0); WM_event_add_keymap_handler(handlers, keymap); // XXX need boundbox check urgently!!! } if(flag & ED_KEYMAP_ANIMATION) { - wmKeyMap *keymap= WM_keymap_find(wm, "Animation", 0, 0); + wmKeyMap *keymap= WM_keymap_find(wm->defaultconf, "Animation", 0, 0); WM_event_add_keymap_handler(handlers, keymap); } if(flag & ED_KEYMAP_FRAMES) { - wmKeyMap *keymap= WM_keymap_find(wm, "Frames", 0, 0); + wmKeyMap *keymap= WM_keymap_find(wm->defaultconf, "Frames", 0, 0); WM_event_add_keymap_handler(handlers, keymap); } if(flag & ED_KEYMAP_GPENCIL) { - wmKeyMap *keymap= WM_keymap_find(wm, "Grease Pencil", 0, 0); + wmKeyMap *keymap= WM_keymap_find(wm->defaultconf, "Grease Pencil", 0, 0); WM_event_add_keymap_handler(handlers, keymap); } } @@ -1371,7 +1371,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_find(wm, "View2D Buttons List", 0, 0); + keymap= WM_keymap_find(wm->defaultconf, "View2D Buttons List", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 8d8c2eba2a8..7ba83753fee 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -2550,7 +2550,7 @@ static ScrArea *find_empty_image_area(bContext *C) static void screen_set_image_output(bContext *C, int mx, int my) { Scene *scene= CTX_data_scene(C); - ScrArea *sa; + ScrArea *sa= NULL; SpaceImage *sima; if(scene->r.displaymode==R_OUTPUT_WINDOW) { @@ -2580,8 +2580,8 @@ static void screen_set_image_output(bContext *C, int mx, int my) ED_screen_full_newspace(C, CTX_wm_area(C), SPACE_IMAGE); sa= CTX_wm_area(C); } - else { + if(!sa) { sa= find_area_showing_r_result(C); if(sa==NULL) sa= find_area_image_empty(C); @@ -3286,7 +3286,7 @@ void ED_operatortypes_screen(void) } -static void keymap_modal_set(wmWindowManager *wm) +static void keymap_modal_set(wmKeyConfig *keyconf) { static EnumPropertyItem modal_items[] = { {KM_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, @@ -3297,7 +3297,7 @@ static void keymap_modal_set(wmWindowManager *wm) wmKeyMap *keymap; /* Standard Modal keymap ------------------------------------------------ */ - keymap= WM_modalkeymap_add(wm, "Standard Modal Map", modal_items); + keymap= WM_modalkeymap_add(keyconf, "Standard Modal Map", modal_items); WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, KM_MODAL_CANCEL); WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_ANY, KM_ANY, 0, KM_MODAL_APPLY); @@ -3312,12 +3312,12 @@ static void keymap_modal_set(wmWindowManager *wm) } /* called in spacetypes.c */ -void ED_keymap_screen(wmWindowManager *wm) +void ED_keymap_screen(wmKeyConfig *keyconf) { wmKeyMap *keymap; /* Screen Editing ------------------------------------------------ */ - keymap= WM_keymap_find(wm, "Screen Editing", 0, 0); + keymap= WM_keymap_find(keyconf, "Screen Editing", 0, 0); RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_actionzone", LEFTMOUSE, KM_PRESS, 0, 0)->ptr, "modifier", 0); RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_actionzone", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "modifier", 1); @@ -3334,7 +3334,7 @@ void ED_keymap_screen(wmWindowManager *wm) /* Screen General ------------------------------------------------ */ - keymap= WM_keymap_find(wm, "Screen", 0, 0); + keymap= WM_keymap_find(keyconf, "Screen", 0, 0); /* standard timers */ WM_keymap_add_item(keymap, "SCREEN_OT_animation_step", TIMER0, KM_ANY, KM_ANY, 0); @@ -3389,7 +3389,7 @@ void ED_keymap_screen(wmWindowManager *wm) /* Anim Playback ------------------------------------------------ */ - keymap= WM_keymap_find(wm, "Frames", 0, 0); + keymap= WM_keymap_find(keyconf, "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); @@ -3409,6 +3409,6 @@ void ED_keymap_screen(wmWindowManager *wm) WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", KKEY, KM_PRESS, 0, LKEY); RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0)->ptr, "reverse", 1); - keymap_modal_set(wm); + keymap_modal_set(keyconf); } diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 514c80d929d..11dbeffdb22 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -134,12 +134,12 @@ void ED_operatortypes_paint(void) WM_operatortype_append(PAINT_OT_vertex_color_set); } -void ED_keymap_paint(wmWindowManager *wm) +void ED_keymap_paint(wmKeyConfig *keyconf) { wmKeyMap *keymap; /* Sculpt mode */ - keymap= WM_keymap_find(wm, "Sculpt", 0, 0); + keymap= WM_keymap_find(keyconf, "Sculpt", 0, 0); keymap->poll= sculpt_poll; RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE); @@ -150,7 +150,7 @@ void ED_keymap_paint(wmWindowManager *wm) WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0); /* Vertex Paint mode */ - keymap= WM_keymap_find(wm, "Vertex Paint", 0, 0); + keymap= WM_keymap_find(keyconf, "Vertex Paint", 0, 0); keymap->poll= vertex_paint_poll; RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_vertex_paint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE); @@ -159,7 +159,7 @@ void ED_keymap_paint(wmWindowManager *wm) WM_keymap_add_item(keymap, "PAINT_OT_sample_color", RIGHTMOUSE, KM_PRESS, 0, 0); /* Weight Paint mode */ - keymap= WM_keymap_find(wm, "Weight Paint", 0, 0); + keymap= WM_keymap_find(keyconf, "Weight Paint", 0, 0); keymap->poll= weight_paint_poll; RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_weight_paint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE); @@ -168,7 +168,7 @@ void ED_keymap_paint(wmWindowManager *wm) WM_keymap_verify_item(keymap, "PAINT_OT_weight_paint", LEFTMOUSE, KM_PRESS, 0, 0); /* Image/Texture Paint mode */ - keymap= WM_keymap_find(wm, "Image Paint", 0, 0); + keymap= WM_keymap_find(keyconf, "Image Paint", 0, 0); keymap->poll= image_texture_paint_poll; RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_texture_paint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE); diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h index 4326bed62d3..c436475b537 100644 --- a/source/blender/editors/space_action/action_intern.h +++ b/source/blender/editors/space_action/action_intern.h @@ -124,7 +124,7 @@ enum { /* ***************************************** */ /* action_ops.c */ void action_operatortypes(void); -void action_keymap(struct wmWindowManager *wm); +void action_keymap(struct wmKeyConfig *keyconf); #endif /* ED_ACTION_INTERN_H */ diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c index 00b22232608..ba504fa8a69 100644 --- a/source/blender/editors/space_action/action_ops.c +++ b/source/blender/editors/space_action/action_ops.c @@ -91,9 +91,9 @@ void action_operatortypes(void) /* ************************** registration - keymaps **********************************/ -static void action_keymap_keyframes (wmWindowManager *wm, wmKeyMap *keymap) +static void action_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap) { - wmKeymapItem *kmi; + wmKeyMapItem *kmi; /* action_select.c - selection tools */ /* click-select */ @@ -156,7 +156,7 @@ static void action_keymap_keyframes (wmWindowManager *wm, wmKeyMap *keymap) WM_keymap_add_item(keymap, "ACT_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); /* transform system */ - transform_keymap_for_space(wm, keymap, SPACE_ACTION); + transform_keymap_for_space(keyconf, keymap, SPACE_ACTION); /* test */ /* WM_keymap_add_item(keymap, "ACT_OT_test", QKEY, KM_PRESS, 0, 0); */ @@ -164,7 +164,7 @@ static void action_keymap_keyframes (wmWindowManager *wm, wmKeyMap *keymap) /* --------------- */ -void action_keymap(wmWindowManager *wm) +void action_keymap(wmKeyConfig *keyconf) { wmKeyMap *keymap; @@ -175,7 +175,7 @@ void action_keymap(wmWindowManager *wm) */ /* keyframes */ - keymap= WM_keymap_find(wm, "Action_Keys", SPACE_ACTION, 0); - action_keymap_keyframes(wm, keymap); + keymap= WM_keymap_find(keyconf, "Action_Keys", SPACE_ACTION, 0); + action_keymap_keyframes(keyconf, keymap); } diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index 3b275cab814..07de15a26b4 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -158,7 +158,7 @@ static void action_main_area_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); /* own keymap */ - keymap= WM_keymap_find(wm, "Action_Keys", SPACE_ACTION, 0); + keymap= WM_keymap_find(wm->defaultconf, "Action_Keys", SPACE_ACTION, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } @@ -221,7 +221,7 @@ static void action_channel_area_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); /* own keymap */ - keymap= WM_keymap_find(wm, "Animation_Channels", 0, 0); + keymap= WM_keymap_find(wm->defaultconf, "Animation_Channels", 0, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index 8c563c98d9b..397da005543 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -110,35 +110,35 @@ void ED_spacetypes_init(void) /* called in wm.c */ /* keymap definitions are registered only once per WM initialize, usually on file read, using the keymap the actual areas/regions add the handlers */ -void ED_spacetypes_keymap(wmWindowManager *wm) +void ED_spacetypes_keymap(wmKeyConfig *keyconf) { const ListBase *spacetypes; SpaceType *stype; ARegionType *atype; - ED_keymap_screen(wm); - ED_keymap_anim(wm); - ED_keymap_animchannels(wm); - ED_keymap_gpencil(wm); - ED_keymap_object(wm); - ED_keymap_mesh(wm); - ED_keymap_uvedit(wm); - ED_keymap_curve(wm); - ED_keymap_armature(wm); - ED_keymap_physics(wm); - ED_keymap_metaball(wm); - ED_keymap_paint(wm); - ED_marker_keymap(wm); - - UI_view2d_keymap(wm); + ED_keymap_screen(keyconf); + ED_keymap_anim(keyconf); + ED_keymap_animchannels(keyconf); + ED_keymap_gpencil(keyconf); + ED_keymap_object(keyconf); + ED_keymap_mesh(keyconf); + ED_keymap_uvedit(keyconf); + ED_keymap_curve(keyconf); + ED_keymap_armature(keyconf); + ED_keymap_physics(keyconf); + ED_keymap_metaball(keyconf); + ED_keymap_paint(keyconf); + ED_marker_keymap(keyconf); + + UI_view2d_keymap(keyconf); spacetypes = BKE_spacetypes_list(); for(stype=spacetypes->first; stype; stype=stype->next) { if(stype->keymap) - stype->keymap(wm); + stype->keymap(keyconf); for(atype=stype->regiontypes.first; atype; atype=atype->next) { if(atype->keymap) - atype->keymap(wm); + atype->keymap(keyconf); } } } @@ -234,7 +234,7 @@ static void xxx_operatortypes(void) /* register operator types for this space */ } -static void xxx_keymap(wmWindowManager *wm) +static void xxx_keymap(wmKeyConfig *keyconf) { /* add default items to keymap */ } diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 6ffbb79f273..03d126a3e7b 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -142,7 +142,7 @@ static void buttons_main_area_init(wmWindowManager *wm, ARegion *ar) ED_region_panels_init(wm, ar); - keymap= WM_keymap_find(wm, "Buttons Generic", SPACE_BUTS, 0); + keymap= WM_keymap_find(wm->defaultconf, "Buttons Generic", SPACE_BUTS, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -189,9 +189,9 @@ void buttons_operatortypes(void) WM_operatortype_append(BUTTONS_OT_file_browse); } -void buttons_keymap(struct wmWindowManager *wm) +void buttons_keymap(struct wmKeyConfig *keyconf) { - wmKeyMap *keymap= WM_keymap_find(wm, "Buttons Generic", SPACE_BUTS, 0); + wmKeyMap *keymap= WM_keymap_find(keyconf, "Buttons Generic", SPACE_BUTS, 0); WM_keymap_add_item(keymap, "BUTTONS_OT_toolbox", RIGHTMOUSE, KM_PRESS, 0, 0); } diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 19fb575ed16..49bc3adb5b9 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -152,7 +152,7 @@ static void console_main_area_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); /* own keymap */ - keymap= WM_keymap_find(wm, "Console", SPACE_CONSOLE, 0); + keymap= WM_keymap_find(wm->defaultconf, "Console", SPACE_CONSOLE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } @@ -232,9 +232,9 @@ void console_operatortypes(void) WM_operatortype_append(CONSOLE_OT_report_copy); } -void console_keymap(struct wmWindowManager *wm) +void console_keymap(struct wmKeyConfig *keyconf) { - wmKeyMap *keymap= WM_keymap_find(wm, "Console", SPACE_CONSOLE, 0); + wmKeyMap *keymap= WM_keymap_find(keyconf, "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); diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c index 1b54277c383..afdb0d24917 100644 --- a/source/blender/editors/space_file/file_panels.c +++ b/source/blender/editors/space_file/file_panels.c @@ -172,16 +172,16 @@ static void file_panel_operator(const bContext *C, Panel *pa) { SpaceFile *sfile= CTX_wm_space_file(C); wmOperator *op= sfile->op; - int empty= 1; + int empty= 1, flag; if(op->type->ui) { op->type->ui((bContext*)C, op->ptr, pa->layout); } else { RNA_STRUCT_BEGIN(op->ptr, prop) { - if(strcmp(RNA_property_identifier(prop), "rna_type") == 0) - continue; - if(strcmp(RNA_property_identifier(prop), "filemode") == 0) + flag= RNA_property_flag(prop); + + if(flag & PROP_HIDDEN) continue; if(strcmp(RNA_property_identifier(prop), "path") == 0) continue; @@ -189,10 +189,6 @@ static void file_panel_operator(const bContext *C, Panel *pa) continue; if(strcmp(RNA_property_identifier(prop), "filename") == 0) continue; - if(strcmp(RNA_property_identifier(prop), "display") == 0) - continue; - if(strncmp(RNA_property_identifier(prop), "filter", 6) == 0) - continue; uiItemFullR(pa->layout, NULL, 0, op->ptr, prop, -1, 0, 0); empty= 0; diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 8257aa5482f..94d90929d80 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -406,7 +406,7 @@ void folderlist_pushdir(ListBase* folderlist, const char *dir) previous_folder = folderlist->last; // check if already exists - if(previous_folder){ + if(previous_folder && previous_folder->foldername){ if(! strcmp(previous_folder->foldername, dir)){ return; } diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 1f461f1bbd5..9f5d889c7b9 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -124,7 +124,10 @@ short ED_fileselect_set_params(SpaceFile *sfile) if (op) { BLI_strncpy(params->title, op->type->name, sizeof(params->title)); - params->type = RNA_int_get(op->ptr, "filemode"); + if(RNA_struct_find_property(op->ptr, "filename")) + params->type = RNA_int_get(op->ptr, "filemode"); + else + params->type = FILE_SPECIAL; if (RNA_property_is_set(op->ptr, "path")) { RNA_string_get(op->ptr, "path", name); @@ -140,15 +143,24 @@ short ED_fileselect_set_params(SpaceFile *sfile) } } params->filter = 0; - params->filter |= RNA_boolean_get(op->ptr, "filter_blender") ? BLENDERFILE : 0; - params->filter |= RNA_boolean_get(op->ptr, "filter_image") ? IMAGEFILE : 0; - params->filter |= RNA_boolean_get(op->ptr, "filter_movie") ? MOVIEFILE : 0; - params->filter |= RNA_boolean_get(op->ptr, "filter_text") ? TEXTFILE : 0; - params->filter |= RNA_boolean_get(op->ptr, "filter_python") ? PYSCRIPTFILE : 0; - params->filter |= RNA_boolean_get(op->ptr, "filter_font") ? FTFONTFILE : 0; - params->filter |= RNA_boolean_get(op->ptr, "filter_sound") ? SOUNDFILE : 0; - params->filter |= RNA_boolean_get(op->ptr, "filter_text") ? TEXTFILE : 0; - params->filter |= RNA_boolean_get(op->ptr, "filter_folder") ? FOLDERFILE : 0; + if(RNA_struct_find_property(op->ptr, "filter_blender")) + params->filter |= RNA_boolean_get(op->ptr, "filter_blender") ? BLENDERFILE : 0; + if(RNA_struct_find_property(op->ptr, "filter_image")) + params->filter |= RNA_boolean_get(op->ptr, "filter_image") ? IMAGEFILE : 0; + if(RNA_struct_find_property(op->ptr, "filter_movie")) + params->filter |= RNA_boolean_get(op->ptr, "filter_movie") ? MOVIEFILE : 0; + if(RNA_struct_find_property(op->ptr, "filter_text")) + params->filter |= RNA_boolean_get(op->ptr, "filter_text") ? TEXTFILE : 0; + if(RNA_struct_find_property(op->ptr, "filter_python")) + params->filter |= RNA_boolean_get(op->ptr, "filter_python") ? PYSCRIPTFILE : 0; + if(RNA_struct_find_property(op->ptr, "filter_font")) + params->filter |= RNA_boolean_get(op->ptr, "filter_font") ? FTFONTFILE : 0; + if(RNA_struct_find_property(op->ptr, "filter_sound")) + params->filter |= RNA_boolean_get(op->ptr, "filter_sound") ? SOUNDFILE : 0; + if(RNA_struct_find_property(op->ptr, "filter_text")) + params->filter |= RNA_boolean_get(op->ptr, "filter_text") ? TEXTFILE : 0; + if(RNA_struct_find_property(op->ptr, "filter_folder")) + params->filter |= RNA_boolean_get(op->ptr, "filter_folder") ? FOLDERFILE : 0; if (params->filter != 0) params->flag |= FILE_FILTER; diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 77f50d91e77..4d3376e0e1f 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -253,10 +253,10 @@ static void file_main_area_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); /* own keymaps */ - keymap= WM_keymap_find(wm, "File", SPACE_FILE, 0); + keymap= WM_keymap_find(wm->defaultconf, "File", SPACE_FILE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - keymap= WM_keymap_find(wm, "FileMain", SPACE_FILE, 0); + keymap= WM_keymap_find(wm->defaultconf, "FileMain", SPACE_FILE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); @@ -364,11 +364,11 @@ void file_operatortypes(void) } /* NOTE: do not add .blend file reading on this level */ -void file_keymap(struct wmWindowManager *wm) +void file_keymap(struct wmKeyConfig *keyconf) { - wmKeymapItem *kmi; + wmKeyMapItem *kmi; /* keys for all areas */ - wmKeyMap *keymap= WM_keymap_find(wm, "File", SPACE_FILE, 0); + wmKeyMap *keymap= WM_keymap_find(keyconf, "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); @@ -380,7 +380,7 @@ void file_keymap(struct wmWindowManager *wm) WM_keymap_add_item(keymap, "FILE_OT_delete", DELKEY, KM_PRESS, 0, 0); /* keys for main area */ - keymap= WM_keymap_find(wm, "FileMain", SPACE_FILE, 0); + keymap= WM_keymap_find(keyconf, "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); @@ -401,7 +401,7 @@ void file_keymap(struct wmWindowManager *wm) RNA_int_set(kmi->ptr, "increment",-100); /* keys for button area (top) */ - keymap= WM_keymap_find(wm, "FileButtons", SPACE_FILE, 0); + keymap= WM_keymap_find(keyconf, "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); @@ -425,7 +425,7 @@ static void file_channel_area_init(wmWindowManager *wm, ARegion *ar) ED_region_panels_init(wm, ar); /* own keymaps */ - keymap= WM_keymap_find(wm, "File", SPACE_FILE, 0); + keymap= WM_keymap_find(wm->defaultconf, "File", SPACE_FILE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } @@ -461,10 +461,10 @@ static void file_ui_area_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); /* own keymap */ - keymap= WM_keymap_find(wm, "File", SPACE_FILE, 0); + keymap= WM_keymap_find(wm->defaultconf, "File", SPACE_FILE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - keymap= WM_keymap_find(wm, "FileButtons", SPACE_FILE, 0); + keymap= WM_keymap_find(wm->defaultconf, "FileButtons", SPACE_FILE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h index 83a565e485f..9b7c2eb3656 100644 --- a/source/blender/editors/space_graph/graph_intern.h +++ b/source/blender/editors/space_graph/graph_intern.h @@ -159,7 +159,7 @@ int graphop_selected_fcurve_poll(struct bContext *C); /* ***************************************** */ /* graph_ops.c */ -void graphedit_keymap(struct wmWindowManager *wm); +void graphedit_keymap(struct wmKeyConfig *keyconf); void graphedit_operatortypes(void); diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index b82055064f8..ab35bda0e2f 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -141,9 +141,9 @@ void graphedit_operatortypes(void) /* ************************** registration - keymaps **********************************/ -static void graphedit_keymap_keyframes (wmWindowManager *wm, wmKeyMap *keymap) +static void graphedit_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap) { - wmKeymapItem *kmi; + wmKeyMapItem *kmi; /* view */ WM_keymap_add_item(keymap, "GRAPH_OT_handles_view_toggle", HKEY, KM_PRESS, KM_CTRL, 0); @@ -225,17 +225,17 @@ static void graphedit_keymap_keyframes (wmWindowManager *wm, wmKeyMap *keymap) /* transform system */ - transform_keymap_for_space(wm, keymap, SPACE_IPO); + transform_keymap_for_space(keyconf, keymap, SPACE_IPO); } /* --------------- */ -void graphedit_keymap(wmWindowManager *wm) +void graphedit_keymap(wmKeyConfig *keyconf) { wmKeyMap *keymap; /* keymap for all regions */ - keymap= WM_keymap_find(wm, "GraphEdit Generic", SPACE_IPO, 0); + keymap= WM_keymap_find(keyconf, "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_find(wm, "GraphEdit Keys", SPACE_IPO, 0); - graphedit_keymap_keyframes(wm, keymap); + keymap= WM_keymap_find(keyconf, "GraphEdit Keys", SPACE_IPO, 0); + graphedit_keymap_keyframes(keyconf, keymap); } diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index a7ea2294ed4..c8d2c571a16 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -208,9 +208,9 @@ static void graph_main_area_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); /* own keymap */ - keymap= WM_keymap_find(wm, "GraphEdit Keys", SPACE_IPO, 0); + keymap= WM_keymap_find(wm->defaultconf, "GraphEdit Keys", SPACE_IPO, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - keymap= WM_keymap_find(wm, "GraphEdit Generic", SPACE_IPO, 0); + keymap= WM_keymap_find(wm->defaultconf, "GraphEdit Generic", SPACE_IPO, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -286,9 +286,9 @@ static void graph_channel_area_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); /* own keymap */ - keymap= WM_keymap_find(wm, "Animation_Channels", 0, 0); + keymap= WM_keymap_find(wm->defaultconf, "Animation_Channels", 0, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - keymap= WM_keymap_find(wm, "GraphEdit Generic", SPACE_IPO, 0); + keymap= WM_keymap_find(wm->defaultconf, "GraphEdit Generic", SPACE_IPO, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -356,7 +356,7 @@ static void graph_buttons_area_init(wmWindowManager *wm, ARegion *ar) ED_region_panels_init(wm, ar); - keymap= WM_keymap_find(wm, "GraphEdit Generic", SPACE_IPO, 0); + keymap= WM_keymap_find(wm->defaultconf, "GraphEdit Generic", SPACE_IPO, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 4cf59c9a28e..e64bb1a4209 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -202,9 +202,9 @@ void image_operatortypes(void) WM_operatortype_append(IMAGE_OT_properties); } -void image_keymap(struct wmWindowManager *wm) +void image_keymap(struct wmKeyConfig *keyconf) { - wmKeyMap *keymap= WM_keymap_find(wm, "Image Generic", SPACE_IMAGE, 0); + wmKeyMap *keymap= WM_keymap_find(keyconf, "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_find(wm, "Image", SPACE_IMAGE, 0); + keymap= WM_keymap_find(keyconf, "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); @@ -389,16 +389,16 @@ static void image_main_area_init(wmWindowManager *wm, ARegion *ar) // UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy); /* image paint polls for mode */ - keymap= WM_keymap_find(wm, "Image Paint", SPACE_IMAGE, 0); + keymap= WM_keymap_find(wm->defaultconf, "Image Paint", SPACE_IMAGE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - keymap= WM_keymap_find(wm, "UVEdit", 0, 0); + keymap= WM_keymap_find(wm->defaultconf, "UVEdit", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); /* own keymaps */ - keymap= WM_keymap_find(wm, "Image Generic", SPACE_IMAGE, 0); + keymap= WM_keymap_find(wm->defaultconf, "Image Generic", SPACE_IMAGE, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap= WM_keymap_find(wm, "Image", SPACE_IMAGE, 0); + keymap= WM_keymap_find(wm->defaultconf, "Image", SPACE_IMAGE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } @@ -463,7 +463,7 @@ static void image_buttons_area_init(wmWindowManager *wm, ARegion *ar) ED_region_panels_init(wm, ar); - keymap= WM_keymap_find(wm, "Image Generic", SPACE_IMAGE, 0); + keymap= WM_keymap_find(wm->defaultconf, "Image Generic", SPACE_IMAGE, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c index d3f9c97205c..518553c9a7a 100644 --- a/source/blender/editors/space_info/space_info.c +++ b/source/blender/editors/space_info/space_info.c @@ -134,7 +134,7 @@ void info_operatortypes(void) WM_operatortype_append(FILE_OT_find_missing_files); } -void info_keymap(struct wmWindowManager *wm) +void info_keymap(struct wmKeyConfig *keyconf) { } diff --git a/source/blender/editors/space_logic/space_logic.c b/source/blender/editors/space_logic/space_logic.c index 7043d625ab0..836ac4c6659 100644 --- a/source/blender/editors/space_logic/space_logic.c +++ b/source/blender/editors/space_logic/space_logic.c @@ -186,9 +186,9 @@ void logic_operatortypes(void) } -void logic_keymap(struct wmWindowManager *wm) +void logic_keymap(struct wmKeyConfig *keyconf) { - wmKeyMap *keymap= WM_keymap_find(wm, "Logic Generic", SPACE_LOGIC, 0); + wmKeyMap *keymap= WM_keymap_find(keyconf, "Logic Generic", SPACE_LOGIC, 0); WM_keymap_add_item(keymap, "LOGIC_OT_properties", NKEY, KM_PRESS, 0, 0); } @@ -239,7 +239,7 @@ static void logic_main_area_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); /* own keymaps */ - keymap= WM_keymap_find(wm, "Logic Generic", SPACE_LOGIC, 0); + keymap= WM_keymap_find(wm->defaultconf, "Logic Generic", SPACE_LOGIC, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -280,7 +280,7 @@ static void logic_buttons_area_init(wmWindowManager *wm, ARegion *ar) ED_region_panels_init(wm, ar); - keymap= WM_keymap_find(wm, "Logic Generic", SPACE_LOGIC, 0); + keymap= WM_keymap_find(wm->defaultconf, "Logic Generic", SPACE_LOGIC, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } diff --git a/source/blender/editors/space_nla/nla_intern.h b/source/blender/editors/space_nla/nla_intern.h index e4557ec878f..91c1decc576 100644 --- a/source/blender/editors/space_nla/nla_intern.h +++ b/source/blender/editors/space_nla/nla_intern.h @@ -130,7 +130,7 @@ short nlaedit_is_tweakmode_on(bAnimContext *ac); /* --- */ void nla_operatortypes(void); -void nla_keymap(wmWindowManager *wm); +void nla_keymap(wmKeyConfig *keyconf); #endif /* ED_NLA_INTERN_H */ diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c index 5ea2e99ad6a..6c940f32c24 100644 --- a/source/blender/editors/space_nla/nla_ops.c +++ b/source/blender/editors/space_nla/nla_ops.c @@ -167,7 +167,7 @@ void nla_operatortypes(void) /* ************************** registration - keymaps **********************************/ -static void nla_keymap_channels (wmWindowManager *wm, wmKeyMap *keymap) +static void nla_keymap_channels (wmKeyConfig *keyconf, wmKeyMap *keymap) { /* NLA-specific (different to standard channels keymap) -------------------------- */ /* selection */ @@ -210,9 +210,9 @@ static void nla_keymap_channels (wmWindowManager *wm, wmKeyMap *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, wmKeyMap *keymap) +static void nla_keymap_main (wmKeyConfig *keyconf, wmKeyMap *keymap) { - wmKeymapItem *kmi; + wmKeyMapItem *kmi; /* selection */ /* click select */ @@ -277,17 +277,17 @@ static void nla_keymap_main (wmWindowManager *wm, wmKeyMap *keymap) WM_keymap_add_item(keymap, "NLA_OT_fmodifier_add", MKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); /* transform system */ - transform_keymap_for_space(wm, keymap, SPACE_NLA); + transform_keymap_for_space(keyconf, keymap, SPACE_NLA); } /* --------------- */ -void nla_keymap(wmWindowManager *wm) +void nla_keymap(wmKeyConfig *keyconf) { wmKeyMap *keymap; /* keymap for all regions */ - keymap= WM_keymap_find(wm, "NLA Generic", SPACE_NLA, 0); + keymap= WM_keymap_find(keyconf, "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_find(wm, "NLA Channels", SPACE_NLA, 0); - nla_keymap_channels(wm, keymap); + keymap= WM_keymap_find(keyconf, "NLA Channels", SPACE_NLA, 0); + nla_keymap_channels(keyconf, keymap); /* data */ - keymap= WM_keymap_find(wm, "NLA Data", SPACE_NLA, 0); - nla_keymap_main(wm, keymap); + keymap= WM_keymap_find(keyconf, "NLA Data", SPACE_NLA, 0); + nla_keymap_main(keyconf, keymap); } diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index 41435810889..32ff7766690 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -214,9 +214,9 @@ static void nla_channel_area_init(wmWindowManager *wm, ARegion *ar) /* own keymap */ // TODO: cannot use generic copy, need special NLA version - keymap= WM_keymap_find(wm, "NLA Channels", SPACE_NLA, 0); + keymap= WM_keymap_find(wm->defaultconf, "NLA Channels", SPACE_NLA, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - keymap= WM_keymap_find(wm, "NLA Generic", SPACE_NLA, 0); + keymap= WM_keymap_find(wm->defaultconf, "NLA Generic", SPACE_NLA, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } @@ -259,9 +259,9 @@ static void nla_main_area_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); /* own keymap */ - keymap= WM_keymap_find(wm, "NLA Data", SPACE_NLA, 0); + keymap= WM_keymap_find(wm->defaultconf, "NLA Data", SPACE_NLA, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - keymap= WM_keymap_find(wm, "NLA Generic", SPACE_NLA, 0); + keymap= WM_keymap_find(wm->defaultconf, "NLA Generic", SPACE_NLA, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -358,7 +358,7 @@ static void nla_buttons_area_init(wmWindowManager *wm, ARegion *ar) ED_region_panels_init(wm, ar); - keymap= WM_keymap_find(wm, "NLA Generic", SPACE_NLA, 0); + keymap= WM_keymap_find(wm->defaultconf, "NLA Generic", SPACE_NLA, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index 9f28a5e3dcb..f55ecf1d0f4 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -53,7 +53,7 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d); /* node_ops.c */ void node_operatortypes(void); -void node_keymap(wmWindowManager *wm); +void node_keymap(wmKeyConfig *keyconf); /* node_select.c */ void NODE_OT_select(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c index 880cc489838..443b83a91bc 100644 --- a/source/blender/editors/space_node/node_ops.c +++ b/source/blender/editors/space_node/node_ops.c @@ -67,10 +67,10 @@ void node_operatortypes(void) WM_operatortype_append(NODE_OT_group_edit); } -void node_keymap(struct wmWindowManager *wm) +void node_keymap(struct wmKeyConfig *keyconf) { - wmKeyMap *keymap= WM_keymap_find(wm, "Node", SPACE_NODE, 0); - wmKeymapItem *kmi; + wmKeyMap *keymap= WM_keymap_find(keyconf, "Node", SPACE_NODE, 0); + wmKeyMapItem *kmi; /* 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); @@ -101,5 +101,5 @@ void node_keymap(struct wmWindowManager *wm) kmi= WM_keymap_add_item(keymap, "WM_OT_call_menu", AKEY, KM_PRESS, KM_SHIFT, 0); RNA_string_set(kmi->ptr, "name", "NODE_MT_add"); - transform_keymap_for_space(wm, keymap, SPACE_NODE); + transform_keymap_for_space(keyconf, keymap, SPACE_NODE); } diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index bdd2a65984f..41140eae776 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -252,7 +252,7 @@ static void node_main_area_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); /* own keymap */ - keymap= WM_keymap_find(wm, "Node", SPACE_NODE, 0); + keymap= WM_keymap_find(wm->defaultconf, "Node", SPACE_NODE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index 641137c010b..28fdc4708df 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -1113,16 +1113,16 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i } else if(type == TSE_KEYMAP) { wmKeyMap *km= (wmKeyMap *)idv; - wmKeymapItem *kmi; + wmKeyMapItem *kmi; char opname[OP_MAX_TYPENAME]; te->directdata= idv; - te->name= km->nameid; + te->name= km->idname; if(!(tselem->flag & TSE_CLOSED)) { a= 0; - for (kmi= km->keymap.first; kmi; kmi= kmi->next, a++) { + for (kmi= km->items.first; kmi; kmi= kmi->next, a++) { const char *key= WM_key_event_string(kmi->type); if(key[0]) { @@ -1408,7 +1408,7 @@ static void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) wmWindowManager *wm= mainvar->wm.first; wmKeyMap *km; - for(km= wm->keymaps.first; km; km= km->next) { + for(km= wm->defaultconf->keymaps.first; km; km= km->next) { ten= outliner_add_element(soops, &soops->tree, (void*)km, NULL, TSE_KEYMAP, 0); } } @@ -2229,14 +2229,14 @@ static int tree_element_active_sequence_dup(bContext *C, Scene *scene, TreeEleme static int tree_element_active_keymap_item(bContext *C, TreeElement *te, TreeStoreElem *tselem, int set) { - wmKeymapItem *kmi= te->directdata; + wmKeyMapItem *kmi= te->directdata; if(set==0) { - if(kmi->inactive) return 0; + if(kmi->flag & KMI_INACTIVE) return 0; return 1; } else { - kmi->inactive= !kmi->inactive; + kmi->flag ^= KMI_INACTIVE; } return 0; } @@ -4957,7 +4957,7 @@ static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, Spa static void operator_call_cb(struct bContext *C, void *arg_kmi, void *arg2) { wmOperatorType *ot= arg2; - wmKeymapItem *kmi= arg_kmi; + wmKeyMapItem *kmi= arg_kmi; if(ot) BLI_strncpy(kmi->idname, ot->idname, OP_MAX_TYPENAME); @@ -4987,7 +4987,7 @@ static uiBlock *operator_search_menu(bContext *C, ARegion *ar, void *arg_kmi) static char search[OP_MAX_TYPENAME]; wmEvent event; wmWindow *win= CTX_wm_window(C); - wmKeymapItem *kmi= arg_kmi; + wmKeyMapItem *kmi= arg_kmi; wmOperatorType *ot= WM_operatortype_find(kmi->idname, 0); uiBlock *block; uiBut *but; @@ -5026,8 +5026,8 @@ static uiBlock *operator_search_menu(bContext *C, ARegion *ar, void *arg_kmi) static short keymap_menu_type(short type) { if(ISKEYBOARD(type)) return OL_KM_KEYBOARD; - if(WM_key_event_is_tweak(type)) return OL_KM_TWEAK; - if(type >= LEFTMOUSE && type <= WHEELOUTMOUSE) return OL_KM_MOUSE; + if(ISTWEAK(type)) return OL_KM_TWEAK; + if(ISMOUSE(type)) return OL_KM_MOUSE; // return OL_KM_SPECIALS; return 0; } @@ -5083,8 +5083,6 @@ static char *keymap_tweak_menu(void) str += sprintf(str, formatstr, "Left Mouse", EVT_TWEAK_L); str += sprintf(str, formatstr, "Middle Mouse", EVT_TWEAK_M); str += sprintf(str, formatstr, "Right Mouse", EVT_TWEAK_R); - str += sprintf(str, formatstr, "Button4 Mouse ", BUTTON4MOUSE); - str += sprintf(str, formatstr, "Button5 Mouse ", BUTTON5MOUSE); str += sprintf(str, formatstr, "Action Mouse", EVT_TWEAK_A); str += sprintf(str, formatstr, "Select Mouse", EVT_TWEAK_S); @@ -5115,7 +5113,7 @@ static char *keymap_tweak_dir_menu(void) static void keymap_type_cb(bContext *C, void *kmi_v, void *unused_v) { - wmKeymapItem *kmi= kmi_v; + wmKeyMapItem *kmi= kmi_v; short maptype= keymap_menu_type(kmi->type); if(maptype!=kmi->maptype) { @@ -5158,7 +5156,7 @@ static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soo int butw3= 43; /* modifiers */ if(tselem->type == TSE_KEYMAP_ITEM) { - wmKeymapItem *kmi= te->directdata; + wmKeyMapItem *kmi= te->directdata; /* modal map? */ if(kmi->propvalue); diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index 4f9a0f686b9..c71b5181d16 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -110,7 +110,7 @@ typedef struct TreeElement { /* outliner_ops.c */ void outliner_operatortypes(void); -void outliner_keymap(struct wmWindowManager *wm); +void outliner_keymap(struct wmKeyConfig *keyconf); /* outliner_header.c */ void outliner_header_buttons(const struct bContext *C, struct ARegion *ar); diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c index a35b91249db..3cdd054fe0e 100644 --- a/source/blender/editors/space_outliner/outliner_ops.c +++ b/source/blender/editors/space_outliner/outliner_ops.c @@ -74,9 +74,9 @@ void outliner_operatortypes(void) WM_operatortype_append(OUTLINER_OT_drivers_delete); } -void outliner_keymap(wmWindowManager *wm) +void outliner_keymap(wmKeyConfig *keyconf) { - wmKeyMap *keymap= WM_keymap_find(wm, "Outliner", SPACE_OUTLINER, 0); + wmKeyMap *keymap= WM_keymap_find(keyconf, "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); diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index eb0e9dafbaa..fabe889ace6 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -77,7 +77,7 @@ static void outliner_main_area_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); /* own keymap */ - keymap= WM_keymap_find(wm, "Outliner", SPACE_OUTLINER, 0); + keymap= WM_keymap_find(wm->defaultconf, "Outliner", SPACE_OUTLINER, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } diff --git a/source/blender/editors/space_script/script_intern.h b/source/blender/editors/space_script/script_intern.h index 59858ee6289..7534fc98de1 100644 --- a/source/blender/editors/space_script/script_intern.h +++ b/source/blender/editors/space_script/script_intern.h @@ -36,7 +36,7 @@ void script_header_buttons(const bContext *C, ARegion *ar); /* script_ops.c */ void script_operatortypes(void); -void script_keymap(struct wmWindowManager *wm); +void script_keymap(struct wmKeyConfig *keyconf); /* script_edit.c */ void SCRIPT_OT_python_file_run(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_script/script_ops.c b/source/blender/editors/space_script/script_ops.c index 0e6ea9cf4fd..bf0a7e5769e 100644 --- a/source/blender/editors/space_script/script_ops.c +++ b/source/blender/editors/space_script/script_ops.c @@ -63,9 +63,9 @@ void script_operatortypes(void) WM_operatortype_append(SCRIPT_OT_python_run_ui_scripts); } -void script_keymap(wmWindowManager *wm) +void script_keymap(wmKeyConfig *keyconf) { - wmKeyMap *keymap= WM_keymap_find(wm, "Script", SPACE_SCRIPT, 0); + wmKeyMap *keymap= WM_keymap_find(keyconf, "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"); diff --git a/source/blender/editors/space_script/space_script.c b/source/blender/editors/space_script/space_script.c index a0e73082701..eae0f77d0e1 100644 --- a/source/blender/editors/space_script/space_script.c +++ b/source/blender/editors/space_script/space_script.c @@ -138,7 +138,7 @@ static void script_main_area_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy); /* own keymap */ - keymap= WM_keymap_find(wm, "Script", SPACE_SCRIPT, 0); + keymap= WM_keymap_find(wm->defaultconf, "Script", SPACE_SCRIPT, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index ac396440a00..d45d7bf4d18 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -75,7 +75,8 @@ extern EnumPropertyItem prop_side_types[]; /* operators */ struct wmOperatorType; -struct wmWindowManager; +struct wmKeyConfig; + void SEQUENCER_OT_cut(struct wmOperatorType *ot); void SEQUENCER_OT_mute(struct wmOperatorType *ot); void SEQUENCER_OT_unmute(struct wmOperatorType *ot); @@ -137,7 +138,7 @@ enum { /* sequencer_ops.c */ void sequencer_operatortypes(void); -void sequencer_keymap(struct wmWindowManager *wm); +void sequencer_keymap(struct wmKeyConfig *keyconf); /* sequencer_scope.c */ struct ImBuf *make_waveform_view_from_ibuf(struct ImBuf * ibuf); diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index 1541b32f566..eedbab779c0 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -103,10 +103,10 @@ void sequencer_operatortypes(void) } -void sequencer_keymap(wmWindowManager *wm) +void sequencer_keymap(wmKeyConfig *keyconf) { - wmKeyMap *keymap= WM_keymap_find(wm, "Sequencer", SPACE_SEQ, 0); - wmKeymapItem *kmi; + wmKeyMap *keymap= WM_keymap_find(keyconf, "Sequencer", SPACE_SEQ, 0); + wmKeyMapItem *kmi; WM_keymap_add_item(keymap, "SEQUENCER_OT_properties", NKEY, KM_PRESS, 0, 0); @@ -183,6 +183,6 @@ void sequencer_keymap(wmWindowManager *wm) WM_keymap_verify_item(keymap, "ANIM_OT_change_frame", LEFTMOUSE, KM_PRESS, 0, 0); - transform_keymap_for_space(wm, keymap, SPACE_SEQ); + transform_keymap_for_space(keyconf, keymap, SPACE_SEQ); } diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index c2756b05946..626a3e6e2e0 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -190,7 +190,7 @@ static void sequencer_main_area_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); /* own keymap */ - keymap= WM_keymap_find(wm, "Sequencer", SPACE_SEQ, 0); + keymap= WM_keymap_find(wm->defaultconf, "Sequencer", SPACE_SEQ, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } diff --git a/source/blender/editors/space_sound/space_sound.c b/source/blender/editors/space_sound/space_sound.c index 6713e19b6de..7cd9988eea0 100644 --- a/source/blender/editors/space_sound/space_sound.c +++ b/source/blender/editors/space_sound/space_sound.c @@ -147,7 +147,7 @@ static void sound_main_area_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); /* own keymap */ - keymap= WM_keymap_find(wm, "Sound", SPACE_SOUND, 0); + keymap= WM_keymap_find(wm->defaultconf, "Sound", SPACE_SOUND, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } @@ -179,7 +179,7 @@ void sound_operatortypes(void) } -void sound_keymap(struct wmWindowManager *wm) +void sound_keymap(struct wmKeyConfig *keyconf) { } diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index e068c1a70bb..e3816ed7495 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -206,11 +206,11 @@ static void text_operatortypes(void) WM_operatortype_append(TEXT_OT_resolve_conflict); } -static void text_keymap(struct wmWindowManager *wm) +static void text_keymap(struct wmKeyConfig *keyconf) { wmKeyMap *keymap; - keymap= WM_keymap_find(wm, "Text", SPACE_TEXT, 0); + keymap= WM_keymap_find(keyconf, "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); @@ -336,7 +336,7 @@ static void text_main_area_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy); /* own keymap */ - keymap= WM_keymap_find(wm, "Text", SPACE_TEXT, 0); + keymap= WM_keymap_find(wm->defaultconf, "Text", SPACE_TEXT, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index 0f05eb0149d..501ac1c0cba 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -207,7 +207,7 @@ static void time_main_area_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); /* own keymap */ - keymap= WM_keymap_find(wm, "TimeLine", SPACE_TIME, 0); + keymap= WM_keymap_find(wm->defaultconf, "TimeLine", SPACE_TIME, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } diff --git a/source/blender/editors/space_time/time_intern.h b/source/blender/editors/space_time/time_intern.h index 25f4c63fed1..ac6b407d117 100644 --- a/source/blender/editors/space_time/time_intern.h +++ b/source/blender/editors/space_time/time_intern.h @@ -35,7 +35,7 @@ struct wmWindowManager; /* time_ops.c */ void time_operatortypes(void); -void time_keymap(struct wmWindowManager *wm); +void time_keymap(struct wmKeyConfig *keyconf); /* time_header.c */ void time_header_buttons(const bContext *C, ARegion *ar); diff --git a/source/blender/editors/space_time/time_ops.c b/source/blender/editors/space_time/time_ops.c index 2b073f269bf..7d91c6d0fc7 100644 --- a/source/blender/editors/space_time/time_ops.c +++ b/source/blender/editors/space_time/time_ops.c @@ -140,9 +140,9 @@ void time_operatortypes(void) WM_operatortype_append(TIME_OT_end_frame_set); } -void time_keymap(wmWindowManager *wm) +void time_keymap(wmKeyConfig *keyconf) { - wmKeyMap *keymap= WM_keymap_find(wm, "TimeLine", SPACE_TIME, 0); + wmKeyMap *keymap= WM_keymap_find(keyconf, "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); diff --git a/source/blender/editors/space_userpref/space_userpref.c b/source/blender/editors/space_userpref/space_userpref.c index 8c9d723ce2c..39fc2fd2bd1 100644 --- a/source/blender/editors/space_userpref/space_userpref.c +++ b/source/blender/editors/space_userpref/space_userpref.c @@ -115,7 +115,7 @@ void userpref_operatortypes(void) { } -void userpref_keymap(struct wmWindowManager *wm) +void userpref_keymap(struct wmKeyConfig *keyconf) { } @@ -167,7 +167,7 @@ void ED_spacetype_userpref(void) art->init= userpref_main_area_init; art->draw= userpref_main_area_draw; art->listener= userpref_main_area_listener; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; + art->keymapflag= ED_KEYMAP_UI; BLI_addhead(&st->regiontypes, art); diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 735f3df9b09..e1bd48e002f 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -280,62 +280,62 @@ static void view3d_main_area_init(wmWindowManager *wm, ARegion *ar) wmKeyMap *keymap; /* object ops. */ - keymap= WM_keymap_find(wm, "Object Non-modal", 0, 0); + keymap= WM_keymap_find(wm->defaultconf, "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_find(wm, "Pose", 0, 0); + keymap= WM_keymap_find(wm->defaultconf, "Pose", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap= WM_keymap_find(wm, "Object Mode", 0, 0); + keymap= WM_keymap_find(wm->defaultconf, "Object Mode", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap= WM_keymap_find(wm, "Image Paint", 0, 0); + keymap= WM_keymap_find(wm->defaultconf, "Image Paint", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap= WM_keymap_find(wm, "Vertex Paint", 0, 0); + keymap= WM_keymap_find(wm->defaultconf, "Vertex Paint", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap= WM_keymap_find(wm, "Weight Paint", 0, 0); + keymap= WM_keymap_find(wm->defaultconf, "Weight Paint", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap= WM_keymap_find(wm, "Sculpt", 0, 0); + keymap= WM_keymap_find(wm->defaultconf, "Sculpt", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap= WM_keymap_find(wm, "EditMesh", 0, 0); + keymap= WM_keymap_find(wm->defaultconf, "EditMesh", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap= WM_keymap_find(wm, "Curve", 0, 0); + keymap= WM_keymap_find(wm->defaultconf, "Curve", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap= WM_keymap_find(wm, "Armature", 0, 0); + keymap= WM_keymap_find(wm->defaultconf, "Armature", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap= WM_keymap_find(wm, "Pose", 0, 0); + keymap= WM_keymap_find(wm->defaultconf, "Pose", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap= WM_keymap_find(wm, "Metaball", 0, 0); + keymap= WM_keymap_find(wm->defaultconf, "Metaball", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap= WM_keymap_find(wm, "Lattice", 0, 0); + keymap= WM_keymap_find(wm->defaultconf, "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); + keymap= WM_keymap_find(wm->defaultconf, "Armature_Sketch", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap= WM_keymap_find(wm, "Particle", 0, 0); + keymap= WM_keymap_find(wm->defaultconf, "Particle", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); /* editfont keymap swallows all... */ - keymap= WM_keymap_find(wm, "Font", 0, 0); + keymap= WM_keymap_find(wm->defaultconf, "Font", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); /* own keymap, last so modes can override it */ - keymap= WM_keymap_find(wm, "View3D Generic", SPACE_VIEW3D, 0); + keymap= WM_keymap_find(wm->defaultconf, "View3D Generic", SPACE_VIEW3D, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap= WM_keymap_find(wm, "View3D", SPACE_VIEW3D, 0); + keymap= WM_keymap_find(wm->defaultconf, "View3D", SPACE_VIEW3D, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -491,7 +491,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) { - wmKeyMap *keymap= WM_keymap_find(wm, "View3D Generic", SPACE_VIEW3D, 0); + wmKeyMap *keymap= WM_keymap_find(wm->defaultconf, "View3D Generic", SPACE_VIEW3D, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); @@ -531,7 +531,7 @@ static void view3d_buttons_area_init(wmWindowManager *wm, ARegion *ar) ED_region_panels_init(wm, ar); - keymap= WM_keymap_find(wm, "View3D Generic", SPACE_VIEW3D, 0); + keymap= WM_keymap_find(wm->defaultconf, "View3D Generic", SPACE_VIEW3D, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -602,7 +602,7 @@ static void view3d_tools_area_init(wmWindowManager *wm, ARegion *ar) ED_region_panels_init(wm, ar); - keymap= WM_keymap_find(wm, "View3D Generic", SPACE_VIEW3D, 0); + keymap= WM_keymap_find(wm->defaultconf, "View3D Generic", SPACE_VIEW3D, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index c07d9108993..4c96e1fee39 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -371,7 +371,7 @@ enum { /* called in transform_ops.c, on each regeneration of keymaps */ -void viewrotate_modal_keymap(wmWindowManager *wm) +void viewrotate_modal_keymap(wmKeyConfig *keyconf) { static EnumPropertyItem modal_items[] = { {VIEW_MODAL_CONFIRM, "CONFIRM", 0, "Cancel", ""}, @@ -381,12 +381,12 @@ void viewrotate_modal_keymap(wmWindowManager *wm) {0, NULL, 0, NULL, NULL}}; - wmKeyMap *keymap= WM_modalkeymap_get(wm, "View3D Rotate Modal"); + wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "View3D Rotate Modal"); /* this function is called for each spacetype, only needs to add map once */ if(keymap) return; - keymap= WM_modalkeymap_add(wm, "View3D Rotate Modal", modal_items); + keymap= WM_modalkeymap_add(keyconf, "View3D Rotate Modal", modal_items); /* items for modal map */ WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, KM_ANY, 0, VIEW_MODAL_CONFIRM); @@ -630,19 +630,19 @@ void VIEW3D_OT_rotate(wmOperatorType *ot) /* NOTE: these defines are saved in keymap files, do not change values but just add new ones */ /* called in transform_ops.c, on each regeneration of keymaps */ -void viewmove_modal_keymap(wmWindowManager *wm) +void viewmove_modal_keymap(wmKeyConfig *keyconf) { static EnumPropertyItem modal_items[] = { {VIEW_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, {0, NULL, 0, NULL, NULL}}; - wmKeyMap *keymap= WM_modalkeymap_get(wm, "View3D Move Modal"); + wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "View3D Move Modal"); /* this function is called for each spacetype, only needs to add map once */ if(keymap) return; - keymap= WM_modalkeymap_add(wm, "View3D Move Modal", modal_items); + keymap= WM_modalkeymap_add(keyconf, "View3D Move Modal", modal_items); /* items for modal map */ WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, KM_ANY, 0, VIEW_MODAL_CONFIRM); @@ -749,19 +749,19 @@ void VIEW3D_OT_move(wmOperatorType *ot) /* ************************ viewzoom ******************************** */ /* called in transform_ops.c, on each regeneration of keymaps */ -void viewzoom_modal_keymap(wmWindowManager *wm) +void viewzoom_modal_keymap(wmKeyConfig *keyconf) { static EnumPropertyItem modal_items[] = { {VIEW_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, {0, NULL, 0, NULL, NULL}}; - wmKeyMap *keymap= WM_modalkeymap_get(wm, "View3D Zoom Modal"); + wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "View3D Zoom Modal"); /* this function is called for each spacetype, only needs to add map once */ if(keymap) return; - keymap= WM_modalkeymap_add(wm, "View3D Zoom Modal", modal_items); + keymap= WM_modalkeymap_add(keyconf, "View3D Zoom Modal", modal_items); /* items for modal map */ WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, KM_ANY, 0, VIEW_MODAL_CONFIRM); diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index d80cec9ad48..84d1a1275a9 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -62,7 +62,7 @@ void VIEW3D_OT_layers(struct wmOperatorType *ot); /* view3d_ops.c */ void view3d_operatortypes(void); -void view3d_keymap(struct wmWindowManager *wm); +void view3d_keymap(struct wmKeyConfig *keyconf); /* view3d_edit.c */ void VIEW3D_OT_zoom(struct wmOperatorType *ot); @@ -137,10 +137,10 @@ void smooth_view(struct bContext *C, Object *, Object *, float *ofs, float *quat void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect); /* rect: for picking */ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d); -void fly_modal_keymap(struct wmWindowManager *wm); -void viewrotate_modal_keymap(struct wmWindowManager *wm); -void viewmove_modal_keymap(struct wmWindowManager *wm); -void viewzoom_modal_keymap(struct wmWindowManager *wm); +void fly_modal_keymap(struct wmKeyConfig *keyconf); +void viewrotate_modal_keymap(struct wmKeyConfig *keyconf); +void viewmove_modal_keymap(struct wmKeyConfig *keyconf); +void viewzoom_modal_keymap(struct wmKeyConfig *keyconf); /* view3d_buttons.c */ void VIEW3D_OT_properties(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index a151ff3e73a..74074a04188 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -103,18 +103,18 @@ void view3d_operatortypes(void) transform_operatortypes(); } -void view3d_keymap(wmWindowManager *wm) +void view3d_keymap(wmKeyConfig *keyconf) { wmKeyMap *keymap; - wmKeymapItem *km; + wmKeyMapItem *km; - keymap= WM_keymap_find(wm, "View3D Generic", SPACE_VIEW3D, 0); + keymap= WM_keymap_find(keyconf, "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_find(wm, "View3D", SPACE_VIEW3D, 0); + keymap= WM_keymap_find(keyconf, "View3D", SPACE_VIEW3D, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, 0, 0); /* manipulator always on left mouse, not on action mouse*/ @@ -221,11 +221,11 @@ void view3d_keymap(wmWindowManager *wm) WM_keymap_add_item(keymap, "VIEW3D_OT_snap_menu", SKEY, KM_PRESS, KM_SHIFT, 0); - transform_keymap_for_space(wm, keymap, SPACE_VIEW3D); + transform_keymap_for_space(keyconf, keymap, SPACE_VIEW3D); - fly_modal_keymap(wm); - viewrotate_modal_keymap(wm); - viewmove_modal_keymap(wm); - viewzoom_modal_keymap(wm); + fly_modal_keymap(keyconf); + viewrotate_modal_keymap(keyconf); + viewmove_modal_keymap(keyconf); + viewzoom_modal_keymap(keyconf); } diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 505f3abf401..d26141e3b54 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1633,7 +1633,7 @@ void VIEW3D_OT_game_start(wmOperatorType *ot) #define FLY_MODAL_PRECISION_DISABLE 16 /* called in transform_ops.c, on each regeneration of keymaps */ -void fly_modal_keymap(wmWindowManager *wm) +void fly_modal_keymap(wmKeyConfig *keyconf) { static EnumPropertyItem modal_items[] = { {FLY_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, @@ -1659,12 +1659,12 @@ void fly_modal_keymap(wmWindowManager *wm) {0, NULL, 0, NULL, NULL}}; - wmKeyMap *keymap= WM_modalkeymap_get(wm, "View3D Fly Modal"); + wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "View3D Fly Modal"); /* this function is called for each spacetype, only needs to add map once */ if(keymap) return; - keymap= WM_modalkeymap_add(wm, "View3D Fly Modal", modal_items); + keymap= WM_modalkeymap_add(keyconf, "View3D Fly Modal", modal_items); /* items for modal map */ WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, FLY_MODAL_CANCEL); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 839c3543515..ad89d8a3a59 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -515,7 +515,7 @@ static char *transform_to_undostr(TransInfo *t) #define TFM_MODAL_SNAP_GEARS_OFF 7 /* called in transform_ops.c, on each regeneration of keymaps */ -void transform_modal_keymap(wmWindowManager *wm) +void transform_modal_keymap(wmKeyConfig *keyconf) { static EnumPropertyItem modal_items[] = { {TFM_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, @@ -527,12 +527,12 @@ void transform_modal_keymap(wmWindowManager *wm) {TFM_MODAL_SNAP_GEARS_OFF, "SNAP_GEARS_OFF", 0, "Snap Off", ""}, {0, NULL, 0, NULL, NULL}}; - wmKeyMap *keymap= WM_modalkeymap_get(wm, "Transform Modal Map"); + wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "Transform Modal Map"); /* this function is called for each spacetype, only needs to add map once */ if(keymap) return; - keymap= WM_modalkeymap_add(wm, "Transform Modal Map", modal_items); + keymap= WM_modalkeymap_add(keyconf, "Transform Modal Map", modal_items); /* items for modal map */ WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_CANCEL); diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 1c170a31c45..60786127e3a 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -508,7 +508,7 @@ int Align(TransInfo *t, short mval[2]); void drawPropCircle(const struct bContext *C, TransInfo *t); -void transform_modal_keymap(struct wmWindowManager *wm); +void transform_modal_keymap(struct wmKeyConfig *keyconf); /*********************** transform_conversions.c ********** */ diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 7ef8ad17a69..0913f0ea273 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -734,12 +734,12 @@ void transform_operatortypes(void) WM_operatortype_append(TFM_OT_delete_orientation); } -void transform_keymap_for_space(struct wmWindowManager *wm, struct wmKeyMap *keymap, int spaceid) +void transform_keymap_for_space(struct wmKeyConfig *keyconf, struct wmKeyMap *keymap, int spaceid) { - wmKeymapItem *km; + wmKeyMapItem *km; /* transform.c, only adds modal map once, checks if it's there */ - transform_modal_keymap(wm); + transform_modal_keymap(keyconf); switch(spaceid) { diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 9216cfb5cdc..0f79420d3a7 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -3084,11 +3084,11 @@ void ED_operatortypes_uvedit(void) WM_operatortype_append(UV_OT_tile_set); } -void ED_keymap_uvedit(wmWindowManager *wm) +void ED_keymap_uvedit(wmKeyConfig *keyconf) { wmKeyMap *keymap; - keymap= WM_keymap_find(wm, "UVEdit", 0, 0); + keymap= WM_keymap_find(keyconf, "UVEdit", 0, 0); keymap->poll= ED_operator_uvedit; /* pick selection */ @@ -3129,6 +3129,6 @@ void ED_keymap_uvedit(wmWindowManager *wm) WM_keymap_add_item(keymap, "UV_OT_cursor_set", ACTIONMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "UV_OT_tile_set", ACTIONMOUSE, KM_PRESS, KM_SHIFT, 0); - transform_keymap_for_space(wm, keymap, SPACE_IMAGE); + transform_keymap_for_space(keyconf, keymap, SPACE_IMAGE); } diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 5aa1aa6dfff..6a1b22e1ed5 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -308,6 +308,8 @@ typedef struct UserDef { struct ListBase themes; struct ListBase uifonts; struct ListBase uistyles; + struct ListBase keymaps; + char keyconfigstr[64]; short undosteps; short undomemory; @@ -345,6 +347,14 @@ extern UserDef U; /* from blenkernel blender.c */ /* ***************** USERDEF ****************** */ +/* userpref/section */ +#define USER_SECTION_INTERFACE 0 +#define USER_SECTION_EDIT 1 +#define USER_SECTION_FILE 2 +#define USER_SECTION_SYSTEM 3 +#define USER_SECTION_THEME 4 +#define USER_SECTION_INPUT 5 + /* flag */ #define USER_AUTOSAVE (1 << 0) #define USER_AUTOGRABGRID (1 << 1) diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index ea9d0e86c38..2b986d6d802 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -42,6 +42,7 @@ struct wmGesture; struct wmOperatorType; struct wmOperator; struct wmKeyMap; +struct wmKeyConfig; /* forwards */ struct bContext; @@ -120,9 +121,9 @@ typedef struct wmWindowManager { ListBase paintcursors; /* extra overlay cursors to draw, like circles */ - /* used keymaps, optionally/partially saved */ - ListBase keymaps; - + ListBase keyconfigs; /* known key configurations */ + struct wmKeyConfig *defaultconf; /* default configuration, not saved */ + int defaultactmap, pad2; /* active keymap from default for editing */ } wmWindowManager; /* wmWindowManager.initialized */ @@ -234,44 +235,70 @@ typedef struct wmOperatorType { /* partial copy of the event, for matching by eventhandler */ -typedef struct wmKeymapItem { - struct wmKeymapItem *next, *prev; +typedef struct wmKeyMapItem { + struct wmKeyMapItem *next, *prev; + /* operator */ char idname[64]; /* used to retrieve operator type pointer */ - struct PointerRNA *ptr; /* rna pointer to access properties */ + IDProperty *properties; /* operator properties */ + /* modal */ + short propvalue; /* if used, the item is from modal map */ + + /* event */ short type; /* event code itself */ short val; /* 0=any, 1=click, 2=release, or wheelvalue, or... */ short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */ short keymodifier; /* rawkey modifier */ - short propvalue; /* if used, the item is from modal map */ - - short inactive; /* if set, deactivated item */ - short maptype; /* keymap editor */ - short pad2, pad3; -} wmKeymapItem; + /* flag: inactive, expanded */ + short flag; + /* runtime */ + short maptype, pad[2]; /* keymap editor */ + struct PointerRNA *ptr; /* rna pointer to access properties */ +} wmKeyMapItem; + +/* wmKeyMapItem.flag */ +#define KMI_INACTIVE 1 +#define KMI_EXPANDED 2 /* stored in WM, the actively used keymaps */ typedef struct wmKeyMap { struct wmKeyMap *next, *prev; - ListBase keymap; + ListBase items; - char nameid[64]; /* global editor keymaps, or for more per space/region */ + char idname[64]; /* global editor keymaps, or for more per space/region */ short spaceid; /* same IDs as in DNA_space_types.h */ short regionid; /* see above */ - short is_modal; /* modal map, not using operatornames */ + short flag; /* general flags */ short pad; - void *items; /* struct EnumPropertyItem for now */ - - /* verify if the keymap is enabled in the current context */ - int (*poll)(struct bContext *); + /* runtime */ + int (*poll)(struct bContext *); /* verify if enabled in the current context */ + void *modal_items; /* for modal, EnumPropertyItem for now */ } wmKeyMap; +/* wmKeyMap.flag */ +#define KEYMAP_MODAL 1 /* modal map, not using operatornames */ +#define KEYMAP_USER 2 /* user created keymap */ + +typedef struct wmKeyConfig { + struct wmKeyConfig *next, *prev; + + char idname[64]; /* unique name */ + char basename[64]; /* idname of configuration this is derives from, "" if none */ + + ListBase keymaps; + int actkeymap, flag; +} wmKeyConfig; + +/* wmKeyConfig.flag */ +#define KEYCONF_TWOBUTTONMOUSE (1 << 1) +#define KEYCONF_LMOUSESELECT (1 << 2) +#define KEYCONF_NONUMPAD (1 << 3) /* this one is the operator itself, stored in files for macros etc */ /* operator + operatortype should be able to redo entirely, but for different contextes */ diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 9ea7725b855..810fb110f7a 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -56,6 +56,7 @@ extern StructRNA RNA_Area; extern StructRNA RNA_AreaLamp; extern StructRNA RNA_Armature; extern StructRNA RNA_ArmatureModifier; +extern StructRNA RNA_ArmatureSensor; extern StructRNA RNA_ArrayModifier; extern StructRNA RNA_BackgroundImage; extern StructRNA RNA_BevelModifier; @@ -76,6 +77,7 @@ extern StructRNA RNA_BoneGroup; extern StructRNA RNA_BooleanModifier; extern StructRNA RNA_BooleanProperty; extern StructRNA RNA_Brush; +extern StructRNA RNA_BrushTextureSlot; extern StructRNA RNA_BuildModifier; extern StructRNA RNA_Camera; extern StructRNA RNA_CastModifier; @@ -99,7 +101,8 @@ extern StructRNA RNA_CompositorNodeBilateralblur; extern StructRNA RNA_CompositorNodeBlur; extern StructRNA RNA_CompositorNodeBrightContrast; extern StructRNA RNA_CompositorNodeChannelMatte; -extern StructRNA RNA_CompositorNodeChroma; +extern StructRNA RNA_CompositorNodeChromaMatte; +extern StructRNA RNA_CompositorNodeColorMatte; extern StructRNA RNA_CompositorNodeColorSpill; extern StructRNA RNA_CompositorNodeCombHSVA; extern StructRNA RNA_CompositorNodeCombRGBA; @@ -114,6 +117,7 @@ extern StructRNA RNA_CompositorNodeDefocus; extern StructRNA RNA_CompositorNodeDiffMatte; extern StructRNA RNA_CompositorNodeDilateErode; extern StructRNA RNA_CompositorNodeDisplace; +extern StructRNA RNA_CompositorNodeDistanceMatte; extern StructRNA RNA_CompositorNodeFilter; extern StructRNA RNA_CompositorNodeFlip; extern StructRNA RNA_CompositorNodeGamma; @@ -123,6 +127,7 @@ extern StructRNA RNA_CompositorNodeIDMask; extern StructRNA RNA_CompositorNodeImage; extern StructRNA RNA_CompositorNodeInvert; extern StructRNA RNA_CompositorNodeLensdist; +extern StructRNA RNA_CompositorNodeLevels; extern StructRNA RNA_CompositorNodeLumaMatte; extern StructRNA RNA_CompositorNodeMapUV; extern StructRNA RNA_CompositorNodeMapValue; @@ -174,9 +179,11 @@ extern StructRNA RNA_DistortedNoiseTexture; extern StructRNA RNA_DomainFluidSettings; extern StructRNA RNA_Driver; extern StructRNA RNA_DriverTarget; +extern StructRNA RNA_DupliObject; extern StructRNA RNA_EdgeSplitModifier; extern StructRNA RNA_EditBone; extern StructRNA RNA_EffectSequence; +extern StructRNA RNA_EffectorWeights; extern StructRNA RNA_EnumProperty; extern StructRNA RNA_EnumPropertyItem; extern StructRNA RNA_EnvironmentMap; @@ -204,6 +211,10 @@ extern StructRNA RNA_FluidSettings; extern StructRNA RNA_FluidSimulationModifier; extern StructRNA RNA_FollowPathConstraint; extern StructRNA RNA_Function; +extern StructRNA RNA_GPencilFrame; +extern StructRNA RNA_GPencilLayer; +extern StructRNA RNA_GPencilStroke; +extern StructRNA RNA_GPencilStrokePoint; extern StructRNA RNA_GameBooleanProperty; extern StructRNA RNA_GameFloatProperty; extern StructRNA RNA_GameIntProperty; @@ -214,10 +225,6 @@ extern StructRNA RNA_GameStringProperty; extern StructRNA RNA_GameTimerProperty; extern StructRNA RNA_GlowSequence; extern StructRNA RNA_GreasePencil; -extern StructRNA RNA_GPencilLayer; -extern StructRNA RNA_GPencilFrame; -extern StructRNA RNA_GPencilStroke; -extern StructRNA RNA_GPencilStrokePoint; extern StructRNA RNA_Group; extern StructRNA RNA_Header; extern StructRNA RNA_HemiLamp; @@ -225,6 +232,7 @@ extern StructRNA RNA_HookModifier; extern StructRNA RNA_ID; extern StructRNA RNA_IDProperty; extern StructRNA RNA_IDPropertyGroup; +extern StructRNA RNA_IKParam; extern StructRNA RNA_Image; extern StructRNA RNA_ImagePaint; extern StructRNA RNA_ImageSequence; @@ -232,8 +240,12 @@ extern StructRNA RNA_ImageTexture; extern StructRNA RNA_ImageUser; extern StructRNA RNA_InflowFluidSettings; extern StructRNA RNA_IntProperty; +extern StructRNA RNA_Itasc; extern StructRNA RNA_JoystickSensor; extern StructRNA RNA_Key; +extern StructRNA RNA_KeyConfig; +extern StructRNA RNA_KeyMap; +extern StructRNA RNA_KeyMapItem; extern StructRNA RNA_KeyboardSensor; extern StructRNA RNA_KeyingSet; extern StructRNA RNA_KeyingSetPath; @@ -263,6 +275,7 @@ extern StructRNA RNA_MaterialSlot; extern StructRNA RNA_MaterialStrand; extern StructRNA RNA_MaterialSubsurfaceScattering; extern StructRNA RNA_MaterialTextureSlot; +extern StructRNA RNA_MaterialVolume; extern StructRNA RNA_Menu; extern StructRNA RNA_Mesh; extern StructRNA RNA_MeshColor; @@ -313,6 +326,7 @@ extern StructRNA RNA_Paint; extern StructRNA RNA_Panel; extern StructRNA RNA_Particle; extern StructRNA RNA_ParticleBrush; +extern StructRNA RNA_ParticleDupliWeight; extern StructRNA RNA_ParticleEdit; extern StructRNA RNA_ParticleFluidSettings; extern StructRNA RNA_ParticleHairKey; @@ -327,13 +341,12 @@ extern StructRNA RNA_PluginTexture; extern StructRNA RNA_PointCache; extern StructRNA RNA_PointDensity; extern StructRNA RNA_PointDensityTexture; -extern StructRNA RNA_PointerProperty; extern StructRNA RNA_PointLamp; +extern StructRNA RNA_PointerProperty; extern StructRNA RNA_Pose; extern StructRNA RNA_PoseChannel; extern StructRNA RNA_Property; extern StructRNA RNA_PropertySensor; -extern StructRNA RNA_ArmatureSensor; extern StructRNA RNA_PythonConstraint; extern StructRNA RNA_PythonController; extern StructRNA RNA_RadarSensor; @@ -344,7 +357,6 @@ extern StructRNA RNA_RenderEngine; extern StructRNA RNA_RenderLayer; extern StructRNA RNA_RenderPass; extern StructRNA RNA_RenderResult; -extern StructRNA RNA_RenderValue; extern StructRNA RNA_RigidBodyJointConstraint; extern StructRNA RNA_Scene; extern StructRNA RNA_SceneGameData; @@ -492,12 +504,12 @@ extern StructRNA RNA_TransformSequence; extern StructRNA RNA_UILayout; extern StructRNA RNA_UIListItem; extern StructRNA RNA_UVProjectModifier; +extern StructRNA RNA_UVProjector; extern StructRNA RNA_UnitSettings; extern StructRNA RNA_UnknownType; extern StructRNA RNA_UserPreferences; extern StructRNA RNA_UserPreferencesEdit; extern StructRNA RNA_UserPreferencesFilePaths; -extern StructRNA RNA_UserPreferencesLanguage; extern StructRNA RNA_UserPreferencesSystem; extern StructRNA RNA_UserPreferencesView; extern StructRNA RNA_UserSolidLight; diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index df447894830..576f5cbb984 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -142,6 +142,9 @@ typedef enum PropertyFlag { /* icon */ PROP_ICONS_CONSECUTIVE = 4096, + /* hidden in the user interface */ + PROP_HIDDEN = 524288, + /* function paramater flags */ PROP_REQUIRED = 4, PROP_RETURN = 8, diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index da467381c06..bec2025907a 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -2785,7 +2785,10 @@ int RNA_property_is_set(PointerRNA *ptr, const char *name) PropertyRNA *prop= RNA_struct_find_property(ptr, name); if(prop) { - return (rna_idproperty_find(ptr, name) != NULL); + if(prop->flag & PROP_IDPROPERTY) + return (rna_idproperty_find(ptr, name) != NULL); + else + return 1; } else { // printf("RNA_property_is_set: %s.%s not found.\n", ptr->type->identifier, name); diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index cc86da18a0b..f3fb1244565 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -667,6 +667,7 @@ StructRNA *RNA_def_struct(BlenderRNA *brna, const char *identifier, const char * } prop= RNA_def_property(&srna->cont, "rna_type", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_HIDDEN); RNA_def_property_ui_text(prop, "RNA", "RNA type definition."); if(DefRNA.preprocess) { diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 1ebf03425d4..23592212f68 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -203,7 +203,9 @@ void rna_TextureSlot_update(struct bContext *C, struct PointerRNA *ptr); void RNA_api_action(StructRNA *srna); void RNA_api_image(struct StructRNA *srna); +void RNA_api_keyconfig(struct StructRNA *srna); void RNA_api_keyingset(struct StructRNA *srna); +void RNA_api_keymap(struct StructRNA *srna); void RNA_api_main(struct StructRNA *srna); void RNA_api_material(StructRNA *srna); void RNA_api_mesh(struct StructRNA *srna); @@ -213,7 +215,6 @@ void RNA_api_text(struct StructRNA *srna); void RNA_api_ui_layout(struct StructRNA *srna); void RNA_api_wm(struct StructRNA *srna); - /* ID Properties */ extern StringPropertyRNA rna_IDProperty_string; diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index 17846651c3b..436efbcb2cf 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -37,7 +37,7 @@ #ifdef RNA_RUNTIME -static void rna_uiItemR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, char *propname, int expand, int slider, int toggle, int icon_only) +static void rna_uiItemR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, char *propname, int expand, int slider, int toggle, int icon_only, int event, int full_event) { int flag= 0; @@ -45,6 +45,8 @@ static void rna_uiItemR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, flag |= (expand)? UI_ITEM_R_EXPAND: 0; flag |= (toggle)? UI_ITEM_R_TOGGLE: 0; flag |= (icon_only)? UI_ITEM_R_ICON_ONLY: 0; + flag |= (event)? UI_ITEM_R_EVENT: 0; + flag |= (full_event)? UI_ITEM_R_FULL_EVENT: 0; uiItemR(layout, name, icon, ptr, propname, flag); } @@ -147,6 +149,8 @@ void RNA_api_ui_layout(StructRNA *srna) RNA_def_boolean(func, "slider", 0, "", "Use slider widget for numeric values."); RNA_def_boolean(func, "toggle", 0, "", "Use toggle widget for boolean values."); RNA_def_boolean(func, "icon_only", 0, "", "Draw only icons in buttons, no text."); + RNA_def_boolean(func, "event", 0, "", "Use button to input key events."); + RNA_def_boolean(func, "full_event", 0, "", "Use button to input full events including modifiers."); func= RNA_def_function(srna, "items_enumR", "uiItemsEnumR"); api_ui_item_rna_common(func); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 8f999300c71..3e3ed669e02 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -1977,68 +1977,68 @@ static void rna_def_userdef_system(BlenderRNA *brna) StructRNA *srna; static EnumPropertyItem gl_texture_clamp_items[] = { - {0, "GL_CLAMP_OFF", 0, "Off", ""}, - {8192, "GL_CLAMP_8192", 0, "8192", ""}, - {4096, "GL_CLAMP_4096", 0, "4096", ""}, - {2048, "GL_CLAMP_2048", 0, "2048", ""}, - {1024, "GL_CLAMP_1024", 0, "1024", ""}, - {512, "GL_CLAMP_512", 0, "512", ""}, - {256, "GL_CLAMP_256", 0, "256", ""}, - {128, "GL_CLAMP_128", 0, "128", ""}, + {0, "CLAMP_OFF", 0, "Off", ""}, + {8192, "CLAMP_8192", 0, "8192", ""}, + {4096, "CLAMP_4096", 0, "4096", ""}, + {2048, "CLAMP_2048", 0, "2048", ""}, + {1024, "CLAMP_1024", 0, "1024", ""}, + {512, "CLAMP_512", 0, "512", ""}, + {256, "CLAMP_256", 0, "256", ""}, + {128, "CLAMP_128", 0, "128", ""}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem audio_mixing_samples_items[] = { - {256, "AUDIO_SAMPLES_256", 0, "256", "Set audio mixing buffer size to 256 samples"}, - {512, "AUDIO_SAMPLES_512", 0, "512", "Set audio mixing buffer size to 512 samples"}, - {1024, "AUDIO_SAMPLES_1024", 0, "1024", "Set audio mixing buffer size to 1024 samples"}, - {2048, "AUDIO_SAMPLES_2048", 0, "2048", "Set audio mixing buffer size to 2048 samples"}, - {4096, "AUDIO_SAMPLES_4096", 0, "4096", "Set audio mixing buffer size to 4096 samples"}, - {8192, "AUDIO_SAMPLES_8192", 0, "8192", "Set audio mixing buffer size to 8192 samples"}, - {16384, "AUDIO_SAMPLES_16384", 0, "16384", "Set audio mixing buffer size to 16384 samples"}, - {32768, "AUDIO_SAMPLES_32768", 0, "32768", "Set audio mixing buffer size to 32768 samples"}, + {256, "SAMPLES_256", 0, "256", "Set audio mixing buffer size to 256 samples"}, + {512, "SAMPLES_512", 0, "512", "Set audio mixing buffer size to 512 samples"}, + {1024, "SAMPLES_1024", 0, "1024", "Set audio mixing buffer size to 1024 samples"}, + {2048, "SAMPLES_2048", 0, "2048", "Set audio mixing buffer size to 2048 samples"}, + {4096, "SAMPLES_4096", 0, "4096", "Set audio mixing buffer size to 4096 samples"}, + {8192, "SAMPLES_8192", 0, "8192", "Set audio mixing buffer size to 8192 samples"}, + {16384, "SAMPLES_16384", 0, "16384", "Set audio mixing buffer size to 16384 samples"}, + {32768, "SAMPLES_32768", 0, "32768", "Set audio mixing buffer size to 32768 samples"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem audio_device_items[] = { - {0, "AUDIO_DEVICE_NULL", 0, "No Audio", "Null device - there will be no audio output."}, + {0, "NONE", 0, "None", "Null device - there will be no audio output."}, #ifdef WITH_SDL - {1, "AUDIO_DEVICE_SDL", 0, "SDL", "SDL device - simple direct media layer, recommended for sequencer usage."}, + {1, "SDL", 0, "SDL", "SDL device - simple direct media layer, recommended for sequencer usage."}, #endif #ifdef WITH_OPENAL - {2, "AUDIO_DEVICE_OPENAL", 0, "OpenAL", "OpenAL device - supports 3D audio, recommended for game engine usage."}, + {2, "OPENAL", 0, "OpenAL", "OpenAL device - supports 3D audio, recommended for game engine usage."}, #endif #ifdef WITH_JACK - {3, "AUDIO_DEVICE_JACK", 0, "Jack", "Jack device - open source pro audio, recommended for pro audio users."}, + {3, "JACK", 0, "Jack", "Jack device - open source pro audio, recommended for pro audio users."}, #endif {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem audio_rate_items[] = { -// {8000, "AUDIO_RATE_8000", 0, "8 kHz", "Set audio sampling rate to 8000 samples per second."}, -// {11025, "AUDIO_RATE_11025", 0, "11.025 kHz", "Set audio sampling rate to 11025 samples per second."}, -// {16000, "AUDIO_RATE_16000", 0, "16 kHz", "Set audio sampling rate to 16000 samples per second."}, -// {22050, "AUDIO_RATE_22050", 0, "22.05 kHz", "Set audio sampling rate to 22050 samples per second."}, -// {32000, "AUDIO_RATE_32000", 0, "32 kHz", "Set audio sampling rate to 32000 samples per second."}, - {44100, "AUDIO_RATE_44100", 0, "44.1 kHz", "Set audio sampling rate to 44100 samples per second."}, - {48000, "AUDIO_RATE_48000", 0, "48 kHz", "Set audio sampling rate to 48000 samples per second."}, -// {88200, "AUDIO_RATE_88200", 0, "88.2 kHz", "Set audio sampling rate to 88200 samples per second."}, - {96000, "AUDIO_RATE_96000", 0, "96 kHz", "Set audio sampling rate to 96000 samples per second."}, - {192000, "AUDIO_RATE_192000", 0, "192 kHz", "Set audio sampling rate to 192000 samples per second."}, +// {8000, "RATE_8000", 0, "8 kHz", "Set audio sampling rate to 8000 samples per second."}, +// {11025, "RATE_11025", 0, "11.025 kHz", "Set audio sampling rate to 11025 samples per second."}, +// {16000, "RATE_16000", 0, "16 kHz", "Set audio sampling rate to 16000 samples per second."}, +// {22050, "RATE_22050", 0, "22.05 kHz", "Set audio sampling rate to 22050 samples per second."}, +// {32000, "RATE_32000", 0, "32 kHz", "Set audio sampling rate to 32000 samples per second."}, + {44100, "RATE_44100", 0, "44.1 kHz", "Set audio sampling rate to 44100 samples per second."}, + {48000, "RATE_48000", 0, "48 kHz", "Set audio sampling rate to 48000 samples per second."}, +// {88200, "RATE_88200", 0, "88.2 kHz", "Set audio sampling rate to 88200 samples per second."}, + {96000, "RATE_96000", 0, "96 kHz", "Set audio sampling rate to 96000 samples per second."}, + {192000, "RATE_192000", 0, "192 kHz", "Set audio sampling rate to 192000 samples per second."}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem audio_format_items[] = { - {0x01, "AUDIO_FORMAT_U8", 0, "8-bit Unsigned", "Set audio sample format to 8 bit unsigned integer."}, - {0x12, "AUDIO_FORMAT_S16", 0, "16-bit Signed", "Set audio sample format to 16 bit signed integer."}, - {0x13, "AUDIO_FORMAT_S24", 0, "24-bit Signed", "Set audio sample format to 24 bit signed integer."}, - {0x14, "AUDIO_FORMAT_S32", 0, "32-bit Signed", "Set audio sample format to 32 bit signed integer."}, - {0x24, "AUDIO_FORMAT_FLOAT", 0, "32-bit Float", "Set audio sample format to 32 bit float."}, - {0x28, "AUDIO_FORMAT_DOUBLE", 0, "64-bit Float", "Set audio sample format to 64 bit float."}, + {0x01, "U8", 0, "8-bit Unsigned", "Set audio sample format to 8 bit unsigned integer."}, + {0x12, "S16", 0, "16-bit Signed", "Set audio sample format to 16 bit signed integer."}, + {0x13, "S24", 0, "24-bit Signed", "Set audio sample format to 24 bit signed integer."}, + {0x14, "S32", 0, "32-bit Signed", "Set audio sample format to 32 bit signed integer."}, + {0x24, "FLOAT", 0, "32-bit Float", "Set audio sample format to 32 bit float."}, + {0x28, "DOUBLE", 0, "64-bit Float", "Set audio sample format to 64 bit float."}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem audio_channel_items[] = { - {1, "AUDIO_CHANNELS_MONO", 0, "Mono", "Set audio channels to mono."}, - {2, "AUDIO_CHANNELS_STEREO", 0, "Stereo", "Set audio channels to stereo."}, - {4, "AUDIO_CHANNELS_SURROUND4", 0, "4 Channels", "Set audio channels to 4 channels."}, - {6, "AUDIO_CHANNELS_SURROUND51", 0, "5.1 Surround", "Set audio channels to 5.1 surround sound."}, - {8, "AUDIO_CHANNELS_SURROUND71", 0, "7.1 Surround", "Set audio channels to 7.1 surround sound."}, + {1, "MONO", 0, "Mono", "Set audio channels to mono."}, + {2, "STEREO", 0, "Stereo", "Set audio channels to stereo."}, + {4, "SURROUND4", 0, "4 Channels", "Set audio channels to 4 channels."}, + {6, "SURROUND51", 0, "5.1 Surround", "Set audio channels to 5.1 surround sound."}, + {8, "SURROUND71", 0, "7.1 Surround", "Set audio channels to 7.1 surround sound."}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem draw_method_items[] = { @@ -2340,11 +2340,12 @@ void RNA_def_userdef(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem user_pref_sections[] = { - {0, "VIEW_CONTROLS", 0, "View", ""}, - {1, "EDIT_METHODS", 0, "Editing", ""}, - {2, "FILE_PATHS", 0, "File", ""}, - {3, "SYSTEM_OPENGL", 0, "System", ""}, -// {4, "THEMES", 0, "Themes", ""}, // Leave this out until we figure out a way to manage themes in the prefs. + {USER_SECTION_INTERFACE, "INTERFACE", 0, "Interface", ""}, + {USER_SECTION_EDIT, "EDITING", 0, "Editing", ""}, + {USER_SECTION_INPUT, "INPUT", 0, "Input", ""}, +// {USER_SECTION_THEME, "THEMES", 0, "Themes", ""}, // Leave this out until we figure out a way to manage themes in the prefs. + {USER_SECTION_FILE, "FILES", 0, "File", ""}, + {USER_SECTION_SYSTEM, "SYSTEM", 0, "System", ""}, {0, NULL, 0, NULL, NULL}}; rna_def_userdef_dothemes(brna); @@ -2358,6 +2359,7 @@ void RNA_def_userdef(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "userpref"); RNA_def_property_enum_items(prop, user_pref_sections); RNA_def_property_ui_text(prop, "Active Section", "Active section of the user preferences shown in the user interface."); + RNA_def_property_update(prop, 0, "rna_userdef_update"); prop= RNA_def_property(srna, "themes", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "themes", NULL); diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 0dd9e3aed42..82b244fa702 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -24,14 +24,37 @@ #include <stdlib.h> +#include "RNA_access.h" #include "RNA_define.h" +#include "RNA_enum_types.h" #include "RNA_types.h" #include "rna_internal.h" +#include "DNA_screen_types.h" +#include "DNA_space_types.h" +#include "DNA_userdef_types.h" #include "DNA_windowmanager_types.h" -#include "WM_types.h" /* wmEvent */ +#include "WM_types.h" + +EnumPropertyItem event_keymouse_value_items[] = { + {KM_ANY, "ANY", 0, "Any", ""}, + {KM_PRESS, "PRESS", 0, "Press", ""}, + {KM_RELEASE, "RELEASE", 0, "Release", ""}, + {0, NULL, 0, NULL, NULL}}; + +EnumPropertyItem event_tweak_value_items[]= { + {KM_ANY, "ANY", 0, "Any", ""}, + {EVT_GESTURE_N, "NORTH", 0, "North", ""}, + {EVT_GESTURE_NE, "NORTH_EAST", 0, "North-East", ""}, + {EVT_GESTURE_E, "EAST", 0, "East", ""}, + {EVT_GESTURE_SE, "SOUTH_EAST", 0, "South-East", ""}, + {EVT_GESTURE_S, "SOUTH", 0, "South", ""}, + {EVT_GESTURE_SW, "SOUTH_WEST", 0, "South-West", ""}, + {EVT_GESTURE_W, "WEST", 0, "West", ""}, + {EVT_GESTURE_NW, "NORTH_WEST", 0, "North-West", ""}, + {0, NULL, 0, NULL, NULL}}; EnumPropertyItem event_value_items[] = { {KM_ANY, "ANY", 0, "Any", ""}, @@ -40,9 +63,43 @@ EnumPropertyItem event_value_items[] = { {KM_RELEASE, "RELEASE", 0, "Release", ""}, {0, NULL, 0, NULL, NULL}}; +EnumPropertyItem event_tweak_type_items[]= { + {EVT_TWEAK_L, "EVT_TWEAK_L", 0, "Left", ""}, + {EVT_TWEAK_M, "EVT_TWEAK_M", 0, "Middle", ""}, + {EVT_TWEAK_R, "EVT_TWEAK_R", 0, "Right", ""}, + {EVT_TWEAK_A, "EVT_TWEAK_A", 0, "Action", ""}, + {EVT_TWEAK_S, "EVT_TWEAK_S", 0, "Select", ""}, + {0, NULL, 0, NULL, NULL}}; + +EnumPropertyItem event_mouse_type_items[]= { + {LEFTMOUSE, "LEFTMOUSE", 0, "Left", ""}, + {MIDDLEMOUSE, "MIDDLEMOUSE", 0, "Middle", ""}, + {RIGHTMOUSE, "RIGHTMOUSE", 0, "Right", ""}, + {BUTTON4MOUSE, "BUTTON4MOUSE", 0, "Button4", ""}, + {BUTTON5MOUSE, "BUTTON5MOUSE", 0, "Button5", ""}, + {ACTIONMOUSE, "ACTIONMOUSE", 0, "Action", ""}, + {SELECTMOUSE, "SELECTMOUSE", 0, "Select", ""}, + {0, "", 0, NULL, NULL}, + {MOUSEMOVE, "MOUSEMOVE", 0, "Move", ""}, + {0, "", 0, NULL, NULL}, + {WHEELUPMOUSE, "WHEELUPMOUSE", 0, "Wheel Up", ""}, + {WHEELDOWNMOUSE, "WHEELDOWNMOUSE", 0, "Wheel Down", ""}, + {WHEELINMOUSE, "WHEELINMOUSE", 0, "Wheel In", ""}, + {WHEELOUTMOUSE, "WHEELOUTMOUSE", 0, "Wheel Out", ""}, + {0, NULL, 0, NULL, NULL}}; + +EnumPropertyItem event_timer_type_items[]= { + {TIMER, "TIMER", 0, "Timer", ""}, + {TIMER0, "TIMER0", 0, "Timer 0", ""}, + {TIMER1, "TIMER1", 0, "Timer 1", ""}, + {TIMER2, "TIMER2", 0, "Timer 2", ""}, + {TIMERJOBS, "JOBS_TIMER", 0, "Jobs Timer", ""}, + {0, NULL, 0, NULL, NULL}}; + /* not returned: CAPSLOCKKEY, UNKNOWNKEY, GRLESSKEY */ EnumPropertyItem event_type_items[] = { + {0, "NONE", 0, "", ""}, {LEFTMOUSE, "LEFTMOUSE", 0, "Left Mouse", ""}, {MIDDLEMOUSE, "MIDDLEMOUSE", 0, "Middle Mouse", ""}, {RIGHTMOUSE, "RIGHTMOUSE", 0, "Right Mouse", ""}, @@ -50,20 +107,20 @@ EnumPropertyItem event_type_items[] = { {BUTTON5MOUSE, "BUTTON5MOUSE", 0, "Button5 Mouse", ""}, {ACTIONMOUSE, "ACTIONMOUSE", 0, "Action Mouse", ""}, {SELECTMOUSE, "SELECTMOUSE", 0, "Select Mouse", ""}, - + {0, "", 0, NULL, NULL}, {MOUSEMOVE, "MOUSEMOVE", 0, "Mouse Move", ""}, - + {0, "", 0, NULL, NULL}, {WHEELUPMOUSE, "WHEELUPMOUSE", 0, "Wheel Up", ""}, {WHEELDOWNMOUSE, "WHEELDOWNMOUSE", 0, "Wheel Down", ""}, {WHEELINMOUSE, "WHEELINMOUSE", 0, "Wheel In", ""}, {WHEELOUTMOUSE, "WHEELOUTMOUSE", 0, "Wheel Out", ""}, - + {0, "", 0, NULL, NULL}, {EVT_TWEAK_L, "EVT_TWEAK_L", 0, "Tweak Left", ""}, {EVT_TWEAK_M, "EVT_TWEAK_M", 0, "Tweak Middle", ""}, {EVT_TWEAK_R, "EVT_TWEAK_R", 0, "Tweak Right", ""}, {EVT_TWEAK_A, "EVT_TWEAK_A", 0, "Tweak Action", ""}, {EVT_TWEAK_S, "EVT_TWEAK_S", 0, "Tweak Select", ""}, - + {0, "", 0, NULL, NULL}, {AKEY, "A", 0, "A", ""}, {BKEY, "B", 0, "B", ""}, {CKEY, "C", 0, "C", ""}, @@ -90,7 +147,7 @@ EnumPropertyItem event_type_items[] = { {XKEY, "X", 0, "X", ""}, {YKEY, "Y", 0, "Y", ""}, {ZKEY, "Z", 0, "Z", ""}, - + {0, "", 0, NULL, NULL}, {ZEROKEY, "ZERO", 0, "0", ""}, {ONEKEY, "ONE", 0, "1", ""}, {TWOKEY, "TWO", 0, "2", ""}, @@ -101,16 +158,16 @@ EnumPropertyItem event_type_items[] = { {SEVENKEY, "SEVEN", 0, "7", ""}, {EIGHTKEY, "EIGHT", 0, "8", ""}, {NINEKEY, "NINE", 0, "9", ""}, - + {0, "", 0, NULL, NULL}, {LEFTCTRLKEY, "LEFT_CTRL", 0, "Left Ctrl", ""}, {LEFTALTKEY, "LEFT_ALT", 0, "Left Alt", ""}, {LEFTSHIFTKEY, "LEFT_SHIFT", 0, "Left Shift", ""}, {RIGHTALTKEY, "RIGHT_ALT", 0, "Right Alt", ""}, {RIGHTCTRLKEY, "RIGHT_CTRL", 0, "Right Ctrl", ""}, {RIGHTSHIFTKEY, "RIGHT_SHIFT", 0, "Right Shift", ""}, - + {0, "", 0, NULL, NULL}, {COMMANDKEY, "COMMAND", 0, "Command", ""}, - + {0, "", 0, NULL, NULL}, {ESCKEY, "ESC", 0, "Esc", ""}, {TABKEY, "TAB", 0, "Tab", ""}, {RETKEY, "RET", 0, "Return", ""}, @@ -167,8 +224,20 @@ EnumPropertyItem event_type_items[] = { {PAGEUPKEY, "PAGE_UP", 0, "Page Up", ""}, {PAGEDOWNKEY, "PAGE_DOWN", 0, "Page Down", ""}, {ENDKEY, "END", 0, "End", ""}, + {0, "", 0, NULL, NULL}, + {TIMER, "TIMER", 0, "Timer", ""}, + {TIMER0, "TIMER0", 0, "Timer 0", ""}, + {TIMER1, "TIMER1", 0, "Timer 1", ""}, + {TIMER2, "TIMER2", 0, "Timer 2", ""}, + {TIMERJOBS, "JOBS_TIMER", 0, "Jobs Timer", ""}, {0, NULL, 0, NULL, NULL}}; +#define KMI_TYPE_KEYBOARD 0 +#define KMI_TYPE_MOUSE 1 +#define KMI_TYPE_TWEAK 2 +#define KMI_TYPE_TEXTINPUT 3 +#define KMI_TYPE_TIMER 4 + #ifdef RNA_RUNTIME #include "WM_api.h" @@ -263,6 +332,156 @@ static void rna_Window_screen_update(bContext *C, PointerRNA *ptr) } } +static PointerRNA rna_KeyMapItem_properties_get(PointerRNA *ptr) +{ + wmKeyMapItem *kmi= ptr->data; + + if(kmi->ptr) + return *(kmi->ptr); + + //return rna_pointer_inherit_refine(ptr, &RNA_OperatorProperties, op->properties); + return PointerRNA_NULL; +} + +static int rna_wmKeyMapItem_map_type_get(PointerRNA *ptr) +{ + wmKeyMapItem *kmi= ptr->data; + + if(ISTIMER(kmi->type)) return KMI_TYPE_TIMER; + if(ISKEYBOARD(kmi->type)) return KMI_TYPE_KEYBOARD; + if(ISTWEAK(kmi->type)) return KMI_TYPE_TWEAK; + if(ISMOUSE(kmi->type)) return KMI_TYPE_MOUSE; + if(kmi->type == KM_TEXTINPUT) return KMI_TYPE_TEXTINPUT; + return KMI_TYPE_KEYBOARD; +} + +static void rna_wmKeyMapItem_map_type_set(PointerRNA *ptr, int value) +{ + wmKeyMapItem *kmi= ptr->data; + int map_type= rna_wmKeyMapItem_map_type_get(ptr); + + if(value != map_type) { + switch(value) { + case KMI_TYPE_KEYBOARD: + kmi->type= AKEY; + kmi->val= KM_PRESS; + break; + case KMI_TYPE_TWEAK: + kmi->type= EVT_TWEAK_L; + kmi->val= KM_ANY; + break; + case KMI_TYPE_MOUSE: + kmi->type= LEFTMOUSE; + kmi->val= KM_PRESS; + break; + case KMI_TYPE_TEXTINPUT: + kmi->type= KM_TEXTINPUT; + kmi->val= KM_NOTHING; + break; + case KMI_TYPE_TIMER: + kmi->type= TIMER; + kmi->val= KM_NOTHING; + break; + } + } +} + +static EnumPropertyItem *rna_KeyMapItem_type_itemf(bContext *C, PointerRNA *ptr, int *free) +{ + int map_type= rna_wmKeyMapItem_map_type_get(ptr); + + if(map_type == KMI_TYPE_MOUSE) return event_mouse_type_items; + if(map_type == KMI_TYPE_TWEAK) return event_tweak_type_items; + if(map_type == KMI_TYPE_TIMER) return event_timer_type_items; + else return event_type_items; +} + +static EnumPropertyItem *rna_KeyMapItem_value_itemf(bContext *C, PointerRNA *ptr, int *free) +{ + int map_type= rna_wmKeyMapItem_map_type_get(ptr); + + if(map_type == KMI_TYPE_MOUSE || map_type == KMI_TYPE_KEYBOARD) return event_keymouse_value_items; + if(map_type == KMI_TYPE_TWEAK) return event_tweak_value_items; + else return event_value_items; +} + +static PointerRNA rna_WindowManager_active_keyconfig_get(PointerRNA *ptr) +{ + wmWindowManager *wm= ptr->data; + wmKeyConfig *kc; + + for(kc=wm->keyconfigs.first; kc; kc=kc->next) + if(strcmp(kc->idname, U.keyconfigstr) == 0) + break; + + if(!kc) + kc= wm->defaultconf; + + return rna_pointer_inherit_refine(ptr, &RNA_KeyConfig, kc); +} + +static void rna_WindowManager_active_keyconfig_set(PointerRNA *ptr, PointerRNA value) +{ + wmKeyConfig *kc= value.data; + + if(kc) + BLI_strncpy(U.keyconfigstr, kc->idname, sizeof(U.keyconfigstr)); +} + +static PointerRNA rna_WindowManager_active_keymap_get(PointerRNA *ptr) +{ + wmWindowManager *wm= ptr->data; + wmKeyMap *km= NULL; + + if(wm->defaultconf) { + km= BLI_findlink(&wm->defaultconf->keymaps, wm->defaultactmap); + + if(!km) + km= wm->defaultconf->keymaps.first; + } + + return rna_pointer_inherit_refine(ptr, &RNA_KeyMap, WM_keymap_active(wm, km)); +} + +static void rna_WindowManager_active_keymap_set(PointerRNA *ptr, PointerRNA value) +{ + wmWindowManager *wm= ptr->data; + wmKeyMap *km= value.data; + int index; + + if(wm->defaultconf && km) { + km= WM_keymap_find(wm->defaultconf, km->idname, km->spaceid, km->regionid); + index= BLI_findindex(&wm->defaultconf->keymaps, km); + + if(index != -1) wm->defaultactmap= index; + else wm->defaultactmap= 0; + } +} + +static void rna_wmKeyMapItem_idname_get(PointerRNA *ptr, char *value) +{ + wmKeyMapItem *kmi= ptr->data; + WM_operator_py_idname(value, kmi->idname); +} + +static int rna_wmKeyMapItem_idname_length(PointerRNA *ptr) +{ + wmKeyMapItem *kmi= ptr->data; + char pyname[OP_MAX_TYPENAME]; + + WM_operator_py_idname(pyname, kmi->idname); + return strlen(pyname); +} + +static void rna_wmKeyMapItem_idname_set(PointerRNA *ptr, const char *value) +{ + wmKeyMapItem *kmi= ptr->data; + char idname[OP_MAX_TYPENAME]; + + WM_operator_bl_idname(idname, value); + BLI_strncpy(kmi->idname, idname, sizeof(kmi->idname)); +} + #else static void rna_def_operator(BlenderRNA *brna) @@ -434,9 +653,154 @@ static void rna_def_windowmanager(BlenderRNA *brna) RNA_def_property_struct_type(prop, "Window"); RNA_def_property_ui_text(prop, "Windows", "Open windows."); + prop= RNA_def_property(srna, "keyconfigs", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "KeyConfig"); + RNA_def_property_ui_text(prop, "Key Configurations", "Registered key configurations."); + + prop= RNA_def_property(srna, "active_keyconfig", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_struct_type(prop, "KeyConfig"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_pointer_funcs(prop, "rna_WindowManager_active_keyconfig_get", "rna_WindowManager_active_keyconfig_set", 0); + RNA_def_property_ui_text(prop, "Active Key Configuration", ""); + + prop= RNA_def_property(srna, "default_keyconfig", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "defaultconf"); + RNA_def_property_struct_type(prop, "KeyConfig"); + RNA_def_property_ui_text(prop, "Default Key Configuration", ""); + + prop= RNA_def_property(srna, "active_keymap", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_struct_type(prop, "KeyMap"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_pointer_funcs(prop, "rna_WindowManager_active_keymap_get", "rna_WindowManager_active_keymap_set", 0); + RNA_def_property_ui_text(prop, "Active Key Map", ""); + RNA_api_wm(srna); } +static void rna_def_keyconfig(BlenderRNA *brna) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *prop, *parm; + + static EnumPropertyItem map_type_items[] = { + {KMI_TYPE_KEYBOARD, "KEYBOARD", 0, "Keyboard", ""}, + {KMI_TYPE_TWEAK, "TWEAK", 0, "Tweak", ""}, + {KMI_TYPE_MOUSE, "MOUSE", 0, "Mouse", ""}, + {KMI_TYPE_TEXTINPUT, "TEXTINPUT", 0, "Text Input", ""}, + {KMI_TYPE_TIMER, "TIMER", 0, "Timer", ""}, + {0, NULL, 0, NULL, NULL}}; + + /* KeyConfig */ + srna= RNA_def_struct(brna, "KeyConfig", NULL); + RNA_def_struct_sdna(srna, "wmKeyConfig"); + RNA_def_struct_ui_text(srna, "Key Configuration", "Input configuration, including keymaps."); + + prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "idname"); + RNA_def_property_ui_text(prop, "Name", "Name of the key configuration."); + RNA_def_struct_name_property(srna, prop); + + prop= RNA_def_property(srna, "keymaps", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "KeyMap"); + RNA_def_property_ui_text(prop, "Key Maps", "Key maps configured as part of this configuration."); + + RNA_api_keyconfig(srna); + + /* KeyMap */ + srna= RNA_def_struct(brna, "KeyMap", NULL); + RNA_def_struct_sdna(srna, "wmKeyMap"); + RNA_def_struct_ui_text(srna, "Key Map", "Input configuration, including keymaps."); + + prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "idname"); + RNA_def_property_ui_text(prop, "Name", "Name of the key map."); + RNA_def_struct_name_property(srna, prop); + + prop= RNA_def_property(srna, "space_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "spaceid"); + RNA_def_property_enum_items(prop, space_type_items); + RNA_def_property_ui_text(prop, "Space Type", "Optional space type keymap is associated with."); + + prop= RNA_def_property(srna, "region_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "regionid"); + RNA_def_property_enum_items(prop, region_type_items); + RNA_def_property_ui_text(prop, "Region Type", "Optional region type keymap is associated with."); + + prop= RNA_def_property(srna, "items", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "KeyMapItem"); + RNA_def_property_ui_text(prop, "Items", "Items in the keymap, linking an operator to an input event."); + + prop= RNA_def_property(srna, "user_defined", PROP_BOOLEAN, PROP_NEVER_NULL); + RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYMAP_USER); + RNA_def_property_ui_text(prop, "User Defined", "Keymap is defined by the user."); + + RNA_api_keymap(srna); + + /* KeyMapItem */ + srna= RNA_def_struct(brna, "KeyMapItem", NULL); + RNA_def_struct_sdna(srna, "wmKeyMapItem"); + RNA_def_struct_ui_text(srna, "Key Map Item", "Item in a Key Map."); + + prop= RNA_def_property(srna, "idname", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "idname"); + RNA_def_property_ui_text(prop, "Identifier", "Identifier of operator to call on input event."); + RNA_def_property_string_funcs(prop, "rna_wmKeyMapItem_idname_get", "rna_wmKeyMapItem_idname_length", "rna_wmKeyMapItem_idname_set"); + RNA_def_struct_name_property(srna, prop); + + prop= RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "OperatorProperties"); + RNA_def_property_pointer_funcs(prop, "rna_KeyMapItem_properties_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Properties", "Properties to set when the operator is called."); + + prop= RNA_def_property(srna, "map_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "maptype"); + RNA_def_property_enum_items(prop, map_type_items); + RNA_def_property_enum_funcs(prop, "rna_wmKeyMapItem_map_type_get", "rna_wmKeyMapItem_map_type_set", NULL); + RNA_def_property_ui_text(prop, "Map Type", "Type of event mapping."); + + prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "type"); + RNA_def_property_enum_items(prop, event_type_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_KeyMapItem_type_itemf"); + RNA_def_property_ui_text(prop, "Type", "Type of event."); + + prop= RNA_def_property(srna, "value", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "val"); + RNA_def_property_enum_items(prop, event_value_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_KeyMapItem_value_itemf"); + RNA_def_property_ui_text(prop, "Value", ""); + + prop= RNA_def_property(srna, "shift", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "shift", 0); + RNA_def_property_ui_text(prop, "Shift", "Shift key pressed."); + + prop= RNA_def_property(srna, "ctrl", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "ctrl", 0); + RNA_def_property_ui_text(prop, "Ctrl", "Control key pressed."); + + prop= RNA_def_property(srna, "alt", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "alt", 0); + RNA_def_property_ui_text(prop, "Alt", "Alt key pressed."); + + prop= RNA_def_property(srna, "oskey", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "oskey", 0); + RNA_def_property_ui_text(prop, "OS Key", "Operating system key pressed."); + + prop= RNA_def_property(srna, "key_modifier", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "keymodifier"); + RNA_def_property_enum_items(prop, event_type_items); + RNA_def_property_ui_text(prop, "Key Modifier", "Regular key pressed as a modifier."); + + prop= RNA_def_property(srna, "expanded", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", KMI_EXPANDED); + RNA_def_property_ui_text(prop, "Expanded", "Expanded in the user interface."); + + prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", KMI_INACTIVE); + RNA_def_property_ui_text(prop, "Active", "Activate or deactivate item."); +} + void RNA_def_wm(BlenderRNA *brna) { rna_def_operator(brna); @@ -445,6 +809,7 @@ void RNA_def_wm(BlenderRNA *brna) rna_def_event(brna); rna_def_window(brna); rna_def_windowmanager(brna); + rna_def_keyconfig(brna); } #endif diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index fd34d7c4d70..44c6967189d 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -31,25 +31,93 @@ #include "RNA_define.h" #include "RNA_types.h" +#include "RNA_enum_types.h" + +#include "DNA_screen_types.h" +#include "DNA_space_types.h" #ifdef RNA_RUNTIME #include "BKE_context.h" #include "WM_api.h" +#include "WM_types.h" + +static wmKeyMapItem *rna_KeyMap_add_item(wmKeyMap *km, char *idname, int type, int value, int shift, int ctrl, int alt, int oskey, int keymodifier) +{ + int modifier= 0; + + if(shift) modifier |= KM_SHIFT; + if(ctrl) modifier |= KM_CTRL; + if(alt) modifier |= KM_ALT; + if(oskey) modifier |= KM_OSKEY; + + return WM_keymap_add_item(km, idname, type, value, modifier, keymodifier); +} #else void RNA_api_wm(StructRNA *srna) { FunctionRNA *func; - PropertyRNA *prop; + PropertyRNA *parm; func= RNA_def_function(srna, "add_fileselect", "WM_event_add_fileselect"); RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Show up the file selector."); - prop= RNA_def_pointer(func, "operator", "Operator", "", "Operator to call."); - RNA_def_property_flag(prop, PROP_REQUIRED); + parm= RNA_def_pointer(func, "operator", "Operator", "", "Operator to call."); + RNA_def_property_flag(parm, PROP_REQUIRED); + + func= RNA_def_function(srna, "add_keyconfig", "WM_keyconfig_add"); + parm= RNA_def_string(func, "name", "", 0, "Name", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_pointer(func, "keyconfig", "KeyConfig", "Key Configuration", "Added key configuration."); + RNA_def_function_return(func, parm); +} + +void RNA_api_keyconfig(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *parm; + + func= RNA_def_function(srna, "add_keymap", "WM_keymap_find"); + parm= RNA_def_string(func, "name", "", 0, "Name", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_enum(func, "space_type", space_type_items, SPACE_EMPTY, "Space Type", ""); + RNA_def_enum(func, "region_type", region_type_items, RGN_TYPE_WINDOW, "Region Type", ""); + parm= RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Added key map."); + RNA_def_function_return(func, parm); +} + +void RNA_api_keymap(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *parm; + + func= RNA_def_function(srna, "add_item", "rna_KeyMap_add_item"); + parm= RNA_def_string(func, "idname", "", 0, "Operator Identifier", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_enum(func, "type", event_type_items, 0, "Type", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_enum(func, "value", event_value_items, 0, "Value", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_boolean(func, "shift", 0, "Shift", ""); + RNA_def_boolean(func, "ctrl", 0, "Ctrl", ""); + RNA_def_boolean(func, "alt", 0, "Alt", ""); + RNA_def_boolean(func, "oskey", 0, "OS Key", ""); + RNA_def_enum(func, "key_modifier", event_type_items, 0, "Key Modifier", ""); + parm= RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Added key map item."); + RNA_def_function_return(func, parm); + + func= RNA_def_function(srna, "remove_item", "WM_keymap_remove_item"); + parm= RNA_def_pointer(func, "item", "KeyMapItem", "Item", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); + + func= RNA_def_function(srna, "copy_to_user", "WM_keymap_copy_to_user"); + parm= RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "User editable key map."); + RNA_def_function_return(func, parm); + + func= RNA_def_function(srna, "restore_to_default", "WM_keymap_restore_to_default"); } #endif diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 42b905dc0d8..44b419e8ae9 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -433,7 +433,7 @@ PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop) { PointerRNA newptr; newptr= RNA_property_pointer_get(ptr, prop); - if (newptr.data) { + if (newptr.type) { ret = pyrna_struct_CreatePyObject(&newptr); } else { ret = Py_None; @@ -1153,6 +1153,31 @@ static PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA * self, PyObject *ar return PyBool_FromLong( insert_keyframe((ID *)self->ptr.data, NULL, NULL, path, index, cfra, 0)); } +static PyObject *pyrna_struct_is_property_set(BPy_StructRNA * self, PyObject *args) +{ + char *name; + + if (!PyArg_ParseTuple(args, "s:is_property_set", &name)) + return NULL; + + return PyBool_FromLong(RNA_property_is_set(&self->ptr, name)); +} + +static PyObject *pyrna_struct_is_property_hidden(BPy_StructRNA * self, PyObject *args) +{ + PropertyRNA *prop; + char *name; + int hidden; + + if (!PyArg_ParseTuple(args, "s:is_property_hidden", &name)) + return NULL; + + prop= RNA_struct_find_property(&self->ptr, name); + hidden= (prop)? (RNA_property_flag(prop) & PROP_HIDDEN): 1; + + return PyBool_FromLong(hidden); +} + static PyObject *pyrna_struct_dir(BPy_StructRNA * self) { @@ -1272,7 +1297,7 @@ static PyObject *pyrna_struct_getattro( BPy_StructRNA * self, PyObject *pyname ) CTX_data_get(self->ptr.data, name, &newptr, &newlb); - if (newptr.data) { + if (newptr.type) { ret = pyrna_struct_CreatePyObject(&newptr); } else if (newlb.first) { @@ -1745,6 +1770,8 @@ static struct PyMethodDef pyrna_struct_methods[] = { /* maybe this become and ID function */ {"keyframe_insert", (PyCFunction)pyrna_struct_keyframe_insert, METH_VARARGS, NULL}, + {"is_property_set", (PyCFunction)pyrna_struct_is_property_set, METH_VARARGS, NULL}, + {"is_property_hidden", (PyCFunction)pyrna_struct_is_property_hidden, METH_VARARGS, NULL}, {"__dir__", (PyCFunction)pyrna_struct_dir, METH_NOARGS, NULL}, {NULL, NULL, 0, NULL} diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 0054f151803..b29dbec6364 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -82,22 +82,30 @@ void WM_timecursor (struct wmWindow *win, int nr); void *WM_paint_cursor_activate(struct wmWindowManager *wm, int (*poll)(struct bContext *C), void (*draw)(struct bContext *C, int, int, void *customdata), void *customdata); void WM_paint_cursor_end(struct wmWindowManager *wm, void *handle); - /* keymap */ + /* keyconfig and keymap */ +wmKeyConfig *WM_keyconfig_add (struct wmWindowManager *wm, char *idname); +void WM_keyconfig_free (struct wmKeyConfig *keyconf); +void WM_keyconfig_userdef(struct wmWindowManager *wm); + void WM_keymap_init (struct bContext *C); -wmKeymapItem *WM_keymap_verify_item(wmKeyMap *keymap, 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); -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); -wmKeyMap *WM_modalkeymap_get(struct wmWindowManager *wm, const char *nameid); -void WM_modalkeymap_add_item(wmKeyMap *km, short type, short val, int modifier, short keymodifier, short value); -void WM_modalkeymap_assign(wmKeyMap *km, const char *opname); - -int WM_key_event_is_tweak(short type); +void WM_keymap_free (struct wmKeyMap *keymap); + +wmKeyMapItem *WM_keymap_verify_item(struct wmKeyMap *keymap, char *idname, int type, + int val, int modifier, int keymodifier); +wmKeyMapItem *WM_keymap_add_item(struct wmKeyMap *keymap, char *idname, int type, + int val, int modifier, int keymodifier); +void WM_keymap_remove_item(struct wmKeyMap *keymap, struct wmKeyMapItem *kmi); +char *WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len); + +wmKeyMap *WM_keymap_find(struct wmKeyConfig *keyconf, char *idname, int spaceid, int regionid); +wmKeyMap *WM_keymap_active(struct wmWindowManager *wm, struct wmKeyMap *keymap); +wmKeyMap *WM_keymap_copy_to_user(struct wmKeyMap *keymap); +void WM_keymap_restore_to_default(struct wmKeyMap *keymap); + +wmKeyMap *WM_modalkeymap_add(struct wmKeyConfig *keyconf, char *idname, struct EnumPropertyItem *items); +wmKeyMap *WM_modalkeymap_get(struct wmKeyConfig *keyconf, char *idname); +void WM_modalkeymap_add_item(struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, int value); +void WM_modalkeymap_assign(struct wmKeyMap *km, char *opname); const char *WM_key_event_string(short type); char *WM_key_event_operator_string(const struct bContext *C, const char *opname, int opcontext, struct IDProperty *properties, char *str, int len); diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index 4405b52888d..a068f84ae29 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -132,12 +132,18 @@ void WM_keymap_init(bContext *C) { wmWindowManager *wm= CTX_wm_manager(C); + if(!wm->defaultconf) + wm->defaultconf= WM_keyconfig_add(wm, "Blender"); + if(wm && CTX_py_init_get(C) && (wm->initialized & WM_INIT_KEYMAP) == 0) { - wm_window_keymap(wm); - ED_spacetypes_keymap(wm); + /* create default key config */ + wm_window_keymap(wm->defaultconf); + ED_spacetypes_keymap(wm->defaultconf); wm->initialized |= WM_INIT_KEYMAP; } + + WM_keyconfig_userdef(wm); } void wm_check(bContext *C) @@ -151,15 +157,16 @@ void wm_check(bContext *C) } if(wm==NULL) return; if(wm->windows.first==NULL) return; + + /* case: fileread */ + if((wm->initialized & WM_INIT_WINDOW) == 0) + WM_keymap_init(C); /* case: no open windows at all, for old file reads */ wm_window_add_ghostwindows(wm); /* case: fileread */ if((wm->initialized & WM_INIT_WINDOW) == 0) { - - WM_keymap_init(C); - ED_screens_initialize(wm); wm->initialized |= WM_INIT_WINDOW; } @@ -211,8 +218,7 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm) { wmWindow *win; wmOperator *op; - wmKeyMap *km; - wmKeymapItem *kmi; + wmKeyConfig *keyconf; while((win= wm->windows.first)) { BLI_remlink(&wm->windows, win); @@ -226,19 +232,11 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm) WM_operator_free(op); } - while((km= wm->keymaps.first)) { - for(kmi=km->keymap.first; kmi; kmi=kmi->next) { - if(kmi->ptr) { - WM_operator_properties_free(kmi->ptr); - MEM_freeN(kmi->ptr); - } - } - - BLI_freelistN(&km->keymap); - BLI_remlink(&wm->keymaps, km); - MEM_freeN(km); + while((keyconf=wm->keyconfigs.first)) { + BLI_remlink(&wm->keyconfigs, keyconf); + WM_keyconfig_free(keyconf); } - + BLI_freelistN(&wm->queue); BLI_freelistN(&wm->paintcursors); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 4a8aac4525d..ea73ed38123 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -725,16 +725,16 @@ static int wm_userdef_event_map(int kmitype) return kmitype; } -static int wm_eventmatch(wmEvent *winevent, wmKeymapItem *kmi) +static int wm_eventmatch(wmEvent *winevent, wmKeyMapItem *kmi) { int kmitype= wm_userdef_event_map(kmi->type); - if(kmi->inactive) return 0; + if(kmi->flag & KMI_INACTIVE) return 0; /* exception for middlemouse emulation */ if((U.flag & USER_TWOBUTTONMOUSE) && (kmi->type == MIDDLEMOUSE)) { if(winevent->type == LEFTMOUSE && winevent->alt) { - wmKeymapItem tmp= *kmi; + wmKeyMapItem tmp= *kmi; tmp.type= winevent->type; tmp.alt= winevent->alt; @@ -784,9 +784,9 @@ static int wm_event_always_pass(wmEvent *event) static void wm_event_modalkeymap(wmOperator *op, wmEvent *event) { if(op->type->modalkeymap) { - wmKeymapItem *kmi; + wmKeyMapItem *kmi; - for(kmi= op->type->modalkeymap->keymap.first; kmi; kmi= kmi->next) { + for(kmi= op->type->modalkeymap->items.first; kmi; kmi= kmi->next) { if(wm_eventmatch(event, kmi)) { event->type= EVT_MODAL_MAP; @@ -1031,6 +1031,7 @@ static int handler_boundbox_test(wmEventHandler *handler, wmEvent *event) static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) { + wmWindowManager *wm= CTX_wm_manager(C); wmEventHandler *handler, *nexthandler; int action= WM_HANDLER_CONTINUE; int always_pass; @@ -1051,11 +1052,11 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) action= WM_HANDLER_BREAK; if(handler->keymap) { - wmKeyMap *keymap= handler->keymap; - wmKeymapItem *kmi; + wmKeyMap *keymap= WM_keymap_active(wm, handler->keymap); + wmKeyMapItem *kmi; if(!keymap->poll || keymap->poll(C)) { - for(kmi= keymap->keymap.first; kmi; kmi= kmi->next) { + for(kmi= keymap->items.first; kmi; kmi= kmi->next) { if(wm_eventmatch(event, kmi)) { event->keymap_idname= kmi->idname; /* weak, but allows interactive callback to not use rawkey */ diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 7d25fb8172e..3d3a6e46fb2 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -29,6 +29,7 @@ #include <string.h> #include "DNA_screen_types.h" +#include "DNA_userdef_types.h" #include "DNA_windowmanager_types.h" #include "MEM_guardedalloc.h" @@ -52,9 +53,86 @@ #include "wm_event_system.h" #include "wm_event_types.h" +/* ********************* key config ***********************/ + +static void keymap_properties_set(wmKeyMapItem *kmi) +{ + if(!kmi->properties) { + IDPropertyTemplate val = {0}; + kmi->properties= IDP_New(IDP_GROUP, val, "wmKeyMapItemProperties"); + } + + if(!kmi->ptr) { + kmi->ptr= MEM_callocN(sizeof(PointerRNA), "wmKeyMapItemPtr"); + WM_operator_properties_create(kmi->ptr, kmi->idname); + } + + kmi->ptr->data= kmi->properties; +} + +wmKeyConfig *WM_keyconfig_add(wmWindowManager *wm, char *idname) +{ + wmKeyConfig *keyconf; + + keyconf= MEM_callocN(sizeof(wmKeyConfig), "wmKeyConfig"); + BLI_strncpy(keyconf->idname, idname, sizeof(keyconf->idname)); + BLI_addtail(&wm->keyconfigs, keyconf); + + return keyconf; +} + +void WM_keyconfig_free(wmKeyConfig *keyconf) +{ + wmKeyMap *km; + + while((km= keyconf->keymaps.first)) { + WM_keymap_free(km); + BLI_freelinkN(&keyconf->keymaps, km); + } + + MEM_freeN(keyconf); +} + +void WM_keyconfig_userdef(wmWindowManager *wm) +{ + wmKeyMap *km; + wmKeyMapItem *kmi; + + for(km=U.keymaps.first; km; km=km->next) + for(kmi=km->items.first; kmi; kmi=kmi->next) + keymap_properties_set(kmi); +} + +static wmKeyConfig *wm_keyconfig_list_find(ListBase *lb, char *idname) +{ + wmKeyConfig *kc; + + for(kc= lb->first; kc; kc= kc->next) + if(0==strncmp(idname, kc->idname, KMAP_MAX_NAME)) + return kc; + + return NULL; +} + +/* ************************ free ************************* */ + +void WM_keymap_free(wmKeyMap *keymap) +{ + wmKeyMapItem *kmi; + + for(kmi=keymap->items.first; kmi; kmi=kmi->next) { + if(kmi->ptr) { + WM_operator_properties_free(kmi->ptr); + MEM_freeN(kmi->ptr); + } + } + + BLI_freelistN(&keymap->items); +} + /* ***************** generic call, exported **************** */ -static void keymap_event_set(wmKeymapItem *kmi, short type, short val, int modifier, short keymodifier) +static void keymap_event_set(wmKeyMapItem *kmi, short type, short val, int modifier, short keymodifier) { kmi->type= type; kmi->val= val; @@ -87,26 +165,18 @@ static void keymap_event_set(wmKeymapItem *kmi, short type, short val, int modif } } -static void keymap_properties_set(wmKeymapItem *kmi) -{ - if(!kmi->ptr) { - kmi->ptr= MEM_callocN(sizeof(PointerRNA), "wmKeymapItemPtr"); - WM_operator_properties_create(kmi->ptr, kmi->idname); - } -} - /* if item was added, then bail out */ -wmKeymapItem *WM_keymap_verify_item(wmKeyMap *keymap, char *idname, short type, short val, int modifier, short keymodifier) +wmKeyMapItem *WM_keymap_verify_item(wmKeyMap *keymap, char *idname, int type, int val, int modifier, int keymodifier) { - wmKeymapItem *kmi; + wmKeyMapItem *kmi; - for(kmi= keymap->keymap.first; kmi; kmi= kmi->next) + for(kmi= keymap->items.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"); + kmi= MEM_callocN(sizeof(wmKeyMapItem), "keymap entry"); - BLI_addtail(&keymap->keymap, kmi); + BLI_addtail(&keymap->items, kmi); BLI_strncpy(kmi->idname, idname, OP_MAX_TYPENAME); keymap_event_set(kmi, type, val, modifier, keymodifier); @@ -116,11 +186,11 @@ wmKeymapItem *WM_keymap_verify_item(wmKeyMap *keymap, char *idname, short type, } /* always add item */ -wmKeymapItem *WM_keymap_add_item(wmKeyMap *keymap, char *idname, short type, short val, int modifier, short keymodifier) +wmKeyMapItem *WM_keymap_add_item(wmKeyMap *keymap, char *idname, int type, int val, int modifier, int keymodifier) { - wmKeymapItem *kmi= MEM_callocN(sizeof(wmKeymapItem), "keymap entry"); + wmKeyMapItem *kmi= MEM_callocN(sizeof(wmKeyMapItem), "keymap entry"); - BLI_addtail(&keymap->keymap, kmi); + BLI_addtail(&keymap->items, kmi); BLI_strncpy(kmi->idname, idname, OP_MAX_TYPENAME); keymap_event_set(kmi, type, val, modifier, keymodifier); @@ -128,27 +198,45 @@ wmKeymapItem *WM_keymap_add_item(wmKeyMap *keymap, char *idname, short type, sho return kmi; } +void WM_keymap_remove_item(wmKeyMap *keymap, wmKeyMapItem *kmi) +{ + if(BLI_findindex(&keymap->items, kmi) != -1) { + if(kmi->ptr) { + WM_operator_properties_free(kmi->ptr); + MEM_freeN(kmi->ptr); + } + BLI_freelinkN(&keymap->items, kmi); + } +} + /* ****************** storage in WM ************ */ /* name id's are for storing general or multiple keymaps, space/region ids are same as DNA_space_types.h */ /* gets free'd in wm.c */ -wmKeyMap *WM_keymap_find(wmWindowManager *wm, const char *nameid, short spaceid, short regionid) +static wmKeyMap *wm_keymap_list_find(ListBase *lb, char *idname, int spaceid, int regionid) { wmKeyMap *km; - - for(km= wm->keymaps.first; km; km= km->next) + + for(km= lb->first; km; km= km->next) if(km->spaceid==spaceid && km->regionid==regionid) - if(0==strncmp(nameid, km->nameid, KMAP_MAX_NAME)) + if(0==strncmp(idname, km->idname, KMAP_MAX_NAME)) return km; + return NULL; +} + +wmKeyMap *WM_keymap_find(wmKeyConfig *keyconf, char *idname, int spaceid, int regionid) +{ + wmKeyMap *km= wm_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid); + if(km==NULL) { km= MEM_callocN(sizeof(struct wmKeyMap), "keymap list"); - BLI_strncpy(km->nameid, nameid, KMAP_MAX_NAME); + BLI_strncpy(km->idname, idname, KMAP_MAX_NAME); km->spaceid= spaceid; km->regionid= regionid; - BLI_addtail(&wm->keymaps, km); + BLI_addtail(&keyconf->keymaps, km); } return km; @@ -158,39 +246,39 @@ wmKeyMap *WM_keymap_find(wmWindowManager *wm, const char *nameid, short spaceid, /* 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 *WM_modalkeymap_add(wmKeyConfig *keyconf, char *idname, EnumPropertyItem *items) { - wmKeyMap *km= WM_keymap_find(wm, nameid, 0, 0); - km->is_modal= 1; - km->items= items; + wmKeyMap *km= WM_keymap_find(keyconf, idname, 0, 0); + km->flag |= KEYMAP_MODAL; + km->modal_items= items; return km; } -wmKeyMap *WM_modalkeymap_get(wmWindowManager *wm, const char *nameid) +wmKeyMap *WM_modalkeymap_get(wmKeyConfig *keyconf, char *idname) { wmKeyMap *km; - for(km= wm->keymaps.first; km; km= km->next) - if(km->is_modal) - if(0==strncmp(nameid, km->nameid, KMAP_MAX_NAME)) + for(km= keyconf->keymaps.first; km; km= km->next) + if(km->flag & KEYMAP_MODAL) + if(0==strncmp(idname, km->idname, KMAP_MAX_NAME)) break; return km; } -void WM_modalkeymap_add_item(wmKeyMap *km, short type, short val, int modifier, short keymodifier, short value) +void WM_modalkeymap_add_item(wmKeyMap *km, int type, int val, int modifier, int keymodifier, int value) { - wmKeymapItem *kmi= MEM_callocN(sizeof(wmKeymapItem), "keymap entry"); + wmKeyMapItem *kmi= MEM_callocN(sizeof(wmKeyMapItem), "keymap entry"); - BLI_addtail(&km->keymap, kmi); + BLI_addtail(&km->items, kmi); kmi->propvalue= value; keymap_event_set(kmi, type, val, modifier, keymodifier); } -void WM_modalkeymap_assign(wmKeyMap *km, const char *opname) +void WM_modalkeymap_assign(wmKeyMap *km, char *opname) { wmOperatorType *ot= WM_operatortype_find(opname, 0); @@ -200,7 +288,6 @@ void WM_modalkeymap_assign(wmKeyMap *km, const char *opname) printf("error: modalkeymap_assign, unknown operator %s\n", opname); } - /* ***************** get string from key events **************** */ const char *WM_key_event_string(short type) @@ -212,9 +299,9 @@ const char *WM_key_event_string(short type) return ""; } -static char *wm_keymap_item_to_string(wmKeymapItem *kmi, char *str, int len) +char *WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len) { - char buf[100]; + char buf[128]; buf[0]= 0; @@ -236,25 +323,30 @@ static 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) +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) { + wmWindowManager *wm= CTX_wm_manager(C); wmEventHandler *handler; wmKeyMap *keymap; - wmKeymapItem *kmi; + wmKeyMapItem *kmi; /* find keymap item in handlers */ for(handler=handlers->first; handler; handler=handler->next) { - keymap= handler->keymap; + keymap= WM_keymap_active(wm, handler->keymap); if(keymap && (!keymap->poll || keymap->poll((bContext*)C))) { - for(kmi=keymap->keymap.first; kmi; kmi=kmi->next) { + for(kmi=keymap->items.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)) + if(kmi->ptr && IDP_EqualsProperties(properties, kmi->ptr->data)) { + if(keymap_r) *keymap_r= keymap; return kmi; + } } - else + else { + if(keymap_r) *keymap_r= keymap; return kmi; + } } } } @@ -263,74 +355,162 @@ static wmKeymapItem *wm_keymap_item_find_handlers(const bContext *C, ListBase *h return NULL; } -static wmKeymapItem *wm_keymap_item_find(const bContext *C, const char *opname, int opcontext, IDProperty *properties, int compare_props) +static wmKeyMapItem *wm_keymap_item_find_props(const bContext *C, const char *opname, int opcontext, IDProperty *properties, int compare_props, wmKeyMap **keymap_r) { - wmKeymapItem *found= NULL; + wmWindow *win= CTX_wm_window(C); + ScrArea *sa= CTX_wm_area(C); + ARegion *ar= CTX_wm_region(C); + wmKeyMapItem *found= NULL; /* look into multiple handler lists to find the item */ - if(CTX_wm_window(C)) - found= wm_keymap_item_find_handlers(C, &CTX_wm_window(C)->handlers, opname, opcontext, properties, compare_props); + if(win) + found= wm_keymap_item_find_handlers(C, &win->handlers, opname, opcontext, properties, compare_props, keymap_r); - if(CTX_wm_area(C) && found==NULL) - found= wm_keymap_item_find_handlers(C, &CTX_wm_area(C)->handlers, opname, opcontext, properties, compare_props); + if(sa && found==NULL) + found= wm_keymap_item_find_handlers(C, &sa->handlers, opname, opcontext, properties, compare_props, keymap_r); if(found==NULL) { if(ELEM(opcontext, WM_OP_EXEC_REGION_WIN, WM_OP_INVOKE_REGION_WIN)) { - if(CTX_wm_area(C)) { - ARegion *ar= CTX_wm_area(C)->regionbase.first; + if(sa) { + ARegion *ar= sa->regionbase.first; for(; ar; ar= ar->next) if(ar->regiontype==RGN_TYPE_WINDOW) break; if(ar) - found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props); + found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, keymap_r); } } else { - if(CTX_wm_region(C)) - found= wm_keymap_item_find_handlers(C, &CTX_wm_region(C)->handlers, opname, opcontext, properties, compare_props); + if(ar) + found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, keymap_r); } } return found; } -char *WM_key_event_operator_string(const bContext *C, const char *opname, int opcontext, IDProperty *properties, char *str, int len) +static wmKeyMapItem *wm_keymap_item_find(const bContext *C, const char *opname, int opcontext, IDProperty *properties, wmKeyMap **keymap_r) { - wmKeymapItem *found= wm_keymap_item_find(C, opname, opcontext, properties, 1); + wmKeyMapItem *found= wm_keymap_item_find_props(C, opname, opcontext, properties, 1, keymap_r); if(!found) - found= wm_keymap_item_find(C, opname, opcontext, properties, 0); + found= wm_keymap_item_find_props(C, opname, opcontext, properties, 0, 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); - if(found) { - wm_keymap_item_to_string(found, str, len); + if(kmi) { + WM_keymap_item_to_string(kmi, str, len); return str; } return NULL; } -/* searches context and changes keymap item, if found */ -void WM_key_event_operator_change(const bContext *C, const char *opname, int opcontext, IDProperty *properties, short key, short modifier) -{ - wmKeymapItem *found= wm_keymap_item_find(C, opname, opcontext, properties, 1); +/* ***************** user preferences ******************* */ - if(!found) - found= wm_keymap_item_find(C, opname, opcontext, properties, 0); +wmKeyMap *WM_keymap_active(wmWindowManager *wm, wmKeyMap *keymap) +{ + wmKeyConfig *keyconf; + wmKeyMap *km; - if(found) { - keymap_event_set(found, key, KM_PRESS, modifier, 0); + if(!keymap) + return NULL; + + /* first user defined keymaps */ + km= wm_keymap_list_find(&U.keymaps, keymap->idname, keymap->spaceid, keymap->regionid); + if(km) + return km; + + /* then user key config */ + keyconf= wm_keyconfig_list_find(&wm->keyconfigs, U.keyconfigstr); + if(keyconf) { + km= wm_keymap_list_find(&keyconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid); + if(km) + return km; } + + /* then use default */ + km= wm_keymap_list_find(&wm->defaultconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid); + return km; } -/* ********************* */ +wmKeyMap *WM_keymap_copy_to_user(wmKeyMap *keymap) +{ + wmKeyMap *usermap; + wmKeyMapItem *kmi; + + usermap= wm_keymap_list_find(&U.keymaps, keymap->idname, keymap->spaceid, keymap->regionid); + + if(!usermap) { + /* not saved yet, duplicate existing */ + usermap= MEM_dupallocN(keymap); + usermap->modal_items= NULL; + usermap->poll= NULL; + usermap->flag |= KEYMAP_USER; + + BLI_addtail(&U.keymaps, usermap); + } + else { + /* already saved, free items for re-copy */ + WM_keymap_free(usermap); + } + + BLI_duplicatelist(&usermap->items, &keymap->items); + + for(kmi=usermap->items.first; kmi; kmi=kmi->next) { + if(kmi->properties) { + kmi->ptr= MEM_callocN(sizeof(PointerRNA), "UserKeyMapItemPtr"); + WM_operator_properties_create(kmi->ptr, kmi->idname); + + kmi->properties= IDP_CopyProperty(kmi->properties); + kmi->ptr->data= kmi->properties; + } + } + + for(kmi=keymap->items.first; kmi; kmi=kmi->next) + kmi->flag &= ~KMI_EXPANDED; + + return usermap; +} -int WM_key_event_is_tweak(short type) +void WM_keymap_restore_to_default(wmKeyMap *keymap) { - if(type>=EVT_TWEAK_L && type<=EVT_GESTURE) - return 1; - return 0; + wmKeyMap *usermap; + + usermap= wm_keymap_list_find(&U.keymaps, keymap->idname, keymap->spaceid, keymap->regionid); + + if(usermap) { + WM_keymap_free(usermap); + BLI_freelinkN(&U.keymaps, usermap); + } } +/* searches context and changes keymap item, if found */ +void WM_key_event_operator_change(const bContext *C, const char *opname, int opcontext, IDProperty *properties, short key, short modifier) +{ + wmWindowManager *wm= CTX_wm_manager(C); + wmKeyMap *keymap; + wmKeyMapItem *kmi; + + kmi= wm_keymap_item_find(C, opname, opcontext, properties, &keymap); + + if(kmi) { + /* if the existing one is in a default keymap, copy it + to user preferences, and lookup again so we get a + key map item from the user preferences we can modify */ + if(BLI_findindex(&wm->defaultconf->keymaps, keymap) >= 0) { + WM_keymap_copy_to_user(keymap); + kmi= wm_keymap_item_find(C, opname, opcontext, properties, NULL); + } + + keymap_event_set(kmi, key, KM_PRESS, modifier, 0); + } +} diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 9ec0ce0df8d..a92fcee48e2 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -517,22 +517,33 @@ int WM_operator_filesel(bContext *C, wmOperator *op, wmEvent *event) /* default properties for fileselect */ void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type) { - RNA_def_string_file_path(ot->srna, "path", "", FILE_MAX, "FilePath", "Path to file."); - RNA_def_string_file_name(ot->srna, "filename", "", FILE_MAX, "FileName", "Name of the file."); - RNA_def_string_dir_path(ot->srna, "directory", "", FILE_MAX, "Directory", "Directory of the file."); + PropertyRNA *prop; - RNA_def_boolean(ot->srna, "filter_blender", (filter & BLENDERFILE), "Filter .blend files", ""); - RNA_def_boolean(ot->srna, "filter_image", (filter & IMAGEFILE), "Filter image files", ""); - RNA_def_boolean(ot->srna, "filter_movie", (filter & MOVIEFILE), "Filter movie files", ""); - RNA_def_boolean(ot->srna, "filter_python", (filter & PYSCRIPTFILE), "Filter python files", ""); - RNA_def_boolean(ot->srna, "filter_font", (filter & FTFONTFILE), "Filter font files", ""); - RNA_def_boolean(ot->srna, "filter_sound", (filter & SOUNDFILE), "Filter sound files", ""); - RNA_def_boolean(ot->srna, "filter_text", (filter & TEXTFILE), "Filter text files", ""); - RNA_def_boolean(ot->srna, "filter_folder", (filter & FOLDERFILE), "Filter folders", ""); + RNA_def_string_file_path(ot->srna, "path", "", FILE_MAX, "File Path", "Path to file."); + RNA_def_string_file_name(ot->srna, "filename", "", FILE_MAX, "File Name", "Name of the file."); + RNA_def_string_dir_path(ot->srna, "directory", "", FILE_MAX, "Directory", "Directory of the file."); - RNA_def_int(ot->srna, "filemode", type, FILE_LOADLIB, FILE_SPECIAL, + prop= RNA_def_boolean(ot->srna, "filter_blender", (filter & BLENDERFILE), "Filter .blend files", ""); + RNA_def_property_flag(prop, PROP_HIDDEN); + prop= RNA_def_boolean(ot->srna, "filter_image", (filter & IMAGEFILE), "Filter image files", ""); + RNA_def_property_flag(prop, PROP_HIDDEN); + prop= RNA_def_boolean(ot->srna, "filter_movie", (filter & MOVIEFILE), "Filter movie files", ""); + RNA_def_property_flag(prop, PROP_HIDDEN); + prop= RNA_def_boolean(ot->srna, "filter_python", (filter & PYSCRIPTFILE), "Filter python files", ""); + RNA_def_property_flag(prop, PROP_HIDDEN); + prop= RNA_def_boolean(ot->srna, "filter_font", (filter & FTFONTFILE), "Filter font files", ""); + RNA_def_property_flag(prop, PROP_HIDDEN); + prop= RNA_def_boolean(ot->srna, "filter_sound", (filter & SOUNDFILE), "Filter sound files", ""); + RNA_def_property_flag(prop, PROP_HIDDEN); + prop= RNA_def_boolean(ot->srna, "filter_text", (filter & TEXTFILE), "Filter text files", ""); + RNA_def_property_flag(prop, PROP_HIDDEN); + prop= RNA_def_boolean(ot->srna, "filter_folder", (filter & FOLDERFILE), "Filter folders", ""); + RNA_def_property_flag(prop, PROP_HIDDEN); + + prop= RNA_def_int(ot->srna, "filemode", type, FILE_LOADLIB, FILE_SPECIAL, "File Browser Mode", "The setting for the file browser mode to load a .blend file, a library or a special file.", FILE_LOADLIB, FILE_SPECIAL); + RNA_def_property_flag(prop, PROP_HIDDEN); } /* op->poll */ @@ -1103,6 +1114,8 @@ static void WM_OT_link_append(wmOperatorType *ot) ot->exec= wm_link_append_exec; ot->poll= WM_operator_winactive; + ot->flag |= OPTYPE_UNDO; + WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_LOADLIB); RNA_def_boolean(ot->srna, "link", 1, "Link", "Link the objects or datablocks rather than appending."); @@ -1382,7 +1395,7 @@ static void wm_gesture_end(bContext *C, wmOperator *op) int WM_border_select_invoke(bContext *C, wmOperator *op, wmEvent *event) { - if(WM_key_event_is_tweak(event->type)) + if(ISTWEAK(event->type)) op->customdata= WM_gesture_new(C, event, WM_GESTURE_RECT); else op->customdata= WM_gesture_new(C, event, WM_GESTURE_CROSS_RECT); @@ -2146,9 +2159,9 @@ void wm_operatortype_init(void) } /* default keymap for windows and screens, only call once per WM */ -void wm_window_keymap(wmWindowManager *wm) +void wm_window_keymap(wmKeyConfig *keyconf) { - wmKeyMap *keymap= WM_keymap_find(wm, "Window", 0, 0); + wmKeyMap *keymap= WM_keymap_find(keyconf, "Window", 0, 0); /* items to make WM work */ WM_keymap_verify_item(keymap, "WM_OT_jobs_timer", TIMERJOBS, KM_ANY, KM_ANY, 0); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index e3cfb9ad60d..44b7b60e451 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -373,15 +373,15 @@ void wm_window_add_ghostwindows(wmWindowManager *wm) /* happens after fileread */ if(win->eventstate==NULL) win->eventstate= MEM_callocN(sizeof(wmEvent), "window event state"); - + /* add keymap handlers (1 handler for all keys in map!) */ - keymap= WM_keymap_find(wm, "Window", 0, 0); + keymap= WM_keymap_find(wm->defaultconf, "Window", 0, 0); WM_event_add_keymap_handler(&win->handlers, keymap); - keymap= WM_keymap_find(wm, "Screen", 0, 0); + keymap= WM_keymap_find(wm->defaultconf, "Screen", 0, 0); WM_event_add_keymap_handler(&win->handlers, keymap); - keymap= WM_keymap_find(wm, "Screen Editing", 0, 0); + keymap= WM_keymap_find(wm->defaultconf, "Screen Editing", 0, 0); WM_event_add_keymap_handler(&win->modalhandlers, keymap); wm_window_title(wm, win); diff --git a/source/blender/windowmanager/wm.h b/source/blender/windowmanager/wm.h index a7529157072..832558b961f 100644 --- a/source/blender/windowmanager/wm.h +++ b/source/blender/windowmanager/wm.h @@ -54,7 +54,7 @@ extern void wm_report_free(wmReport *report); /* wm_operator.c, for init/exit */ void wm_operatortype_free(void); void wm_operatortype_init(void); -void wm_window_keymap(wmWindowManager *wm); +void wm_window_keymap(wmKeyConfig *keyconf); void wm_tweakevent_test(bContext *C, wmEvent *event, int action); diff --git a/source/blender/windowmanager/wm_event_system.h b/source/blender/windowmanager/wm_event_system.h index 4360e49e371..4322f70ea61 100644 --- a/source/blender/windowmanager/wm_event_system.h +++ b/source/blender/windowmanager/wm_event_system.h @@ -44,7 +44,6 @@ typedef struct wmEventHandler { /* keymap handler */ wmKeyMap *keymap; /* pointer to builtin/custom keymaps */ - rcti *bblocal, *bbwin; /* optional local and windowspace bb */ /* modal operator handler */ diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h index cc6041ce529..b33c4bd14e8 100644 --- a/source/blender/windowmanager/wm_event_types.h +++ b/source/blender/windowmanager/wm_event_types.h @@ -199,9 +199,17 @@ /* test wether the event is a key on the keyboard */ #define ISKEYBOARD(event) (event >=' ' && event <=320) -/* test whether event type is acceptable as hotkey, excluding modifiers */ -#define ISHOTKEY(event) (ISKEYBOARD(event) && !(event>=LEFTCTRLKEY && event<=ESCKEY) && !(event>=UNKNOWNKEY && event<=GRLESSKEY)) + /* test wether the event is a mouse button */ +#define ISMOUSE(event) (event >= LEFTMOUSE && event <= WHEELOUTMOUSE) + + /* test wether the event is timer event */ +#define ISTIMER(event) (event >= TIMER && event <= TIMERJOBS) + /* test wether the event is tweak event */ +#define ISTWEAK(event) (event >= EVT_TWEAK_L && event <= EVT_GESTURE) + +/* test whether event type is acceptable as hotkey, excluding modifiers */ +#define ISHOTKEY(event) ((ISKEYBOARD(event) || ISMOUSE(event)) && !(event>=LEFTCTRLKEY && event<=ESCKEY) && !(event>=UNKNOWNKEY && event<=GRLESSKEY)) /* **************** BLENDER GESTURE EVENTS ********************* */ |