diff options
Diffstat (limited to 'source')
6 files changed, 20 insertions, 32 deletions
diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c index 0beacf1244a..14f9365096d 100644 --- a/source/blender/editors/transform/transform_convert.c +++ b/source/blender/editors/transform/transform_convert.c @@ -819,25 +819,21 @@ void clipUVData(TransInfo *t) * \{ */ /** - * For modal operation: `t->center_global` may not have been set yet. + * Used for `TFM_TIME_EXTEND`. */ -void transform_convert_center_global_v2(TransInfo *t, float r_center[2]) +char transform_convert_frame_side_dir_get(TransInfo *t, float cframe) { + Scene *scene = t->scene; + float center[2]; if (t->flag & T_MODAL) { UI_view2d_region_to_view( - (View2D *)t->view, t->mouse.imval[0], t->mouse.imval[1], &r_center[0], &r_center[1]); + (View2D *)t->view, t->mouse.imval[0], t->mouse.imval[1], ¢er[0], ¢er[1]); } else { - copy_v2_v2(r_center, t->center_global); + copy_v2_v2(center, t->center_global); } -} -void transform_convert_center_global_v2_int(TransInfo *t, int r_center[2]) -{ - float center[2]; - transform_convert_center_global_v2(t, center); - r_center[0] = round_fl_to_int(center[0]); - r_center[1] = round_fl_to_int(center[1]); + return (center[0] > cframe) ? 'R' : 'L'; } /* This function tests if a point is on the "mouse" side of the cursor/frame-marking */ diff --git a/source/blender/editors/transform/transform_convert.h b/source/blender/editors/transform/transform_convert.h index d616f24ba86..f975d320e62 100644 --- a/source/blender/editors/transform/transform_convert.h +++ b/source/blender/editors/transform/transform_convert.h @@ -104,8 +104,7 @@ void transform_around_single_fallback(TransInfo *t); bool constraints_list_needinv(TransInfo *t, ListBase *list); void calc_distanceCurveVerts(TransData *head, TransData *tail); struct TransDataCurveHandleFlags *initTransDataCurveHandles(TransData *td, struct BezTriple *bezt); -void transform_convert_center_global_v2(TransInfo *t, float r_center[2]); -void transform_convert_center_global_v2_int(TransInfo *t, int r_center[2]); +char transform_convert_frame_side_dir_get(TransInfo *t, float cframe); bool FrameOnMouseSide(char side, float frame, float cframe); /* transform_convert_action.c */ diff --git a/source/blender/editors/transform/transform_convert_action.c b/source/blender/editors/transform/transform_convert_action.c index c9273121df5..21ef1539911 100644 --- a/source/blender/editors/transform/transform_convert_action.c +++ b/source/blender/editors/transform/transform_convert_action.c @@ -331,10 +331,7 @@ void createTransActionData(bContext *C, TransInfo *t) /* which side of the current frame should be allowed */ if (t->mode == TFM_TIME_EXTEND) { - /* only side on which center is gets transformed */ - float center[2]; - transform_convert_center_global_v2(t, center); - t->frame_side = (center[0] > CFRA) ? 'R' : 'L'; + t->frame_side = transform_convert_frame_side_dir_get(t, (float)CFRA); } else { /* normal transform - both sides of current frame are considered */ diff --git a/source/blender/editors/transform/transform_convert_graph.c b/source/blender/editors/transform/transform_convert_graph.c index 5c2391d8dd0..f6f0dd3c491 100644 --- a/source/blender/editors/transform/transform_convert_graph.c +++ b/source/blender/editors/transform/transform_convert_graph.c @@ -261,10 +261,7 @@ void createTransGraphEditData(bContext *C, TransInfo *t) /* which side of the current frame should be allowed */ // XXX we still want this mode, but how to get this using standard transform too? if (t->mode == TFM_TIME_EXTEND) { - /* only side on which center is gets transformed */ - float center[2]; - transform_convert_center_global_v2(t, center); - t->frame_side = (center[0] > CFRA) ? 'R' : 'L'; + t->frame_side = transform_convert_frame_side_dir_get(t, (float)CFRA); } else { /* normal transform - both sides of current frame are considered */ diff --git a/source/blender/editors/transform/transform_convert_nla.c b/source/blender/editors/transform/transform_convert_nla.c index 580a8d79d7a..2978c36b15f 100644 --- a/source/blender/editors/transform/transform_convert_nla.c +++ b/source/blender/editors/transform/transform_convert_nla.c @@ -71,10 +71,7 @@ void createTransNlaData(bContext *C, TransInfo *t) /* which side of the current frame should be allowed */ if (t->mode == TFM_TIME_EXTEND) { - /* only side on which center is gets transformed */ - float center[2]; - transform_convert_center_global_v2(t, center); - t->frame_side = (center[0] > CFRA) ? 'R' : 'L'; + t->frame_side = transform_convert_frame_side_dir_get(t, (float)CFRA); } else { /* normal transform - both sides of current frame are considered */ diff --git a/source/blender/editors/transform/transform_convert_sequencer.c b/source/blender/editors/transform/transform_convert_sequencer.c index a722f17db22..0175bf6e673 100644 --- a/source/blender/editors/transform/transform_convert_sequencer.c +++ b/source/blender/editors/transform/transform_convert_sequencer.c @@ -31,6 +31,8 @@ #include "BKE_report.h" #include "BKE_sequencer.h" +#include "UI_view2d.h" + #include "transform.h" #include "transform_convert.h" @@ -541,10 +543,7 @@ void createTransSeqData(TransInfo *t) } tc->custom.type.free_cb = freeSeqData; - /* only side on which center is gets transformed */ - int center[2]; - transform_convert_center_global_v2_int(t, center); - t->frame_side = (center[0] > CFRA) ? 'R' : 'L'; + t->frame_side = transform_convert_frame_side_dir_get(t, (float)CFRA); #ifdef XXX_DURIAN_ANIM_TX_HACK { @@ -586,9 +585,12 @@ void createTransSeqData(TransInfo *t) SeqToTransData_Recursive(t, ed->seqbasep, td, td2d, tdsq); SeqTransDataBounds(t, ed->seqbasep, ts); - /* set the snap mode based on how close the mouse is at the end/start points */ - if (abs(center[0] - ts->max) > abs(center[0] - ts->min)) { - ts->snap_left = true; + if (t->flag & T_MODAL) { + /* set the snap mode based on how close the mouse is at the end/start points */ + int xmouse = (int)UI_view2d_region_to_view_x((View2D *)t->view, t->mouse.imval[0]); + if (abs(xmouse - ts->max) > abs(xmouse - ts->min)) { + ts->snap_left = true; + } } #undef XXX_DURIAN_ANIM_TX_HACK |