De-duplicate zero resolution check in marker add operators.

This commit is contained in:
Sergey Sharybin
2013-05-22 06:28:59 +00:00
parent b1d7205aa9
commit 1840cb84b2

View File

@@ -80,7 +80,7 @@
/********************** add marker operator *********************/
static void add_marker(const bContext *C, float x, float y)
static bool add_marker(const bContext *C, float x, float y)
{
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
@@ -92,11 +92,17 @@ static void add_marker(const bContext *C, float x, float y)
ED_space_clip_get_size(sc, &width, &height);
if (width == 0 || height == 0) {
return false;
}
track = BKE_tracking_track_add(tracking, tracksbase, x, y, framenr, width, height);
BKE_tracking_track_select(tracksbase, track, TRACK_AREA_ALL, 0);
clip->tracking.act_track = track;
return true;
}
static int add_marker_exec(bContext *C, wmOperator *op)
@@ -104,16 +110,12 @@ static int add_marker_exec(bContext *C, wmOperator *op)
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
float pos[2];
int width, height;
ED_space_clip_get_size(sc, &width, &height);
if (!width || !height)
return OPERATOR_CANCELLED;
RNA_float_get_array(op->ptr, "location", pos);
add_marker(C, pos[0], pos[1]);
if (!add_marker(C, pos[0], pos[1])) {
return OPERATOR_CANCELLED;
}
/* reset offset from locked position, so frame jumping wouldn't be so confusing */
sc->xlockof = 0;
@@ -167,19 +169,15 @@ static int add_marker_at_center_invoke(bContext *C, wmOperator *UNUSED(op), cons
MovieClip *clip = ED_space_clip_get_clip(sc);
ARegion *ar = CTX_wm_region(C);
float pos[2];
int width, height;
ED_space_clip_get_size(sc, &width, &height);
if (!width || !height)
return OPERATOR_CANCELLED;
ED_clip_point_stable_pos(sc, ar,
BLI_rcti_size_x(&ar->winrct) / 2.0f,
BLI_rcti_size_y(&ar->winrct) / 2.0f,
&pos[0], &pos[1]);
add_marker(C, pos[0], pos[1]);
if (!add_marker(C, pos[0], pos[1])) {
return OPERATOR_CANCELLED;
}
/* reset offset from locked position, so frame jumping wouldn't be so confusing */
sc->xlockof = 0;