Add flag that prevents editing of markers. Can be located in marker
authorAntony Riakiotakis <kalast@gmail.com>
Tue, 14 Apr 2015 10:11:24 +0000 (12:11 +0200)
committerAntony Riakiotakis <kalast@gmail.com>
Tue, 14 Apr 2015 10:12:17 +0000 (12:12 +0200)
menu.

When active, all editing operators for markers will not fire up.

release/scripts/startup/bl_ui/space_time.py
source/blender/editors/animation/anim_markers.c
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_scene.c

index 819c2af4200540632dba60d33213751d5cba0dcc..2a3bcfc01ba32189aa2744df62b6eb6927b3aaad 100644 (file)
@@ -254,6 +254,10 @@ def marker_menu_generic(layout):
     layout.operator("screen.marker_jump", text="Jump to Next Marker").next = True
     layout.operator("screen.marker_jump", text="Jump to Previous Marker").next = False
 
+    layout.separator()
+    ts = bpy.context.tool_settings
+    layout.prop(ts, "marker_lock")
+
 
 if __name__ == "__main__":  # only for live edit.
     bpy.utils.register_module(__name__)
index 68660740ac7e061ebae2782b9451947aed4ee518..ac6a0aede17d9993c479f2393d14194b528172c2 100644 (file)
@@ -499,6 +499,23 @@ static int ed_markers_poll_selected_markers(bContext *C)
        return ED_markers_get_first_selected(markers) != NULL;
 }
 
+static int ed_markers_poll_selected_no_locked_markers(bContext *C)
+{
+       ListBase *markers = ED_context_get_markers(C);
+       ToolSettings *ts = CTX_data_tool_settings(C);
+
+       if (ts->marker_lock)
+               return 0;
+
+       /* first things first: markers can only exist in timeline views */
+       if (ED_operator_animview_active(C) == 0)
+               return 0;
+
+       /* check if some marker is selected */
+       return ED_markers_get_first_selected(markers) != NULL;
+}
+
+
 /* special poll() which checks if there are any markers at all first */
 static int ed_markers_poll_markers_exist(bContext *C)
 {
@@ -941,7 +958,7 @@ static void MARKER_OT_move(wmOperatorType *ot)
        ot->exec = ed_marker_move_exec;
        ot->invoke = ed_marker_move_invoke_wrapper;
        ot->modal = ed_marker_move_modal;
-       ot->poll = ed_markers_poll_selected_markers;
+       ot->poll = ed_markers_poll_selected_no_locked_markers;
        ot->cancel = ed_marker_move_cancel;
        
        /* flags */
@@ -1034,7 +1051,7 @@ static void MARKER_OT_duplicate(wmOperatorType *ot)
        ot->exec = ed_marker_duplicate_exec;
        ot->invoke = ed_marker_duplicate_invoke_wrapper;
        ot->modal = ed_marker_move_modal;
-       ot->poll = ed_markers_poll_selected_markers;
+       ot->poll = ed_markers_poll_selected_no_locked_markers;
        ot->cancel = ed_marker_move_cancel;
        
        /* flags */
@@ -1364,7 +1381,7 @@ static void MARKER_OT_delete(wmOperatorType *ot)
        /* api callbacks */
        ot->invoke = ed_marker_delete_invoke_wrapper;
        ot->exec = ed_marker_delete_exec;
-       ot->poll = ed_markers_poll_selected_markers;
+       ot->poll = ed_markers_poll_selected_no_locked_markers;
        
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1412,7 +1429,7 @@ static void MARKER_OT_rename(wmOperatorType *ot)
        /* api callbacks */
        ot->invoke = ed_marker_rename_invoke_wrapper;
        ot->exec = ed_marker_rename_exec;
-       ot->poll = ed_markers_poll_selected_markers;
+       ot->poll = ed_markers_poll_selected_no_locked_markers;
        
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1440,6 +1457,11 @@ static int ed_marker_make_links_scene_exec(bContext *C, wmOperator *op)
                return OPERATOR_CANCELLED;
        }
 
+       if (scene_to->toolsettings->marker_lock) {
+               BKE_report(op->reports, RPT_ERROR, "Target scene has locked markers");
+               return OPERATOR_CANCELLED;
+       }
+
        /* copy markers */
        for (marker = markers->first; marker; marker = marker->next) {
                if (marker->flag & SELECT) {
@@ -1521,7 +1543,7 @@ static void MARKER_OT_camera_bind(wmOperatorType *ot)
        /* api callbacks */
        ot->exec = ed_marker_camera_bind_exec;
        ot->invoke = ed_markers_opwrap_invoke;
-       ot->poll = ed_markers_poll_selected_markers;
+       ot->poll = ed_markers_poll_selected_no_locked_markers;
 
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
index 2f54dfa811602b6f0053a8bad8c2fe5f60758ae2..e03d77d4ec5471797be7d594a2f35b9f90194776 100644 (file)
@@ -1272,7 +1272,8 @@ typedef struct ToolSettings {
        char proportional_mask; /* proportional edit, mask editing */
        char proportional_action; /* proportional edit, action editor */
        char proportional_fcurve; /* proportional edit, graph editor */
-       char pad4[6];
+       char marker_lock; /* lock marker editing */
+       char pad4[5];
 
        char auto_normalize; /*auto normalizing mode in wpaint*/
        char multipaint; /* paint multiple bones in wpaint */
index ee77bccc340a5e9b7e4a7828185bcdc02c75a124..a17a746945c7f57a2f7724e6610dffbec18a5628 100644 (file)
@@ -2180,6 +2180,10 @@ static void rna_def_tool_settings(BlenderRNA  *brna)
        RNA_def_property_ui_icon(prop, ICON_PROP_OFF, 1);
        RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */
 
+       prop = RNA_def_property(srna, "marker_lock", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "marker_lock", 0);
+       RNA_def_property_ui_text(prop, "Lock Markers", "Prevent marker editing");
+
        prop = RNA_def_property(srna, "proportional_edit_falloff", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "prop_mode");
        RNA_def_property_enum_items(prop, proportional_falloff_items);