[Bf-blender-cvs] [205c6d8d085] master: VSE: New Change Scene option in Change menu

Antonio Vazquez noreply at git.blender.org
Mon May 16 19:42:55 CEST 2022


Commit: 205c6d8d0853ada1c3d087b31bb2bec42d5597f1
Author: Antonio Vazquez
Date:   Mon May 16 19:41:50 2022 +0200
Branches: master
https://developer.blender.org/rB205c6d8d0853ada1c3d087b31bb2bec42d5597f1

VSE: New Change Scene option in Change menu

This is a new option in `C` key menu.

Reviewed By: mendio, ISS

Maniphest Tasks: T97711

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

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

M	release/scripts/startup/bl_ui/space_sequencer.py
M	source/blender/editors/space_sequencer/sequencer_edit.c
M	source/blender/editors/space_sequencer/sequencer_intern.h
M	source/blender/editors/space_sequencer/sequencer_ops.c

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

diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py
index 7c7bb456473..9aeac14ef4b 100644
--- a/release/scripts/startup/bl_ui/space_sequencer.py
+++ b/release/scripts/startup/bl_ui/space_sequencer.py
@@ -611,7 +611,16 @@ class SEQUENCER_MT_change(Menu):
         strip = context.active_sequence_strip
 
         layout.operator_context = 'INVOKE_REGION_WIN'
+        if strip and strip.type == 'SCENE':
+            bpy_data_scenes_len = len(bpy.data.scenes)
+            if bpy_data_scenes_len > 10:
+                layout.operator_context = 'INVOKE_DEFAULT'
+                layout.operator("sequencer.change_scene", text="Change Scene...")
+            elif bpy_data_scenes_len > 1:
+                layout.operator_menu_enum("sequencer.change_scene", "scene", text="Change Scene")
+            del bpy_data_scenes_len
 
+        layout.operator_context = 'INVOKE_DEFAULT'
         layout.operator_menu_enum("sequencer.change_effect_input", "swap")
         layout.operator_menu_enum("sequencer.change_effect_type", "type")
         prop = layout.operator("sequencer.change_path", text="Path/Files")
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 117e206eac7..0370d3605a7 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -3039,6 +3039,81 @@ void SEQUENCER_OT_change_path(struct wmOperatorType *ot)
 
 /** \} */
 
+/* -------------------------------------------------------------------- */
+/** \name Change Strip Scene Operator
+ * \{ */
+
+bool sequencer_strip_change_scene_poll(bContext *C)
+{
+  Editing *ed = SEQ_editing_get(CTX_data_scene(C));
+  if (ed == NULL) {
+    return false;
+  }
+  Sequence *seq = ed->act_seq;
+  return ((seq != NULL) && (seq->type == SEQ_TYPE_SCENE));
+}
+static int sequencer_change_scene_exec(bContext *C, wmOperator *op)
+{
+  Main *bmain = CTX_data_main(C);
+  Scene *scene = CTX_data_scene(C);
+  Scene *scene_seq = BLI_findlink(&bmain->scenes, RNA_enum_get(op->ptr, "scene"));
+
+  if (scene_seq == NULL) {
+    BKE_report(op->reports, RPT_ERROR, "Scene not found");
+    return OPERATOR_CANCELLED;
+  }
+
+  /* Assign new scene. */
+  Sequence *seq = SEQ_select_active_get(scene);
+  if (seq) {
+    seq->scene = scene_seq;
+    /* Do a refresh of the sequencer data. */
+    SEQ_relations_invalidate_cache_raw(scene, seq);
+    DEG_id_tag_update(&scene->id, ID_RECALC_AUDIO | ID_RECALC_SEQUENCER_STRIPS);
+    DEG_relations_tag_update(bmain);
+  }
+
+  WM_event_add_notifier(C, NC_SCENE | ND_SCENEBROWSE, scene);
+  WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+
+  return OPERATOR_FINISHED;
+}
+
+static int sequencer_change_scene_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+{
+  if (!RNA_struct_property_is_set(op->ptr, "scene")) {
+    return WM_enum_search_invoke(C, op, event);
+  }
+
+  return sequencer_change_scene_exec(C, op);
+}
+
+void SEQUENCER_OT_change_scene(struct wmOperatorType *ot)
+{
+  PropertyRNA *prop;
+
+  /* Identifiers. */
+  ot->name = "Change Scene";
+  ot->idname = "SEQUENCER_OT_change_scene";
+  ot->description = "Change Scene assigned to Strip";
+
+  /* Api callbacks. */
+  ot->exec = sequencer_change_scene_exec;
+  ot->invoke = sequencer_change_scene_invoke;
+  ot->poll = sequencer_strip_change_scene_poll;
+
+  /* Flags. */
+  ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+  /* Properties. */
+  prop = RNA_def_enum(ot->srna, "scene", DummyRNA_NULL_items, 0, "Scene", "");
+  RNA_def_enum_funcs(prop, RNA_scene_without_active_itemf);
+  RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
+  ot->prop = prop;
+}
+
+/** \} */
+
 /* -------------------------------------------------------------------- */
 /** \name Export Subtitles Operator
  * \{ */
diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h
index 67df065ef35..fd08fad94cb 100644
--- a/source/blender/editors/space_sequencer/sequencer_intern.h
+++ b/source/blender/editors/space_sequencer/sequencer_intern.h
@@ -197,6 +197,7 @@ void SEQUENCER_OT_rendersize(struct wmOperatorType *ot);
 void SEQUENCER_OT_change_effect_input(struct wmOperatorType *ot);
 void SEQUENCER_OT_change_effect_type(struct wmOperatorType *ot);
 void SEQUENCER_OT_change_path(struct wmOperatorType *ot);
+void SEQUENCER_OT_change_scene(struct wmOperatorType *ot);
 
 void SEQUENCER_OT_copy(struct wmOperatorType *ot);
 void SEQUENCER_OT_paste(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c
index 1aa2991f07a..88a46035225 100644
--- a/source/blender/editors/space_sequencer/sequencer_ops.c
+++ b/source/blender/editors/space_sequencer/sequencer_ops.c
@@ -58,6 +58,7 @@ void sequencer_operatortypes(void)
   WM_operatortype_append(SEQUENCER_OT_change_effect_input);
   WM_operatortype_append(SEQUENCER_OT_change_effect_type);
   WM_operatortype_append(SEQUENCER_OT_change_path);
+  WM_operatortype_append(SEQUENCER_OT_change_scene);
 
   WM_operatortype_append(SEQUENCER_OT_set_range_to_strips);
   WM_operatortype_append(SEQUENCER_OT_strip_transform_clear);



More information about the Bf-blender-cvs mailing list