[Bf-blender-cvs] [25c173ffd12] master: Tracking: support editing all selected tracks

Philipp Oeser noreply at git.blender.org
Wed Oct 20 11:40:47 CEST 2021


Commit: 25c173ffd12c0b46de4cc9919b8dbcc125f7e5ec
Author: Philipp Oeser
Date:   Tue Oct 19 16:24:23 2021 +0200
Branches: master
https://developer.blender.org/rB25c173ffd12c0b46de4cc9919b8dbcc125f7e5ec

Tracking: support editing all selected tracks

This patch adds a "selected_movieclip_tracks" context member and enables
editing properties of multiple selected tracks via the usual Alt-click
editing (as well as the "Copy To Selected" operator). Both use
UI_context_copy_to_selected_list() to gather a list of other selected
items [which are now taken via said new context member]. Strictly
speaking, this could be done without the context member as well [just
gathering other selected tracks in UI_context_copy_to_selected_list()
without relying on a context member], but this might come in handy in
other places (e.g. Addons).

note: some could be desired for markers (e.g. editing pattern/search
areas of all selected track markers, but since this is burried in a
uiTemplate, this is a bit more work for another patch).

Differential Revision: https://developer.blender.org/D12923

===================================================================

M	doc/python_api/sphinx_doc_gen.py
M	source/blender/editors/interface/interface_ops.c
M	source/blender/editors/screen/screen_context.c

===================================================================

diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py
index ec636036f95..afc84834dd1 100644
--- a/doc/python_api/sphinx_doc_gen.py
+++ b/doc/python_api/sphinx_doc_gen.py
@@ -1110,6 +1110,7 @@ context_type_map = {
     "selected_editable_sequences": ("Sequence", True),
     "selected_files": ("FileSelectEntry", True),
     "selected_nla_strips": ("NlaStrip", True),
+    "selected_movieclip_tracks": ("MovieTrackingTrack", True),
     "selected_nodes": ("Node", True),
     "selected_objects": ("Object", True),
     "selected_pose_bones": ("PoseBone", True),
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index 423950d4dbd..69a3cc959c9 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -849,6 +849,9 @@ bool UI_context_copy_to_selected_list(bContext *C,
   else if (RNA_struct_is_a(ptr->type, &RNA_NlaStrip)) {
     *r_lb = CTX_data_collection_get(C, "selected_nla_strips");
   }
+  else if (RNA_struct_is_a(ptr->type, &RNA_MovieTrackingTrack)) {
+    *r_lb = CTX_data_collection_get(C, "selected_movieclip_tracks");
+  }
   else if (RNA_struct_is_a(ptr->type, &RNA_Constraint) &&
            (path_from_bone = RNA_path_resolve_from_type_to_property(ptr, prop, &RNA_PoseBone)) !=
                NULL) {
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index 3d447d90626..a8c63027254 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -49,11 +49,13 @@
 #include "BKE_gpencil.h"
 #include "BKE_layer.h"
 #include "BKE_object.h"
+#include "BKE_tracking.h"
 
 #include "RNA_access.h"
 
 #include "ED_anim_api.h"
 #include "ED_armature.h"
+#include "ED_clip.h"
 #include "ED_gpencil.h"
 
 #include "SEQ_select.h"
@@ -99,6 +101,7 @@ const char *screen_context_dir[] = {
     "active_nla_track",
     "active_nla_strip",
     "selected_nla_strips", /* nla editor */
+    "selected_movieclip_tracks",
     "gpencil_data",
     "gpencil_data_owner", /* grease pencil data */
     "annotation_data",
@@ -709,6 +712,33 @@ static eContextResult screen_ctx_selected_nla_strips(const bContext *C, bContext
   }
   return CTX_RESULT_NO_DATA;
 }
+static eContextResult screen_ctx_selected_movieclip_tracks(const bContext *C,
+                                                           bContextDataResult *result)
+{
+  SpaceClip *space_clip = CTX_wm_space_clip(C);
+  if (space_clip == NULL) {
+    return CTX_RESULT_NO_DATA;
+  }
+  MovieClip *clip = ED_space_clip_get_clip(space_clip);
+  if (clip == NULL) {
+    return CTX_RESULT_NO_DATA;
+  }
+  MovieTracking *tracking = &clip->tracking;
+  if (tracking == NULL) {
+    return CTX_RESULT_NO_DATA;
+  }
+
+  ListBase *tracks_list = BKE_tracking_get_active_tracks(tracking);
+  LISTBASE_FOREACH (MovieTrackingTrack *, track, tracks_list) {
+    if (!TRACK_SELECTED(track)) {
+      continue;
+    }
+    CTX_data_list_add(result, &clip->id, &RNA_MovieTrackingTrack, track);
+  }
+
+  CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
+  return CTX_RESULT_OK;
+}
 static eContextResult screen_ctx_gpencil_data(const bContext *C, bContextDataResult *result)
 {
   wmWindow *win = CTX_wm_window(C);
@@ -1143,6 +1173,7 @@ static void ensure_ed_screen_context_functions(void)
   register_context_function("active_nla_track", screen_ctx_active_nla_track);
   register_context_function("active_nla_strip", screen_ctx_active_nla_strip);
   register_context_function("selected_nla_strips", screen_ctx_selected_nla_strips);
+  register_context_function("selected_movieclip_tracks", screen_ctx_selected_movieclip_tracks);
   register_context_function("gpencil_data", screen_ctx_gpencil_data);
   register_context_function("gpencil_data_owner", screen_ctx_gpencil_data_owner);
   register_context_function("annotation_data", screen_ctx_annotation_data);



More information about the Bf-blender-cvs mailing list