2.5
authorTon Roosendaal <ton@blender.org>
Thu, 1 Jan 2009 14:57:04 +0000 (14:57 +0000)
committerTon Roosendaal <ton@blender.org>
Thu, 1 Jan 2009 14:57:04 +0000 (14:57 +0000)
- 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.

source/blender/editors/include/ED_screen.h
source/blender/editors/interface/view2d_ops.c
source/blender/editors/object/object_edit.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/space_view3d/view3d_ops.c
source/blender/windowmanager/WM_types.h
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/wm_event_types.h

index 95ac858bb09d6cd4fd331cbe19686fd37ff5e5b3..7d896c91fd4952a85166598b9b56f0ea28bf64ea 100644 (file)
@@ -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);
index bb4e9e39fbcdec20802e0fc5e88d4adda3631457..e5f0835be35b9a4ca4012dae521126cce9e2f79e 100644 (file)
@@ -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);
index 0c85d4c9eb5378f5c8819d54e2466ca6f5c36d14..8eb51192d8a71064c59fbe6e2d74a85f2d12a5b1 100644 (file)
@@ -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;
 }
 
index d65c4d0f504dda02576fd35c55e1f251e8ce3889..6c4ccad6a330825c55c6a8a9a244c0d5aedf7c7f 100644 (file)
@@ -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)) {
index 9901fc11c43403945d3a6d3b00d7368d7909afa8..df33d2c660ed53861179b412b0f0fb6b656017af 100644 (file)
@@ -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);
index 770c3481b8f4310d5c4a8f20eb63bec7c8ffb0a9..fe9650094a2bd0c26c448e43b866619c02653ee3 100644 (file)
@@ -102,6 +102,7 @@ typedef struct wmEvent {
 #define KM_RELEASE     0
 #define KM_PRESS       1
 
+
 /* ************** UI Handler ***************** */
 
 #define WM_UI_HANDLER_CONTINUE 0
index 6e53b1308173f0be8f98f6afc8ef1708e1a434ff..be977530fad80958677231895453cd8affc5aac8 100644 (file)
@@ -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;
index 91427579c29b9a6dfaaff9b90cc62aa741d8a760..87dbd337d32b8c06a7d62678093ffc4927f257f3 100644 (file)
                /* 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 */