[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56959] trunk/blender: Fix #35461: Marker gets initialized to arbitrary position

Sergey Sharybin sergey.vfx at gmail.com
Wed May 22 08:06:22 CEST 2013


Revision: 56959
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56959
Author:   nazgul
Date:     2013-05-22 06:06:22 +0000 (Wed, 22 May 2013)
Log Message:
-----------
Fix #35461: Marker gets initialized to arbitrary position

Use center of currently visible frame part instead of
center of the whole frame for position of marker which
is adding from toolbox.

Used separate operator for this to keep operators more
atomic and not confuse with lots of conflicting properties.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/space_clip.py
    trunk/blender/source/blender/editors/space_clip/clip_intern.h
    trunk/blender/source/blender/editors/space_clip/space_clip.c
    trunk/blender/source/blender/editors/space_clip/tracking_ops.c

Modified: trunk/blender/release/scripts/startup/bl_ui/space_clip.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_clip.py	2013-05-22 06:00:26 UTC (rev 56958)
+++ trunk/blender/release/scripts/startup/bl_ui/space_clip.py	2013-05-22 06:06:22 UTC (rev 56959)
@@ -211,8 +211,7 @@
         settings = clip.tracking.settings
 
         col = layout.column(align=True)
-        props = col.operator("clip.add_marker")
-        props.location = (0.5, 0.5)
+        props = col.operator("clip.add_marker_at_center", text="Add Marker")
         col.operator("clip.detect_features")
         col.operator("clip.delete_track")
 

Modified: trunk/blender/source/blender/editors/space_clip/clip_intern.h
===================================================================
--- trunk/blender/source/blender/editors/space_clip/clip_intern.h	2013-05-22 06:00:26 UTC (rev 56958)
+++ trunk/blender/source/blender/editors/space_clip/clip_intern.h	2013-05-22 06:06:22 UTC (rev 56959)
@@ -145,6 +145,7 @@
                                                        int *area_r, int *action_r, int *corner_r);
 
 void CLIP_OT_add_marker(struct wmOperatorType *ot);
+void CLIP_OT_add_marker_at_center(struct wmOperatorType *ot);
 void CLIP_OT_delete_track(struct wmOperatorType *ot);
 void CLIP_OT_delete_marker(struct wmOperatorType *ot);
 

Modified: trunk/blender/source/blender/editors/space_clip/space_clip.c
===================================================================
--- trunk/blender/source/blender/editors/space_clip/space_clip.c	2013-05-22 06:00:26 UTC (rev 56958)
+++ trunk/blender/source/blender/editors/space_clip/space_clip.c	2013-05-22 06:06:22 UTC (rev 56959)
@@ -465,6 +465,7 @@
 
 	/* markers */
 	WM_operatortype_append(CLIP_OT_add_marker);
+	WM_operatortype_append(CLIP_OT_add_marker_at_center);
 	WM_operatortype_append(CLIP_OT_slide_marker);
 	WM_operatortype_append(CLIP_OT_delete_track);
 	WM_operatortype_append(CLIP_OT_delete_marker);

Modified: trunk/blender/source/blender/editors/space_clip/tracking_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_clip/tracking_ops.c	2013-05-22 06:00:26 UTC (rev 56958)
+++ trunk/blender/source/blender/editors/space_clip/tracking_ops.c	2013-05-22 06:06:22 UTC (rev 56959)
@@ -159,6 +159,52 @@
 	                     "Location", "Location of marker on frame", -1.0f, 1.0f);
 }
 
+/********************** add marker operator *********************/
+
+static int add_marker_at_center_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
+{
+	SpaceClip *sc = CTX_wm_space_clip(C);
+	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]);
+
+	/* reset offset from locked position, so frame jumping wouldn't be so confusing */
+	sc->xlockof = 0;
+	sc->ylockof = 0;
+
+	WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip);
+
+	return OPERATOR_FINISHED;
+}
+
+void CLIP_OT_add_marker_at_center(wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name = "Add Marker at Center";
+	ot->idname = "CLIP_OT_add_marker_at_center";
+	ot->description = "Place new marker at the center of visible frame";
+
+	/* api callbacks */
+	ot->invoke = add_marker_at_center_invoke;
+	ot->poll = ED_space_clip_tracking_poll;
+
+	/* flags */
+	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
 /********************** delete track operator *********************/
 
 static int delete_track_exec(bContext *C, wmOperator *UNUSED(op))




More information about the Bf-blender-cvs mailing list