UI: Show ANIM_OT_change_frame as "Set Frame (Solo Preview)" in VSE

Operator ANIM_OT_change_frame currently has a hidden feature when used
within the Sequencer, called "Solo Preview". But this feature is not
advertised anywhere in the interface. This PR adds a new property to
the operator called "seq_preview" that enables this feature and then
shows the name as "Set Frame (Solo Preview)".
This commit is contained in:
Harley Acheson
2025-02-26 01:54:26 +01:00
committed by Harley Acheson
parent 956a0fad80
commit ac549dcfde
2 changed files with 46 additions and 13 deletions

View File

@@ -2759,9 +2759,19 @@ def km_nla_editor(params):
{"properties": [("mode", 'TIME_SCALE')]}),
("marker.add", {"type": 'M', "value": 'PRESS'}, None),
*_template_items_context_menu("NLA_MT_context_menu", params.context_menu_event),
*_template_items_change_frame(params),
])
if params.select_mouse == 'LEFTMOUSE' and not params.legacy:
items.extend([
("anim.change_frame", {"type": 'RIGHTMOUSE', "value": 'PRESS', "shift": True},
{"properties": [("seq_solo_preview", True)]}),
])
else:
items.extend([
("anim.change_frame", {"type": params.action_mouse, "value": 'PRESS'},
{"properties": [("seq_solo_preview", True)]}),
])
return keymap
@@ -8114,7 +8124,8 @@ def km_sequencer_editor_tool_generic_select_timeline_rcs(params):
("sequencer.select_handle", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
("sequencer.select_handle", {"type": 'LEFTMOUSE', "value": 'PRESS',
"alt": True}, {"properties": [("ignore_connections", True)]}),
*_template_items_change_frame(params),
("anim.change_frame", {"type": params.action_mouse, "value": 'PRESS'},
{"properties": [("seq_solo_preview", True)]}),
# Change frame takes precedence over the sequence slide operator. If a
# mouse press happens on a strip handle, it is canceled, and the sequence
# slide below activates instead.
@@ -8128,7 +8139,8 @@ def km_sequencer_editor_tool_generic_select_timeline_lcs(params):
("sequencer.select", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
("sequencer.select", {"type": 'LEFTMOUSE', "value": 'PRESS',
"shift": True}, {"properties": [("toggle", True)]}),
*_template_items_change_frame(params),
("anim.change_frame", {"type": 'RIGHTMOUSE', "value": 'PRESS',
"shift": True}, {"properties": [("seq_solo_preview", True)]}),
]

View File

@@ -25,6 +25,8 @@
#include "BKE_report.hh"
#include "BKE_scene.hh"
#include "BLT_translation.hh"
#include "UI_view2d.hh"
#include "RNA_access.hh"
@@ -276,9 +278,12 @@ static int change_frame_invoke(bContext *C, wmOperator *op, const wmEvent *event
}
screen->scrubbing = true;
SpaceSeq *sseq = CTX_wm_space_seq(C);
if (sseq) {
change_frame_seq_preview_begin(C, event, sseq);
if (RNA_boolean_get(op->ptr, "seq_solo_preview")) {
SpaceSeq *sseq = CTX_wm_space_seq(C);
if (sseq) {
change_frame_seq_preview_begin(C, event, sseq);
}
}
change_frame_apply(C, op, true);
@@ -303,14 +308,16 @@ static bool need_extra_redraw_after_scrubbing_ends(bContext *C)
return false;
}
static void change_frame_cancel(bContext *C, wmOperator * /*op*/)
static void change_frame_cancel(bContext *C, wmOperator *op)
{
bScreen *screen = CTX_wm_screen(C);
screen->scrubbing = false;
SpaceSeq *sseq = CTX_wm_space_seq(C);
if (sseq != nullptr) {
change_frame_seq_preview_end(sseq);
if (RNA_boolean_get(op->ptr, "seq_solo_preview")) {
SpaceSeq *sseq = CTX_wm_space_seq(C);
if (sseq != nullptr) {
change_frame_seq_preview_end(sseq);
}
}
if (need_extra_redraw_after_scrubbing_ends(C)) {
@@ -369,10 +376,13 @@ static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event)
bScreen *screen = CTX_wm_screen(C);
screen->scrubbing = false;
SpaceSeq *sseq = CTX_wm_space_seq(C);
if (sseq != nullptr) {
change_frame_seq_preview_end(sseq);
if (RNA_boolean_get(op->ptr, "seq_solo_preview")) {
SpaceSeq *sseq = CTX_wm_space_seq(C);
if (sseq != nullptr) {
change_frame_seq_preview_end(sseq);
}
}
if (need_extra_redraw_after_scrubbing_ends(C)) {
Scene *scene = CTX_data_scene(C);
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
@@ -382,6 +392,15 @@ static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event)
return ret;
}
static std::string change_frame_get_name(wmOperatorType * /*ot*/, PointerRNA *ptr)
{
if (RNA_boolean_get(ptr, "seq_solo_preview")) {
return CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Set Frame (Strip Preview)");
}
return {};
}
static void ANIM_OT_change_frame(wmOperatorType *ot)
{
PropertyRNA *prop;
@@ -397,6 +416,7 @@ static void ANIM_OT_change_frame(wmOperatorType *ot)
ot->cancel = change_frame_cancel;
ot->modal = change_frame_modal;
ot->poll = change_frame_poll;
ot->get_name = change_frame_get_name;
/* flags */
ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR_X | OPTYPE_UNDO_GROUPED;
@@ -406,6 +426,7 @@ static void ANIM_OT_change_frame(wmOperatorType *ot)
ot->prop = RNA_def_float(
ot->srna, "frame", 0, MINAFRAME, MAXFRAME, "Frame", "", MINAFRAME, MAXFRAME);
prop = RNA_def_boolean(ot->srna, "snap", false, "Snap", "");
prop = RNA_def_boolean(ot->srna, "seq_solo_preview", false, "Strip Preview", "");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}