Fix Split Strips operator not showing shortcut

This is because the menu entry was using different operator
properties from what the shortcut is defined for. It was needed
to make it so an operator which is called from the menu does not
have dependency on the mouse location.

Now it is achieved by resolving MOUSE side to RIGHT from the
operator's exec().

Ref #112598

Pull Request: https://projects.blender.org/blender/blender/pulls/113143
This commit is contained in:
Sergey Sharybin
2023-10-02 16:20:31 +02:00
committed by Sergey Sharybin
parent 3a00ba53a1
commit 0e01667e25
2 changed files with 28 additions and 9 deletions

View File

@@ -20,6 +20,7 @@ from bl_ui.space_toolsystem_common import (
ToolActivePanelHelper,
)
from rna_prop_ui import PropertyPanel
from bl_ui_utils.layout import operator_context
def _space_view_types(st):
@@ -988,13 +989,12 @@ class SEQUENCER_MT_strip(Menu):
layout.menu("SEQUENCER_MT_strip_retiming")
layout.separator()
props = layout.operator("sequencer.split", text="Split")
props.type = 'SOFT'
props.side = 'RIGHT'
with operator_context(layout, 'EXEC_REGION_WIN'):
props = layout.operator("sequencer.split", text="Split")
props.type = 'SOFT'
props = layout.operator("sequencer.split", text="Hold Split")
props.type = 'HARD'
props.side = 'RIGHT'
props = layout.operator("sequencer.split", text="Hold Split")
props.type = 'HARD'
layout.separator()

View File

@@ -1401,6 +1401,23 @@ EnumPropertyItem prop_side_types[] = {
{0, nullptr, 0, nullptr, nullptr},
};
/* Get the splitting side for the Split Strips's operator exec() callback. */
static int sequence_split_side_for_exec_get(wmOperator *op)
{
const int split_side = RNA_enum_get(op->ptr, "side");
/* The mouse position can not be resolved from the exec() as the mouse coordinate is not
* accessible. So fall-back to the RIGHT side instead.
*
* The SEQ_SIDE_MOUSE is used by the Strip menu, together with the EXEC_DEFAULT operator
* context in order to have properly resolved shortcut in the menu. */
if (split_side == SEQ_SIDE_MOUSE) {
return SEQ_SIDE_RIGHT;
}
return split_side;
}
static int sequencer_split_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
@@ -1409,11 +1426,13 @@ static int sequencer_split_exec(bContext *C, wmOperator *op)
bool changed = false;
bool seq_selected = false;
const int split_frame = RNA_int_get(op->ptr, "frame");
const int split_channel = RNA_int_get(op->ptr, "channel");
const bool use_cursor_position = RNA_boolean_get(op->ptr, "use_cursor_position");
const int split_frame = use_cursor_position ? RNA_int_get(op->ptr, "frame") : scene->r.cfra;
const int split_channel = use_cursor_position ? RNA_int_get(op->ptr, "channel") : 0;
const eSeqSplitMethod method = eSeqSplitMethod(RNA_enum_get(op->ptr, "type"));
const int split_side = RNA_enum_get(op->ptr, "side");
const int split_side = sequence_split_side_for_exec_get(op);
const bool ignore_selection = RNA_boolean_get(op->ptr, "ignore_selection");
SEQ_prefetch_stop(scene);