Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2013-05-22 10:28:59 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-05-22 10:28:59 +0400
commit1840cb84b2c9fd38c01def6ae9702736c0b1e32e (patch)
tree417bc60bf469ed578444a538988ab9fdcb1d6730 /source/blender/editors/space_clip
parentb1d7205aa9cadd0d29941fbb5891095a1fffdbda (diff)
De-duplicate zero resolution check in marker add operators.
Diffstat (limited to 'source/blender/editors/space_clip')
-rw-r--r--source/blender/editors/space_clip/tracking_ops.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c
index 59e5c665f73..ffa4ee2a1d8 100644
--- a/source/blender/editors/space_clip/tracking_ops.c
+++ b/source/blender/editors/space_clip/tracking_ops.c
@@ -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;