Cleanup: Move TransSeq declaration to tansform_convert

This commit is contained in:
Germano Cavalcante 2020-06-06 10:30:32 -03:00
parent 0e040ef3fb
commit 34b4dca9f1
4 changed files with 27 additions and 23 deletions

View File

@ -229,16 +229,6 @@ typedef struct TransDataSeq {
} TransDataSeq;
/**
* Sequencer transform customdata (stored in #TransCustomDataContainer).
*/
typedef struct TransSeq {
TransDataSeq *tdseq;
int min;
int max;
bool snap_left;
} TransSeq;
/** Used for NLA transform (stored in #TransData.extra pointer). */
typedef struct TransDataNla {
/** ID-block NLA-data is attached to. */

View File

@ -93,6 +93,7 @@ void flushTransParticles(TransInfo *t);
/* transform_convert_sequencer.c */
void flushTransSeq(TransInfo *t);
int transform_convert_sequencer_get_snap_bound(TransInfo *t);
/* transform_convert_tracking.c */
void flushTransTracking(TransInfo *t);

View File

@ -36,6 +36,16 @@
#include "transform.h"
#include "transform_convert.h"
/**
* Sequencer transform customdata (stored in #TransCustomDataContainer).
*/
typedef struct TransSeq {
TransDataSeq *tdseq;
int min;
int max;
bool snap_left;
} TransSeq;
/* -------------------------------------------------------------------- */
/** \name Sequencer Transform Creation
*
@ -760,4 +770,10 @@ void flushTransSeq(TransInfo *t)
}
}
int transform_convert_sequencer_get_snap_bound(TransInfo *t)
{
TransSeq *ts = TRANS_DATA_CONTAINER_FIRST_SINGLE(t)->custom.type.data;
return ts->snap_left ? ts->min : ts->max;
}
/** \} */

View File

@ -72,6 +72,7 @@
#include "MEM_guardedalloc.h"
#include "transform.h"
#include "transform_convert.h"
#include "transform_snap.h"
/* this should be passed as an arg for use in snap functions */
@ -1615,26 +1616,22 @@ void snapGridIncrement(TransInfo *t, float *val)
void snapSequenceBounds(TransInfo *t, const int mval[2])
{
float xmouse, ymouse;
int frame;
int mframe;
TransSeq *ts = TRANS_DATA_CONTAINER_FIRST_SINGLE(t)->custom.type.data;
/* reuse increment, strictly speaking could be another snap mode, but leave as is */
/* Reuse increment, strictly speaking could be another snap mode, but leave as is. */
if (!(t->modifiers & MOD_SNAP_INVERT)) {
return;
}
/* convert to frame range */
/* Convert to frame range. */
float xmouse, ymouse;
UI_view2d_region_to_view(&t->region->v2d, mval[0], mval[1], &xmouse, &ymouse);
mframe = round_fl_to_int(xmouse);
/* now find the closest sequence */
frame = BKE_sequencer_find_next_prev_edit(t->scene, mframe, SEQ_SIDE_BOTH, true, false, true);
const int frame_curr = round_fl_to_int(xmouse);
if (!ts->snap_left) {
frame = frame - (ts->max - ts->min);
}
/* Now find the closest sequence. */
const int frame_near = BKE_sequencer_find_next_prev_edit(
t->scene, frame_curr, SEQ_SIDE_BOTH, true, false, true);
t->values[0] = frame - ts->min;
const int frame_snap = transform_convert_sequencer_get_snap_bound(t);
t->values[0] = frame_near - frame_snap;
}
static void applyGridIncrement(