link markers to another scene, Currently in Ctrl+L menu (which isnt ideal but no...
authorCampbell Barton <ideasman42@gmail.com>
Wed, 13 Jan 2010 14:39:08 +0000 (14:39 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 13 Jan 2010 14:39:08 +0000 (14:39 +0000)
needed for linking in scenes and copying markers about

release/scripts/ui/space_view3d.py
source/blender/editors/animation/anim_markers.c

index 0c844440250a1602c3b77ebfd5bf93e6eeab447c..4f4c98dee696a8b67e91e4e28dcd81c41b27e6be 100644 (file)
@@ -777,7 +777,7 @@ class VIEW3D_MT_make_links(bpy.types.Menu):
         layout = self.layout
 
         layout.operator_menu_enum("object.make_links_scene", "type", text="Objects to Scene...")
-
+        layout.operator_menu_enum("marker.make_links_scene", "type", text="Markers to Scene...")
         layout.operator_enums("object.make_links_data", property="type") # inline
 
 
index 7d1ddda1c6dfb2a0a4904b1627d99f072ee7ca48..4f7a02bb688922466b7bc2b00156292127625a77 100644 (file)
@@ -41,6 +41,7 @@
 
 #include "RNA_access.h"
 #include "RNA_define.h"
+#include "RNA_enum_types.h"
 
 #include "BLI_blenlib.h"
 
@@ -48,6 +49,8 @@
 #include "BKE_global.h"
 #include "BKE_fcurve.h"
 #include "BKE_utildefines.h"
+#include "BKE_main.h"
+#include "BKE_report.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -985,6 +988,56 @@ static void MARKER_OT_delete(wmOperatorType *ot)
        
 }
 
+static int ed_marker_make_links_scene_exec(bContext *C, wmOperator *op)
+{
+       ListBase *markers= context_get_markers(C);
+       Scene *scene_to= BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "type"));
+       TimeMarker *marker, *marker_new;
+
+       if(scene_to==NULL) {
+               BKE_report(op->reports, RPT_ERROR, "Scene not found");
+               return OPERATOR_CANCELLED;
+       }
+
+       if(scene_to == CTX_data_scene(C)) {
+               BKE_report(op->reports, RPT_ERROR, "Can't link objects into the same scene");
+               return OPERATOR_CANCELLED;
+       }
+
+       /* copy markers */
+       for (marker= markers->first; marker; marker= marker->next) {
+               if(marker->flag & SELECT) {
+                       marker_new= MEM_dupallocN(marker);
+                       BLI_addtail(&scene_to->markers, marker_new);
+               }
+       }
+
+       /* one day multiple scenes will be visible, then we should have some update function for them */
+       return OPERATOR_FINISHED;
+}
+
+static void MARKER_OT_make_links_scene(wmOperatorType *ot)
+{
+       PropertyRNA *prop;
+
+       /* identifiers */
+       ot->name= "Make Links to Scene";
+       ot->description= "Link markers to another scene.";
+       ot->idname= "MARKER_OT_make_links_scene";
+
+       /* api callbacks */
+       ot->exec= ed_marker_make_links_scene_exec;
+       ot->poll= ED_operator_areaactive;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+       /* properties */
+       prop= RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, 0, "Type", "");
+       RNA_def_enum_funcs(prop, RNA_scene_itemf);
+
+}
+
 #ifdef DURIAN_CAMERA_SWITCH
 /* ******************************* camera bind marker ***************** */
 
@@ -1039,6 +1092,7 @@ void ED_operatortypes_marker(void)
        WM_operatortype_append(MARKER_OT_select_border);
        WM_operatortype_append(MARKER_OT_select_all);
        WM_operatortype_append(MARKER_OT_delete);
+       WM_operatortype_append(MARKER_OT_make_links_scene);
 #ifdef DURIAN_CAMERA_SWITCH
        WM_operatortype_append(MARKER_OT_camera_bind);
 #endif