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-30 15:37:53 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-05-30 15:37:53 +0400
commit79f5a013be6efff5484b9a4cd6f9d7be0b7232af (patch)
treedc4b24a5560667df1c1310c73102482f755de4e9 /source/blender/editors/space_clip
parentb0cf3a342d81ca8bcd44c50b2e35af4d22fab802 (diff)
Patch #35464: Marker placement for motion tracker by clicking on a desired location
Now button in the toolshelf behaves this way: - User clicks on "Add Marker" - Then he clicks where the marker should get placed Patch by Marcos Couto (ocf) with own modifications.
Diffstat (limited to 'source/blender/editors/space_clip')
-rw-r--r--source/blender/editors/space_clip/clip_intern.h2
-rw-r--r--source/blender/editors/space_clip/space_clip.c2
-rw-r--r--source/blender/editors/space_clip/tracking_ops.c69
3 files changed, 48 insertions, 25 deletions
diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h
index f1851ef25a7..51cb83eecad 100644
--- a/source/blender/editors/space_clip/clip_intern.h
+++ b/source/blender/editors/space_clip/clip_intern.h
@@ -145,7 +145,7 @@ struct MovieTrackingTrack *tracking_marker_check_slide(struct bContext *C, const
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_add_marker_at_click(struct wmOperatorType *ot);
void CLIP_OT_delete_track(struct wmOperatorType *ot);
void CLIP_OT_delete_marker(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index fcb33474fa2..60420649093 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -465,7 +465,7 @@ static void clip_operatortypes(void)
/* markers */
WM_operatortype_append(CLIP_OT_add_marker);
- WM_operatortype_append(CLIP_OT_add_marker_at_center);
+ WM_operatortype_append(CLIP_OT_add_marker_at_click);
WM_operatortype_append(CLIP_OT_slide_marker);
WM_operatortype_append(CLIP_OT_delete_track);
WM_operatortype_append(CLIP_OT_delete_marker);
diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c
index 756492ea0f0..3f9b2aac0f1 100644
--- a/source/blender/editors/space_clip/tracking_ops.c
+++ b/source/blender/editors/space_clip/tracking_ops.c
@@ -72,6 +72,8 @@
#include "RNA_access.h"
#include "RNA_define.h"
+#include "BLF_translation.h"
+
#include "PIL_time.h"
#include "UI_view2d.h"
@@ -163,44 +165,65 @@ void CLIP_OT_add_marker(wmOperatorType *ot)
/********************** add marker operator *********************/
-static int add_marker_at_center_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
+static int add_marker_at_click_invoke(bContext *C, wmOperator *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];
+ ED_area_headerprint(CTX_wm_area(C), IFACE_("Use LMB click to define location where place the marker"));
- 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 modal handler for ESC */
+ WM_event_add_modal_handler(C, op);
- if (!add_marker(C, pos[0], pos[1])) {
- return OPERATOR_CANCELLED;
- }
+ return OPERATOR_RUNNING_MODAL;
+}
- /* reset offset from locked position, so frame jumping wouldn't be so confusing */
- sc->xlockof = 0;
- sc->ylockof = 0;
+static int add_marker_at_click_modal(bContext *C, wmOperator *UNUSED(op), const wmEvent *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];
- WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip);
+ switch(event->type) {
+ case MOUSEMOVE:
+ return OPERATOR_RUNNING_MODAL;
+ break;
- return OPERATOR_FINISHED;
+ case LEFTMOUSE:
+ ED_area_headerprint(CTX_wm_area(C), NULL);
+
+ ED_clip_point_stable_pos(sc, ar,
+ event->x - ar->winrct.xmin,
+ event->y - ar->winrct.ymin,
+ &pos[0], &pos[1]);
+
+ if (!add_marker(C, pos[0], pos[1]))
+ return OPERATOR_CANCELLED;
+
+ WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip);
+ return OPERATOR_FINISHED;
+ break;
+
+ case ESCKEY:
+ ED_area_headerprint(CTX_wm_area(C), NULL);
+ return OPERATOR_CANCELLED;
+ }
+
+ return OPERATOR_PASS_THROUGH;
}
-void CLIP_OT_add_marker_at_center(wmOperatorType *ot)
+void CLIP_OT_add_marker_at_click(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";
+ ot->name = "Add Marker at Click";
+ ot->idname = "CLIP_OT_add_marker_at_click";
+ ot->description = "Place new marker at the desired (clicked) position";
/* api callbacks */
- ot->invoke = add_marker_at_center_invoke;
+ ot->invoke = add_marker_at_click_invoke;
ot->poll = ED_space_clip_tracking_poll;
+ ot->modal = add_marker_at_click_modal;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
}
/********************** delete track operator *********************/