forked from bartvdbraak/blender
Add flag that prevents editing of markers. Can be located in marker
menu. When active, all editing operators for markers will not fire up.
This commit is contained in:
parent
68eeeea57e
commit
ed40d5eaa7
@ -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__)
|
||||
|
@ -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;
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user