From 364b6b29ff2ea19a31fdfc8e08b75ce0d46df40b Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Mon, 13 Apr 2015 14:30:17 +0200 Subject: New operator for action and graph editor that centers around current scene frame, bound to numberpad zero. --- source/blender/editors/interface/view2d_ops.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source/blender/editors/interface/view2d_ops.c') diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 88140d897ae..5730c967880 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -1462,6 +1462,21 @@ void UI_view2d_smooth_view(bContext *C, ARegion *ar, } } +void UI_view2d_center_frame(struct bContext *C, int smooth_viewtx) +{ + ARegion *ar = CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); + float w = BLI_rctf_size_x(&ar->v2d.cur); + rctf newrct; + + newrct.xmax = scene->r.cfra + (w / 2); + newrct.xmin = scene->r.cfra - (w / 2); + newrct.ymax = ar->v2d.cur.ymax; + newrct.ymin = ar->v2d.cur.ymin; + + UI_view2d_smooth_view(C, ar, &newrct, smooth_viewtx); +} + /* only meant for timer usage */ static int view2d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) { -- cgit v1.2.3 From 912397756a8adfde91e2c307ab9f17d873e002f8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 21 Apr 2015 13:10:32 +1000 Subject: Fix T44432: Zoom to mouse fails /w FCurve editor --- source/blender/editors/interface/view2d_ops.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source/blender/editors/interface/view2d_ops.c') diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 5730c967880..58b51ef8e28 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -661,7 +661,9 @@ static void view_zoomstep_apply_ex(bContext *C, v2dViewZoomData *vzd, const bool const float zoomx = (float)(BLI_rcti_size_x(&v2d->mask) + 1) / BLI_rctf_size_x(&v2d->cur); /* only move view to mouse if zoom fac is inside minzoom/maxzoom */ - if (IN_RANGE_INCL(zoomx, v2d->minzoom, v2d->maxzoom)) { + if (((v2d->keepzoom & V2D_LIMITZOOM) == 0) || + IN_RANGE_INCL(zoomx, v2d->minzoom, v2d->maxzoom)) + { float mval_fac = (vzd->mx_2d - cur_old.xmin) / BLI_rctf_size_x(&cur_old); float mval_faci = 1.0f - mval_fac; float ofs = (mval_fac * dx) - (mval_faci * dx); @@ -692,7 +694,9 @@ static void view_zoomstep_apply_ex(bContext *C, v2dViewZoomData *vzd, const bool const float zoomy = (float)(BLI_rcti_size_y(&v2d->mask) + 1) / BLI_rctf_size_y(&v2d->cur); /* only move view to mouse if zoom fac is inside minzoom/maxzoom */ - if (IN_RANGE_INCL(zoomy, v2d->minzoom, v2d->maxzoom)) { + if (((v2d->keepzoom & V2D_LIMITZOOM) == 0) || + IN_RANGE_INCL(zoomy, v2d->minzoom, v2d->maxzoom)) + { float mval_fac = (vzd->my_2d - cur_old.ymin) / BLI_rctf_size_y(&cur_old); float mval_faci = 1.0f - mval_fac; float ofs = (mval_fac * dy) - (mval_faci * dy); -- cgit v1.2.3 From 5e1eb8cdcf6aca9ad55aa040ca914c17b717c102 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 27 Apr 2015 18:44:27 +1000 Subject: Cleanup: rename GRAB_POINTER -> GRAB_CURSOR Term pointer is overloaded already. --- source/blender/editors/interface/view2d_ops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/editors/interface/view2d_ops.c') diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 58b51ef8e28..816c9a93d8c 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -328,7 +328,7 @@ static void VIEW2D_OT_pan(wmOperatorType *ot) ot->cancel = view_pan_cancel; /* operator is modal */ - ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_POINTER; + ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR; /* rna - must keep these in sync with the other operators */ RNA_def_int(ot->srna, "deltax", 0, INT_MIN, INT_MAX, "Delta X", "", INT_MIN, INT_MAX); @@ -1179,7 +1179,7 @@ static void VIEW2D_OT_zoom(wmOperatorType *ot) ot->poll = view_zoom_poll; /* operator is repeatable */ - ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_POINTER; + ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR; /* rna - must keep these in sync with the other operators */ prop = RNA_def_float(ot->srna, "deltax", 0, -FLT_MAX, FLT_MAX, "Delta X", "", -FLT_MAX, FLT_MAX); -- cgit v1.2.3 From 7478eb9bd09965f7d27064b500c91322f4fe3f14 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 5 May 2015 03:13:47 +1000 Subject: Cleanup: wrapped function indentation --- source/blender/editors/interface/view2d_ops.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source/blender/editors/interface/view2d_ops.c') diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 816c9a93d8c..9fed02ee096 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -620,8 +620,9 @@ static int view_zoom_poll(bContext *C) } /* apply transform to view (i.e. adjust 'cur' rect) */ -static void view_zoomstep_apply_ex(bContext *C, v2dViewZoomData *vzd, const bool use_mousepos, - const float facx, const float facy) +static void view_zoomstep_apply_ex( + bContext *C, v2dViewZoomData *vzd, const bool use_mousepos, + const float facx, const float facy) { ARegion *ar = CTX_wm_region(C); View2D *v2d = &ar->v2d; @@ -1406,8 +1407,9 @@ static float smooth_view_rect_to_fac(const rctf *rect_a, const rctf *rect_b) /* will start timer if appropriate */ /* the arguments are the desired situation */ -void UI_view2d_smooth_view(bContext *C, ARegion *ar, - const rctf *cur, const int smooth_viewtx) +void UI_view2d_smooth_view( + bContext *C, ARegion *ar, + const rctf *cur, const int smooth_viewtx) { wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win = CTX_wm_window(C); -- cgit v1.2.3 From e4c93dc7db9b50acf898b667c95b208856b80ea8 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Wed, 13 May 2015 20:30:53 +0200 Subject: Zoom to frame options, requested by the Hwoozeberry (dutch translation) team. There are 3 options here: 1) Keep range (previous behaviour) 2) Seconds - allows a specified offset in seconds around current frame 3) keyframes - zoom to include a number of keyframes around the cursor Options 2 and 3 have their own properties to tweak the behaviour and all options can be found in User Preferences->Interface under the 2D viewports section. Number 3 will probably need some refinement so commiting here for the hwoozeberry team to test first. --- source/blender/editors/interface/view2d_ops.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'source/blender/editors/interface/view2d_ops.c') diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 9fed02ee096..eafc5c1d24c 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -1468,21 +1468,6 @@ void UI_view2d_smooth_view( } } -void UI_view2d_center_frame(struct bContext *C, int smooth_viewtx) -{ - ARegion *ar = CTX_wm_region(C); - Scene *scene = CTX_data_scene(C); - float w = BLI_rctf_size_x(&ar->v2d.cur); - rctf newrct; - - newrct.xmax = scene->r.cfra + (w / 2); - newrct.xmin = scene->r.cfra - (w / 2); - newrct.ymax = ar->v2d.cur.ymax; - newrct.ymin = ar->v2d.cur.ymin; - - UI_view2d_smooth_view(C, ar, &newrct, smooth_viewtx); -} - /* only meant for timer usage */ static int view2d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) { -- cgit v1.2.3 From 67bebc42f4a789487583b7e2c7f1174910ab67f9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 31 May 2015 14:20:03 +1000 Subject: UI: comments (doxygen tweaks) --- source/blender/editors/interface/view2d_ops.c | 79 ++++++++++++++++----------- 1 file changed, 47 insertions(+), 32 deletions(-) (limited to 'source/blender/editors/interface/view2d_ops.c') diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index eafc5c1d24c..6fbe8509188 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -63,12 +63,13 @@ static int view2d_poll(bContext *C) /* ********************************************************* */ /* VIEW PANNING OPERATOR */ -/* This group of operators come in several forms: - * 1) Modal 'dragging' with MMB - where movement of mouse dictates amount to pan view by - * 2) Scrollwheel 'steps' - rolling mousewheel by one step moves view by predefined amount +/** + * This group of operators come in several forms: + * -# Modal 'dragging' with MMB - where movement of mouse dictates amount to pan view by + * -# Scrollwheel 'steps' - rolling mousewheel by one step moves view by predefined amount * - * In order to make sure this works, each operator must define the following RNA-Operator Props: - * deltax, deltay - define how much to move view by (relative to zoom-correction factor) + * In order to make sure this works, each operator must define the following RNA-Operator Props: + * - `deltax, deltay` - define how much to move view by (relative to zoom-correction factor) */ /* ------------------ Shared 'core' stuff ---------------------- */ @@ -525,15 +526,18 @@ static void VIEW2D_OT_scroll_up(wmOperatorType *ot) /* ********************************************************* */ /* SINGLE-STEP VIEW ZOOMING OPERATOR */ -/* This group of operators come in several forms: - * 1) Scrollwheel 'steps' - rolling mousewheel by one step zooms view by predefined amount - * 2) Scrollwheel 'steps' + alt + ctrl/shift - zooms view on one axis only (ctrl=x, shift=y) // XXX this could be implemented... - * 3) Pad +/- Keys - pressing each key moves the zooms the view by a predefined amount +/** + * This group of operators come in several forms: + * -# Scrollwheel 'steps' - rolling mousewheel by one step zooms view by predefined amount. + * -# Scrollwheel 'steps' + alt + ctrl/shift - zooms view on one axis only (ctrl=x, shift=y). + * XXX this could be implemented... + * -# Pad +/- Keys - pressing each key moves the zooms the view by a predefined amount. * * In order to make sure this works, each operator must define the following RNA-Operator Props: - * zoomfacx, zoomfacy - These two zoom factors allow for non-uniform scaling. - * It is safe to scale by 0, as these factors are used to determine - * amount to enlarge 'cur' by + * + * - zoomfacx, zoomfacy - These two zoom factors allow for non-uniform scaling. + * It is safe to scale by 0, as these factors are used to determine. + * amount to enlarge 'cur' by. */ /* ------------------ 'Shared' stuff ------------------------ */ @@ -872,10 +876,11 @@ static void VIEW2D_OT_zoom_out(wmOperatorType *ot) /* ********************************************************* */ /* DRAG-ZOOM OPERATOR */ -/* MMB Drag - allows non-uniform scaling by dragging mouse +/** + * MMB Drag - allows non-uniform scaling by dragging mouse * - * In order to make sure this works, each operator must define the following RNA-Operator Props: - * deltax, deltay - amounts to add to each side of the 'cur' rect + * In order to make sure this works, each operator must define the following RNA-Operator Props: + * - `deltax, deltay` - amounts to add to each side of the 'cur' rect */ /* apply transform to view (i.e. adjust 'cur' rect) */ @@ -1192,10 +1197,12 @@ static void VIEW2D_OT_zoom(wmOperatorType *ot) /* ********************************************************* */ /* BORDER-ZOOM */ -/* The user defines a rect using standard borderselect tools, and we use this rect to +/** + * The user defines a rect using standard borderselect tools, and we use this rect to * define the new zoom-level of the view in the following ways: - * 1) LEFTMOUSE - zoom in to view - * 2) RIGHTMOUSE - zoom out of view + * + * -# LEFTMOUSE - zoom in to view + * -# RIGHTMOUSE - zoom out of view * * Currently, these key mappings are hardcoded, but it shouldn't be too important to * have custom keymappings for this... @@ -1534,13 +1541,14 @@ static void VIEW2D_OT_smoothview(wmOperatorType *ot) /* ********************************************************* */ /* SCROLLERS */ -/* Scrollers should behave in the following ways, when clicked on with LMB (and dragged): - * 1) 'Handles' on end of 'bubble' - when the axis that the scroller represents is zoomable, - * enlarge 'cur' rect on the relevant side - * 2) 'Bubble'/'bar' - just drag, and bar should move with mouse (view pans opposite) +/** + * Scrollers should behave in the following ways, when clicked on with LMB (and dragged): + * -# 'Handles' on end of 'bubble' - when the axis that the scroller represents is zoomable, + * enlarge 'cur' rect on the relevant side. + * -# 'Bubble'/'bar' - just drag, and bar should move with mouse (view pans opposite). * - * In order to make sure this works, each operator must define the following RNA-Operator Props: - * deltax, deltay - define how much to move view by (relative to zoom-correction factor) + * In order to make sure this works, each operator must define the following RNA-Operator Props: + * - `deltax, deltay` - define how much to move view by (relative to zoom-correction factor) */ /* customdata for scroller-invoke data */ @@ -1562,10 +1570,12 @@ typedef struct v2dScrollerMove { } v2dScrollerMove; -/* View2DScrollers is typedef'd in UI_view2d.h +/** + * #View2DScrollers is typedef'd in UI_view2d.h * This is a CUT DOWN VERSION of the 'real' version, which is defined in view2d.c, as we only need focus bubble info - * WARNING: the start of this struct must not change, so that it stays in sync with the 'real' version - * For now, we don't need to have a separate (internal) header for structs like this... + * + * \warning: The start of this struct must not change, so that it stays in sync with the 'real' version + * For now, we don't need to have a separate (internal) header for structs like this... */ struct View2DScrollers { /* focus bubbles */ @@ -1584,10 +1594,12 @@ enum { /* ------------------------ */ -/* check if mouse is within scroller handle - * - mouse = relevant mouse coordinate in region space - * - sc_min, sc_max = extents of scroller 'groove' (potential available space for scroller) - * - sh_min, sh_max = positions of scrollbar handles +/** + * Check if mouse is within scroller handle. + * + * \param mouse: relevant mouse coordinate in region space. + * \param sc_min, sc_max: extents of scroller 'groove' (potential available space for scroller). + * \param sh_min, sh_max: positions of scrollbar handles. */ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_min, int sh_max) { @@ -1791,7 +1803,10 @@ static void scroller_activate_apply(bContext *C, wmOperator *op) UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY); } -/* handle user input for scrollers - calculations of mouse-movement need to be done here, not in the apply callback! */ +/** + * Handle user input for scrollers - calculations of mouse-movement need to be done here, + * not in the apply callback! + */ static int scroller_activate_modal(bContext *C, wmOperator *op, const wmEvent *event) { v2dScrollerMove *vsm = op->customdata; -- cgit v1.2.3