Cleanup: Use common utility to get direction for TIME_EXTEND

This commit is contained in:
Germano Cavalcante 2020-04-27 11:42:18 -03:00
parent 995611640e
commit 61f0941321
6 changed files with 20 additions and 32 deletions

View File

@ -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], &center[0], &center[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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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