diff options
author | Joshua Leung <aligorith@gmail.com> | 2010-04-02 07:52:44 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2010-04-02 07:52:44 +0400 |
commit | 7b98f6220b2ce1739331f87722e0f88a78ba1a92 (patch) | |
tree | 6205f5dafdd83b85910503422e096c9ab600cc4d | |
parent | 174696fd542e966bc218957cc9a73eea14aefa06 (diff) |
Bugfix #21853: Border zoom in the 2D-Views zooms out
* Fixed the way the operator was checking for what the user wanted when using the operator
* Added a few specific defines to a copy of the gesture border modal keymap (added one for zooming only) labelled 'In' and 'Out' which make this more useful than being hacked to use select and deselect
-rw-r--r-- | source/blender/editors/animation/keyframing.c | 4 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d_ops.c | 11 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 39 | ||||
-rw-r--r-- | source/blender/windowmanager/wm_event_types.h | 3 |
4 files changed, 48 insertions, 9 deletions
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 800b0248728..02b79770941 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -286,7 +286,9 @@ int insert_vert_fcurve (FCurve *fcu, float x, float y, short flag) BezTriple beztr; int a; - /* set all three points, for nicer start position */ + /* set all three points, for nicer start position + * NOTE: +/- 1 on vec.x for left and right handles is so that 'free' handles work ok... + */ memset(&beztr, 0, sizeof(BezTriple)); beztr.vec[0][0]= x-1.0f; beztr.vec[0][1]= y; diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 4039e975724..8e760a7501c 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -1038,17 +1038,16 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op) ARegion *ar= CTX_wm_region(C); View2D *v2d= &ar->v2d; rctf rect; - int event_type; + int gesture_mode; /* convert coordinates of rect to 'tot' rect coordinates */ UI_view2d_region_to_view(v2d, RNA_int_get(op->ptr, "xmin"), RNA_int_get(op->ptr, "ymin"), &rect.xmin, &rect.ymin); UI_view2d_region_to_view(v2d, RNA_int_get(op->ptr, "xmax"), RNA_int_get(op->ptr, "ymax"), &rect.xmax, &rect.ymax); /* check if zooming in/out view */ - // XXX hardcoded for now! - event_type= RNA_int_get(op->ptr, "event_type"); + gesture_mode= RNA_int_get(op->ptr, "gesture_mode"); - if (event_type == LEFTMOUSE) { + if (gesture_mode == GESTURE_MODAL_IN) { /* zoom in: * - 'cur' rect will be defined by the coordinates of the border region * - just set the 'cur' rect to have the same coordinates as the border region @@ -1063,7 +1062,7 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op) v2d->cur.ymax= rect.ymax; } } - else { + else /* if (gesture_mode == GESTURE_MODAL_OUT) */ { /* zoom out: * - the current 'cur' rect coordinates are going to end upwhere the 'rect' ones are, * but the 'cur' rect coordinates will need to be adjusted to take in more of the view @@ -1116,7 +1115,7 @@ void VIEW2D_OT_zoom_border(wmOperatorType *ot) ot->poll= view_zoom_poll; /* rna */ - RNA_def_int(ot->srna, "event_type", 0, INT_MIN, INT_MAX, "Event Type", "", INT_MIN, INT_MAX); + RNA_def_int(ot->srna, "gesture_mode", 0, INT_MIN, INT_MAX, "Gesture Mode", "", INT_MIN, INT_MAX); RNA_def_int(ot->srna, "xmin", 0, INT_MIN, INT_MAX, "X Min", "", INT_MIN, INT_MAX); RNA_def_int(ot->srna, "xmax", 0, INT_MIN, INT_MAX, "X Max", "", INT_MIN, INT_MAX); RNA_def_int(ot->srna, "ymin", 0, INT_MIN, INT_MAX, "Y Min", "", INT_MIN, INT_MAX); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 7e5aa2ad8f4..535dd5f1a62 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2070,6 +2070,8 @@ int WM_border_select_modal(bContext *C, wmOperator *op, wmEvent *event) break; case GESTURE_MODAL_SELECT: case GESTURE_MODAL_DESELECT: + case GESTURE_MODAL_IN: + case GESTURE_MODAL_OUT: if(border_apply(C, op, event->val)) { wm_gesture_end(C, op); return OPERATOR_FINISHED; @@ -2843,7 +2845,7 @@ void wm_operatortype_init(void) } -/* called in transform_ops.c, on each regeneration of keymaps */ +/* circleselect-like modal operators */ static void gesture_circle_modal_keymap(wmKeyConfig *keyconf) { static EnumPropertyItem modal_items[] = { @@ -2896,7 +2898,7 @@ static void gesture_circle_modal_keymap(wmKeyConfig *keyconf) } -/* called in transform_ops.c, on each regeneration of keymaps */ +/* borderselect-like modal operators */ static void gesture_border_modal_keymap(wmKeyConfig *keyconf) { static EnumPropertyItem modal_items[] = { @@ -2948,6 +2950,38 @@ static void gesture_border_modal_keymap(wmKeyConfig *keyconf) WM_modalkeymap_assign(keymap, "VIEW3D_OT_zoom_border"); // XXX TODO: zoom border should perhaps map rightmouse to zoom out instead of in+cancel } +/* zoom to border modal operators */ +static void gesture_zoom_border_modal_keymap(wmKeyConfig *keyconf) +{ + static EnumPropertyItem modal_items[] = { + {GESTURE_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, + {GESTURE_MODAL_IN, "IN", 0, "In", ""}, + {GESTURE_MODAL_OUT, "OUT", 0, "Out", ""}, + {GESTURE_MODAL_BORDER_BEGIN, "BEGIN", 0, "Begin", ""}, + {0, NULL, 0, NULL, NULL}}; + + wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "Gesture Zoom Border"); + + /* this function is called for each spacetype, only needs to add map once */ + if(keymap) return; + + keymap= WM_modalkeymap_add(keyconf, "Gesture Zoom Border", modal_items); + + /* items for modal map */ + WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, GESTURE_MODAL_CANCEL); + WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_ANY, KM_ANY, 0, GESTURE_MODAL_CANCEL); + + WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, 0, 0, GESTURE_MODAL_BORDER_BEGIN); + WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_RELEASE, 0, 0, GESTURE_MODAL_IN); + + WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_PRESS, 0, 0, GESTURE_MODAL_BORDER_BEGIN); + WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, 0, 0, GESTURE_MODAL_OUT); + + /* assign map to operators */ + WM_modalkeymap_assign(keymap, "VIEW2D_OT_zoom_border"); + WM_modalkeymap_assign(keymap, "VIEW3D_OT_zoom_border"); +} + /* default keymap for windows and screens, only call once per WM */ void wm_window_keymap(wmKeyConfig *keyconf) { @@ -3035,6 +3069,7 @@ void wm_window_keymap(wmKeyConfig *keyconf) gesture_circle_modal_keymap(keyconf); gesture_border_modal_keymap(keyconf); + gesture_zoom_border_modal_keymap(keyconf); } /* Generic itemf's for operators that take library args */ diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h index 5f6af878976..59dddbaea5b 100644 --- a/source/blender/windowmanager/wm_event_types.h +++ b/source/blender/windowmanager/wm_event_types.h @@ -283,6 +283,9 @@ #define GESTURE_MODAL_BORDER_BEGIN 8 /* border select, activate, use release to detect which button */ +#define GESTURE_MODAL_IN 9 +#define GESTURE_MODAL_OUT 10 + #endif /* WM_EVENT_TYPES_H */ |