diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-03-08 21:06:40 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-03-08 21:06:40 +0400 |
commit | fe131db70bc59f1e25b5fffe41283f7444cce140 (patch) | |
tree | 352865ef91f09b2ef02e93a9b80045974b00e413 | |
parent | a71936196ad1d1f0008278d859f9913318f75d2d (diff) |
New operators for clip editor's curve view:
- Select All operator for selecting markers
- Disable selected markers operator
-rw-r--r-- | source/blender/editors/space_clip/clip_graph_ops.c | 137 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/space_clip/space_clip.c | 31 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_tracking_types.h | 1 |
4 files changed, 159 insertions, 12 deletions
diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c index 581b8787edb..aecce3b1ba1 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -42,6 +42,7 @@ #include "BKE_context.h" #include "BKE_movieclip.h" #include "BKE_tracking.h" +#include "BKE_depsgraph.h" #include "WM_api.h" #include "WM_types.h" @@ -83,13 +84,13 @@ static void toggle_selection_cb(void *userdata, MovieTrackingMarker *marker) switch(data->action) { case SEL_SELECT: - marker->flag|= (MARKER_GRAPH_SEL_X|MARKER_GRAPH_SEL_Y); + marker->flag|= MARKER_GRAPH_SEL; break; case SEL_DESELECT: - marker->flag&= ~(MARKER_GRAPH_SEL_X|MARKER_GRAPH_SEL_Y); + marker->flag&= ~MARKER_GRAPH_SEL; break; case SEL_INVERT: - marker->flag^= (MARKER_GRAPH_SEL_X|MARKER_GRAPH_SEL_Y); + marker->flag^= MARKER_GRAPH_SEL; break; } } @@ -333,7 +334,7 @@ static void border_select_cb(void *userdata, MovieTrackingTrack *UNUSED(track), data->change = TRUE; } else if (!data->extend) { - marker->flag&= ~(MARKER_GRAPH_SEL_X|MARKER_GRAPH_SEL_Y); + marker->flag&= ~MARKER_GRAPH_SEL; } } @@ -391,6 +392,72 @@ void CLIP_OT_graph_select_border(wmOperatorType *ot) WM_operator_properties_gesture_border(ot, TRUE); } +/********************** select all operator *********************/ + +static int graph_select_all_markers_exec(bContext *C, wmOperator *op) +{ + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; + MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking); + MovieTrackingMarker *marker; + int action = RNA_enum_get(op->ptr, "action"); + int a; + + if (!act_track) + return OPERATOR_CANCELLED; + + if (action == SEL_TOGGLE) { + action = SEL_SELECT; + + for (a = 0; a < act_track->markersnr; a++) { + marker = &act_track->markers[a]; + + if (marker->flag & MARKER_GRAPH_SEL) { + action = SEL_DESELECT; + break; + } + } + } + + for (a = 0; a < act_track->markersnr; a++) { + marker = &act_track->markers[a]; + + switch (action) { + case SEL_SELECT: + marker->flag |= MARKER_GRAPH_SEL; + break; + case SEL_DESELECT: + marker->flag &= ~MARKER_GRAPH_SEL; + break; + case SEL_INVERT: + marker->flag ^= MARKER_GRAPH_SEL; + break; + } + } + + WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + + return OPERATOR_FINISHED; +} + +void CLIP_OT_graph_select_all_markers(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Select or Deselect All Markers"; + ot->description = "Change selection of all markers of active track"; + ot->idname = "CLIP_OT_graph_select_all_markers"; + + /* api callbacks */ + ot->exec = graph_select_all_markers_exec; + ot->poll = ED_space_clip_graph_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + WM_operator_properties_select_all(ot); +} + /******************** delete curve operator ********************/ static int delete_curve_exec(bContext *C, wmOperator *UNUSED(op)) @@ -439,7 +506,7 @@ static int delete_knot_exec(bContext *C, wmOperator *UNUSED(op)) while(a<act_track->markersnr) { MovieTrackingMarker *marker= &act_track->markers[a]; - if(marker->flag & (MARKER_GRAPH_SEL_X|MARKER_GRAPH_SEL_Y)) + if(marker->flag & MARKER_GRAPH_SEL) clip_delete_marker(C, clip, tracksbase, act_track, marker); else a++; @@ -567,3 +634,63 @@ void CLIP_OT_graph_center_current_frame(wmOperatorType *ot) ot->exec = center_current_frame_exec; ot->poll = ED_space_clip_graph_poll; } + +/********************** disable markers operator *********************/ + +static int graph_disable_markers_exec(bContext *C, wmOperator *op) +{ + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; + MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking); + MovieTrackingMarker *marker; + int action = RNA_enum_get(op->ptr, "action"); + int a; + + if (!act_track || (act_track->flag & TRACK_LOCKED)) + return OPERATOR_CANCELLED; + + for (a = 0; a < act_track->markersnr; a++) { + marker = &act_track->markers[a]; + + if (marker->flag & MARKER_GRAPH_SEL) { + if (action==0) + marker->flag |= MARKER_DISABLED; + else if(action==1) + marker->flag &= ~MARKER_DISABLED; + else + marker->flag ^= MARKER_DISABLED; + } + } + + DAG_id_tag_update(&clip->id, 0); + + WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); + + return OPERATOR_FINISHED; +} + +void CLIP_OT_graph_disable_markers(wmOperatorType *ot) +{ + static EnumPropertyItem actions_items[] = { + {0, "DISABLE", 0, "Disable", "Disable selected markers"}, + {1, "ENABLE", 0, "Enable", "Enable selected markers"}, + {2, "TOGGLE", 0, "Toggle", "Toggle disabled flag for selected markers"}, + {0, NULL, 0, NULL, NULL} + }; + + /* identifiers */ + ot->name = "Disable Markers"; + ot->description = "Disable/enable selected markers"; + ot->idname = "CLIP_OT_graph_disable_markers"; + + /* api callbacks */ + ot->exec = graph_disable_markers_exec; + ot->poll = ED_space_clip_graph_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + RNA_def_enum(ot->srna, "action", actions_items, 0, "Action", "Disable action to execute"); +} diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h index 0288cb1f797..8d4da7e995c 100644 --- a/source/blender/editors/space_clip/clip_intern.h +++ b/source/blender/editors/space_clip/clip_intern.h @@ -59,10 +59,12 @@ void ED_clip_graph_center_current_frame(struct Scene *scene, struct ARegion *ar) void CLIP_OT_graph_select(struct wmOperatorType *ot); void CLIP_OT_graph_select_border(struct wmOperatorType *ot); +void CLIP_OT_graph_select_all_markers(struct wmOperatorType *ot); void CLIP_OT_graph_delete_curve(struct wmOperatorType *ot); void CLIP_OT_graph_delete_knot(struct wmOperatorType *ot); void CLIP_OT_graph_view_all(struct wmOperatorType *ot); void CLIP_OT_graph_center_current_frame(struct wmOperatorType *ot); +void CLIP_OT_graph_disable_markers(struct wmOperatorType *ot); /* clip_ops.c */ void CLIP_OT_open(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 24267df629a..a92830e1992 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -368,21 +368,29 @@ static void clip_operatortypes(void) WM_operatortype_append(CLIP_OT_clean_tracks); + /* object tracking */ + WM_operatortype_append(CLIP_OT_tracking_object_new); + WM_operatortype_append(CLIP_OT_tracking_object_remove); + + /* clipboard */ + WM_operatortype_append(CLIP_OT_copy_tracks); + WM_operatortype_append(CLIP_OT_paste_tracks); + + /* ** clip_graph_ops.c ** */ + /* graph editing */ + + /* selection */ WM_operatortype_append(CLIP_OT_graph_select); WM_operatortype_append(CLIP_OT_graph_select_border); + WM_operatortype_append(CLIP_OT_graph_select_all_markers); + WM_operatortype_append(CLIP_OT_graph_delete_curve); WM_operatortype_append(CLIP_OT_graph_delete_knot); WM_operatortype_append(CLIP_OT_graph_view_all); WM_operatortype_append(CLIP_OT_graph_center_current_frame); - /* object tracking */ - WM_operatortype_append(CLIP_OT_tracking_object_new); - WM_operatortype_append(CLIP_OT_tracking_object_remove); - - /* clipboard */ - WM_operatortype_append(CLIP_OT_copy_tracks); - WM_operatortype_append(CLIP_OT_paste_tracks); + WM_operatortype_append(CLIP_OT_graph_disable_markers); } static void clip_keymap(struct wmKeyConfig *keyconf) @@ -562,6 +570,11 @@ static void clip_keymap(struct wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "CLIP_OT_graph_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "extend", TRUE); + kmi = WM_keymap_add_item(keymap, "CLIP_OT_graph_select_all_markers", AKEY, KM_PRESS, 0, 0); + RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); + kmi = WM_keymap_add_item(keymap, "CLIP_OT_graph_select_all_markers", IKEY, KM_PRESS, KM_CTRL, 0); + RNA_enum_set(kmi->ptr, "action", SEL_INVERT); + WM_keymap_add_item(keymap, "CLIP_OT_graph_select_border", BKEY, KM_PRESS, 0, 0); /* delete */ @@ -589,6 +602,10 @@ static void clip_keymap(struct wmKeyConfig *keyconf) RNA_enum_set(kmi->ptr, "action", TRACK_CLEAR_ALL); RNA_boolean_set(kmi->ptr, "clear_active", TRUE); + /* tracks */ + kmi= WM_keymap_add_item(keymap, "CLIP_OT_graph_disable_markers", DKEY, KM_PRESS, KM_SHIFT, 0); + RNA_enum_set(kmi->ptr, "action", 2); /* toggle */ + transform_keymap_for_space(keyconf, keymap, SPACE_CLIP); } diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h index 885b2d97692..9c0f63028c1 100644 --- a/source/blender/makesdna/DNA_tracking_types.h +++ b/source/blender/makesdna/DNA_tracking_types.h @@ -218,6 +218,7 @@ enum { #define MARKER_TRACKED (1<<1) #define MARKER_GRAPH_SEL_X (1<<2) #define MARKER_GRAPH_SEL_Y (1<<3) +#define MARKER_GRAPH_SEL (MARKER_GRAPH_SEL_X|MARKER_GRAPH_SEL_Y) /* MovieTrackingTrack->flag */ #define TRACK_HAS_BUNDLE (1<<1) |