diff options
author | Ton Roosendaal <ton@blender.org> | 2009-01-01 17:57:04 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2009-01-01 17:57:04 +0300 |
commit | a1961436f564ad885a014dc964d443378a4b9617 (patch) | |
tree | 5dd883b97048d8474b5c5f31302686610c2084c0 /source/blender | |
parent | e9a3b4f85df2261cafea0bfc9f0a885708cdf9d6 (diff) |
2.5
- Made scrollwheel behave uniform for zooming. It uses the UserDef
to map what's in our out. Use keymap entries WHEELINMOUSE and
WHEELOUTMOUSE to trigger this. Also removed the feature to store
in event->val the direction, it was conflicting with KM_ANY.
- Added more default poll callbacks, use for generic ops things
like ED_operator_object_active.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/include/ED_screen.h | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d_ops.c | 20 | ||||
-rw-r--r-- | source/blender/editors/object/object_edit.c | 20 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_ops.c | 4 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_types.h | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 18 | ||||
-rw-r--r-- | source/blender/windowmanager/wm_event_types.h | 7 |
8 files changed, 53 insertions, 27 deletions
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 95ac858bb09..7d896c91fd4 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -84,6 +84,8 @@ int ED_operator_screenactive(struct bContext *C); int ED_operator_screen_mainwinactive(struct bContext *C); int ED_operator_areaactive(struct bContext *C); +int ED_operator_scene_editable(struct bContext *C); + int ED_operator_view3d_active(struct bContext *C); int ED_operator_timeline_active(struct bContext *C); int ED_operator_outliner_active(struct bContext *C); diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index bb4e9e39fbc..e5f0835be35 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -1273,25 +1273,25 @@ void UI_view2d_keymap(wmWindowManager *wm) /* pan/scroll */ WM_keymap_add_item(keymap, "View2D_OT_view_pan", MIDDLEMOUSE, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "View2D_OT_view_rightscroll", WHEELDOWNMOUSE, KM_ANY, KM_CTRL, 0); - WM_keymap_add_item(keymap, "View2D_OT_view_leftscroll", WHEELUPMOUSE, KM_ANY, KM_CTRL, 0); + WM_keymap_add_item(keymap, "View2D_OT_view_rightscroll", WHEELDOWNMOUSE, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "View2D_OT_view_leftscroll", WHEELUPMOUSE, KM_PRESS, KM_CTRL, 0); - WM_keymap_add_item(keymap, "View2D_OT_view_downscroll", WHEELDOWNMOUSE, KM_ANY, KM_SHIFT, 0); - WM_keymap_add_item(keymap, "View2D_OT_view_upscroll", WHEELUPMOUSE, KM_ANY, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "View2D_OT_view_downscroll", WHEELDOWNMOUSE, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "View2D_OT_view_upscroll", WHEELUPMOUSE, KM_PRESS, KM_SHIFT, 0); /* zoom - single step */ - WM_keymap_add_item(keymap, "View2D_OT_view_zoomout", WHEELUPMOUSE, KM_ANY, 0, 0); - WM_keymap_add_item(keymap, "View2D_OT_view_zoomin", WHEELDOWNMOUSE, KM_ANY, 0, 0); + WM_keymap_add_item(keymap, "View2D_OT_view_zoomout", WHEELOUTMOUSE, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "View2D_OT_view_zoomin", WHEELINMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "View2D_OT_view_zoomout", PADMINUS, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "View2D_OT_view_zoomin", PADPLUSKEY, KM_PRESS, 0, 0); /* scroll up/down - no modifiers, only when zoom fails */ /* these may fail if zoom is disallowed, in which case they should pass on event */ - WM_keymap_add_item(keymap, "View2D_OT_view_downscroll", WHEELDOWNMOUSE, KM_ANY, 0, 0); - WM_keymap_add_item(keymap, "View2D_OT_view_upscroll", WHEELUPMOUSE, KM_ANY, 0, 0); + WM_keymap_add_item(keymap, "View2D_OT_view_downscroll", WHEELDOWNMOUSE, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "View2D_OT_view_upscroll", WHEELUPMOUSE, KM_PRESS, 0, 0); /* these may be necessary if vertical scroll is disallowed */ - WM_keymap_add_item(keymap, "View2D_OT_view_rightscroll", WHEELDOWNMOUSE, KM_ANY, 0, 0); - WM_keymap_add_item(keymap, "View2D_OT_view_leftscroll", WHEELUPMOUSE, KM_ANY, 0, 0); + WM_keymap_add_item(keymap, "View2D_OT_view_rightscroll", WHEELDOWNMOUSE, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "View2D_OT_view_leftscroll", WHEELUPMOUSE, KM_PRESS, 0, 0); /* zoom - drag */ WM_keymap_add_item(keymap, "View2D_OT_view_zoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 0c85d4c9eb5..8eb51192d8a 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1014,7 +1014,7 @@ void OBJECT_OT_clear_parent(wmOperatorType *ot) ot->invoke= WM_menu_invoke; ot->exec= clear_parent_exec; - ot->poll= ED_operator_areaactive; // XXX solve + ot->poll= ED_operator_object_active; ot->flag= OPTYPE_REGISTER; prop = RNA_def_property(ot->srna, "type", PROP_ENUM, PROP_NONE); @@ -1067,7 +1067,7 @@ void OBJECT_OT_clear_track(wmOperatorType *ot) ot->invoke= WM_menu_invoke; ot->exec= object_clear_track_exec; - ot->poll= ED_operator_areaactive; // XXX solve + ot->poll= ED_operator_scene_editable; ot->flag= OPTYPE_REGISTER; prop = RNA_def_property(ot->srna, "type", PROP_ENUM, PROP_NONE); @@ -1120,7 +1120,7 @@ void OBJECT_OT_select_by_type(wmOperatorType *ot) /* api callbacks */ ot->invoke= WM_menu_invoke; ot->exec= object_select_by_type_exec; - ot->poll= ED_operator_view3d_active; + ot->poll= ED_operator_scene_editable; prop = RNA_def_property(ot->srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, prop_select_object_types); @@ -1158,7 +1158,7 @@ void OBJECT_OT_select_by_layer(wmOperatorType *ot) /* api callbacks */ /*ot->invoke = XXX - need a int grid popup*/ ot->exec= object_select_by_layer_exec; - ot->poll= ED_operator_view3d_active; + ot->poll= ED_operator_scene_editable; prop = RNA_def_property(ot->srna, "layer", PROP_INT, PROP_UNSIGNED); RNA_def_property_ui_range(prop, 1, 20,1, 1); @@ -1193,7 +1193,7 @@ void OBJECT_OT_select_invert(wmOperatorType *ot) /* api callbacks */ ot->exec= object_select_invert_exec; - ot->poll= ED_operator_view3d_active; + ot->poll= ED_operator_scene_editable; } /* ****** (de)select All *******/ @@ -1234,7 +1234,7 @@ void OBJECT_OT_de_select_all(wmOperatorType *ot) /* api callbacks */ ot->exec= object_de_select_all_exec; - ot->poll= ED_operator_view3d_active; + ot->poll= ED_operator_scene_editable; } /* ****** random selection *******/ @@ -1269,7 +1269,7 @@ void OBJECT_OT_select_random(wmOperatorType *ot) /* api callbacks */ /*ot->invoke= object_select_random_invoke XXX - need a number popup ;*/ ot->exec = object_select_random_exec; - ot->poll= ED_operator_view3d_active; + ot->poll= ED_operator_scene_editable; prop = RNA_def_property(ot->srna, "percent", PROP_INT, PROP_NONE); RNA_def_property_ui_range(prop, 1, 100,1, 1); @@ -1876,7 +1876,7 @@ void OBJECT_OT_make_parent(wmOperatorType *ot) ot->invoke= make_parent_invoke; ot->exec= make_parent_exec; - ot->poll= ED_operator_areaactive; // XXX solve + ot->poll= ED_operator_object_active; ot->flag= OPTYPE_REGISTER; prop = RNA_def_property(ot->srna, "type", PROP_ENUM, PROP_NONE); @@ -1982,7 +1982,7 @@ void OBJECT_OT_make_track(wmOperatorType *ot) ot->invoke= WM_menu_invoke; ot->exec= make_track_exec; - ot->poll= ED_operator_areaactive; // XXX solve + ot->poll= ED_operator_scene_editable; ot->flag= OPTYPE_REGISTER; prop = RNA_def_property(ot->srna, "type", PROP_ENUM, PROP_NONE); @@ -2176,7 +2176,7 @@ void OBJECT_OT_toggle_editmode(wmOperatorType *ot) /* api callbacks */ ot->exec= toggle_editmode_exec; - ot->poll= ED_operator_areaactive; // XXX solve + ot->poll= ED_operator_object_active; ot->flag= OPTYPE_REGISTER; } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index d65c4d0f504..6c4ccad6a33 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -79,6 +79,14 @@ int ED_operator_screen_mainwinactive(bContext *C) return 1; } +int ED_operator_scene_editable(bContext *C) +{ + Scene *scene= CTX_data_scene(C); + if(scene && scene->id.lib==NULL) + return 1; + return 0; +} + static int ed_spacetype_test(bContext *C, int type) { if(ED_operator_areaactive(C)) { diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 9901fc11c43..df33d2c660e 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -95,8 +95,8 @@ void view3d_keymap(wmWindowManager *wm) RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewzoom", PADPLUSKEY, KM_PRESS, 0, 0)->ptr, "delta", 1); RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewzoom", PADMINUS, KM_PRESS, 0, 0)->ptr, "delta", -1); - RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewzoom", WHEELUPMOUSE, KM_ANY, 0, 0)->ptr, "delta", 1); - RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewzoom", WHEELDOWNMOUSE, KM_ANY, 0, 0)->ptr, "delta", -1); + RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewzoom", WHEELINMOUSE, KM_PRESS, 0, 0)->ptr, "delta", 1); + RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewzoom", WHEELOUTMOUSE, KM_PRESS, 0, 0)->ptr, "delta", -1); RNA_boolean_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewhome", HOMEKEY, KM_PRESS, 0, 0)->ptr, "center", 0); RNA_boolean_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewhome", CKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "center", 1); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 770c3481b8f..fe9650094a2 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -102,6 +102,7 @@ typedef struct wmEvent { #define KM_RELEASE 0 #define KM_PRESS 1 + /* ************** UI Handler ***************** */ #define WM_UI_HANDLER_CONTINUE 0 diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 6e53b130817..be977530fad 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -534,19 +534,31 @@ static int wm_eventmatch(wmEvent *winevent, wmKeymapItem *kmi) { int kmitype= kmi->type; - /* first do default mappings */ + /* first do userdef mappings */ if(kmitype==SELECTMOUSE) { if(U.flag & USER_LMOUSESELECT) kmitype= LEFTMOUSE; else kmitype= RIGHTMOUSE; } - if(kmitype==ACTIONMOUSE) { + else if(kmitype==ACTIONMOUSE) { if(U.flag & USER_LMOUSESELECT) kmitype= RIGHTMOUSE; else kmitype= LEFTMOUSE; } + else if(kmitype==WHEELOUTMOUSE) { + if(U.uiflag & USER_WHEELZOOMDIR) + kmitype= WHEELUPMOUSE; + else + kmitype= WHEELDOWNMOUSE; + } + else if(kmitype==WHEELINMOUSE) { + if(U.uiflag & USER_WHEELZOOMDIR) + kmitype= WHEELDOWNMOUSE; + else + kmitype= WHEELUPMOUSE; + } /* the matching rules */ if(winevent->type!=kmitype) return 0; @@ -1133,7 +1145,7 @@ void wm_event_add_ghostevent(wmWindow *win, int type, void *customdata) else event.type= WHEELDOWNMOUSE; - event.val= wheelData->z; /* currently -1 or +1, see ghost for improvements here... */ + event.val= KM_PRESS; wm_event_add(win, &event); break; diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h index 91427579c29..87dbd337d32 100644 --- a/source/blender/windowmanager/wm_event_types.h +++ b/source/blender/windowmanager/wm_event_types.h @@ -51,9 +51,12 @@ /* only use if you want user option switch possible */ #define ACTIONMOUSE 0x005 #define SELECTMOUSE 0x006 - + /* defaults from ghost */ #define WHEELUPMOUSE 0x00a -#define WHEELDOWNMOUSE 0x00b +#define WHEELDOWNMOUSE 0x00b + /* mapped with userdef */ +#define WHEELINMOUSE 0x00c +#define WHEELOUTMOUSE 0x00d /* SYSTEM : 0x01x */ |