diff options
Diffstat (limited to 'source/blender/editors/transform')
5 files changed, 37 insertions, 23 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 4069a72a8fc..7a83fb71c28 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1671,6 +1671,13 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve } } + if ((prop = RNA_struct_find_property(op->ptr, "view2d_edge_pan")) && + RNA_property_is_set(op->ptr, prop)) { + if (RNA_property_boolean_get(op->ptr, prop)) { + options |= CTX_VIEW2D_EDGE_PAN; + } + } + t->options = options; t->mode = mode; diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 549ad770ac6..013c5faa54a 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -94,6 +94,8 @@ typedef enum { CTX_OBMODE_XFORM_OBDATA = (1 << 12), /** Transform object parents without moving their children. */ CTX_OBMODE_XFORM_SKIP_CHILDREN = (1 << 13), + /** Enable edge scrolling in 2D views */ + CTX_VIEW2D_EDGE_PAN = (1 << 14), } eTContext; /** #TransInfo.flag */ diff --git a/source/blender/editors/transform/transform_convert_node.c b/source/blender/editors/transform/transform_convert_node.c index 9d2d3713bf0..ecc7f01be33 100644 --- a/source/blender/editors/transform/transform_convert_node.c +++ b/source/blender/editors/transform/transform_convert_node.c @@ -46,12 +46,6 @@ /** \name Node Transform Creation * \{ */ -typedef struct NodeTransCustomData { - /* Initial rect of the view2d, used for computing offset during edge panning */ - rctf initial_v2d_cur; - View2DEdgePanData edge_pan; -} NodeTransCustomData; - /* transcribe given node into TransData2D for Transforming */ static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node, const float dpi_fac) { @@ -115,21 +109,16 @@ void createTransNodeData(TransInfo *t) const float dpi_fac = UI_DPI_FAC; SpaceNode *snode = t->area->spacedata.first; - if (t->mode == TFM_TRANSLATION) { - /* Disable cursor wrapping in the node editor for edge pan */ - t->flag |= T_NO_CURSOR_WRAP; - } - /* Custom data to enable edge panning during the node transform */ - NodeTransCustomData *customdata = MEM_callocN(sizeof(*customdata), __func__); + View2DEdgePanData *customdata = MEM_callocN(sizeof(*customdata), __func__); UI_view2d_edge_pan_init(t->context, - &customdata->edge_pan, + customdata, NODE_EDGE_PAN_INSIDE_PAD, NODE_EDGE_PAN_OUTSIDE_PAD, NODE_EDGE_PAN_SPEED_RAMP, NODE_EDGE_PAN_MAX_SPEED, - NODE_EDGE_PAN_DELAY); - customdata->initial_v2d_cur = t->region->v2d.cur; + NODE_EDGE_PAN_DELAY, + NODE_EDGE_PAN_ZOOM_INFLUENCE); t->custom.type.data = customdata; t->custom.type.use_free = true; @@ -176,17 +165,22 @@ void flushTransNodes(TransInfo *t) { const float dpi_fac = UI_DPI_FAC; - NodeTransCustomData *customdata = (NodeTransCustomData *)t->custom.type.data; + View2DEdgePanData *customdata = (View2DEdgePanData *)t->custom.type.data; - if (t->mode == TFM_TRANSLATION) { - /* Edge panning functions expect window coordinates, mval is relative to region */ - const float x = t->region->winrct.xmin + t->mval[0]; - const float y = t->region->winrct.ymin + t->mval[1]; - UI_view2d_edge_pan_apply(t->context, &customdata->edge_pan, x, y); + if (t->options & CTX_VIEW2D_EDGE_PAN) { + if (t->state == TRANS_CANCEL) { + UI_view2d_edge_pan_cancel(t->context, customdata); + } + else { + /* Edge panning functions expect window coordinates, mval is relative to region */ + const float x = t->region->winrct.xmin + t->mval[0]; + const float y = t->region->winrct.ymin + t->mval[1]; + UI_view2d_edge_pan_apply(t->context, customdata, x, y); + } } /* Initial and current view2D rects for additional transform due to view panning and zooming */ - const rctf *rect_src = &customdata->initial_v2d_cur; + const rctf *rect_src = &customdata->initial_rect; const rctf *rect_dst = &t->region->v2d.cur; FOREACH_TRANS_DATA_CONTAINER (t, tc) { diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 81fc1496b1a..9f5e74db501 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -625,6 +625,11 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve } #endif + /* Disable cursor wrap when edge panning is enabled. */ + if (t->options & CTX_VIEW2D_EDGE_PAN) { + t->flag |= T_NO_CURSOR_WRAP; + } + setTransformViewAspect(t, t->aspect); if (op && (prop = RNA_struct_find_property(op->ptr, "center_override")) && diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 45c077b8a07..cbc2adf641f 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -709,6 +709,11 @@ void Transform_Properties(struct wmOperatorType *ot, int flags) RNA_def_property_ui_text(prop, "Center Override", "Force using this center value (when set)"); } + if (flags & P_VIEW2D_EDGE_PAN) { + prop = RNA_def_boolean(ot->srna, "view2d_edge_pan", false, "Edge Pan", "Enable edge panning in 2D view"); + RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); + } + if ((flags & P_NO_DEFAULTS) == 0) { prop = RNA_def_boolean(ot->srna, "release_confirm", @@ -754,7 +759,8 @@ static void TRANSFORM_OT_translate(struct wmOperatorType *ot) Transform_Properties(ot, P_ORIENT_MATRIX | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_ALIGN_SNAP | - P_OPTIONS | P_GPENCIL_EDIT | P_CURSOR_EDIT | P_POST_TRANSFORM); + P_OPTIONS | P_GPENCIL_EDIT | P_CURSOR_EDIT | P_VIEW2D_EDGE_PAN | + P_POST_TRANSFORM); } static void TRANSFORM_OT_resize(struct wmOperatorType *ot) |