mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
VSE: Improve meta strip selection logic
This patch makes a couple small changes to meta strip selection to
make it more intuitive:
- Don't select meta strip contents whenever a meta strip is selected
- This was a holdover from back when there was no proper transform
code for meta strips and was necessary at the time.
- However nowadays this is not very useful; better to avoid tampering
with the selection state.
- Leave meta strip contents deselected after initial creation.
- When separating a meta strip, expand the current selection with the
former meta strip contents, auto-selecting them.
- This lets the user immediately apply an operator on the resulting
separated strips afterwards.
Finally, also poll away the unmeta operator if the active strip isn't
selected. This is to avoid confusion where there could be selected
strips that differ from the active one.
Pull Request: https://projects.blender.org/blender/blender/pulls/161102
This commit is contained in:
parent
ae440e2d4a
commit
fcc881f65e
4 changed files with 36 additions and 50 deletions
|
|
@ -1369,7 +1369,7 @@ class SEQUENCER_MT_context_menu(Menu):
|
|||
layout.separator()
|
||||
in_meta = len(context.sequencer_scene.sequence_editor.meta_stack) > 0
|
||||
show_make = has_selection
|
||||
show_separate = strip_type == 'META'
|
||||
show_separate = strip_type == 'META' and context.active_strip and context.active_strip.select
|
||||
show_toggle = in_meta or (strip_type == 'META' and has_selection)
|
||||
if show_make or show_separate or show_toggle:
|
||||
if show_make:
|
||||
|
|
|
|||
|
|
@ -213,6 +213,28 @@ bool sequencer_strip_editable_poll(bContext *C)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool sequencer_strip_editable_and_selected_poll(bContext *C)
|
||||
{
|
||||
const Scene *scene = CTX_data_sequencer_scene(C);
|
||||
if (!scene || !ID_IS_EDITABLE(&scene->id)) {
|
||||
return false;
|
||||
}
|
||||
const Editing *ed = seq::editing_get(scene);
|
||||
if (!ed) {
|
||||
return false;
|
||||
}
|
||||
const Strip *strip_active = ed->act_strip;
|
||||
if (!strip_active) {
|
||||
CTX_wm_operator_poll_msg_set(C, "No active strip");
|
||||
return false;
|
||||
}
|
||||
if ((strip_active->flag & SEQ_SELECT) == 0) {
|
||||
CTX_wm_operator_poll_msg_set(C, "Active strip isn't selected");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool sequencer_strip_has_path_poll(bContext *C)
|
||||
{
|
||||
Scene *scene = CTX_data_sequencer_scene(C);
|
||||
|
|
@ -3006,6 +3028,7 @@ static wmOperatorStatus sequencer_meta_make_exec(bContext *C, wmOperator * /*op*
|
|||
channel_min = min_ii(strip->channel, channel_min);
|
||||
meta_start_frame = min_ii(strip->left_handle(), meta_start_frame);
|
||||
meta_end_frame = max_ii(strip->right_handle(scene), meta_end_frame);
|
||||
strip->flag &= ~STRIP_ALLSEL;
|
||||
}
|
||||
|
||||
ListBaseT<SeqTimelineChannel> *channels_cur = seq::channels_displayed_get(ed);
|
||||
|
|
@ -3030,7 +3053,7 @@ static wmOperatorStatus sequencer_meta_make_exec(bContext *C, wmOperator * /*op*
|
|||
|
||||
seq::strip_lookup_invalidate(ed);
|
||||
DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
|
||||
sequencer_select_do_updates(C, scene);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
|
@ -3069,6 +3092,10 @@ static wmOperatorStatus sequencer_meta_separate_exec(bContext *C, wmOperator * /
|
|||
seq::prefetch_stop(scene);
|
||||
|
||||
for (Strip &strip : active_strip->seqbase) {
|
||||
/* Expand selection to meta strip's old contents. */
|
||||
strip.flag &= ~STRIP_ALLSEL;
|
||||
strip.flag |= SEQ_SELECT;
|
||||
|
||||
seq::relations_invalidate_cache(scene, &strip);
|
||||
}
|
||||
|
||||
|
|
@ -3091,8 +3118,8 @@ static wmOperatorStatus sequencer_meta_separate_exec(bContext *C, wmOperator * /
|
|||
}
|
||||
}
|
||||
|
||||
sequencer_select_do_updates(C, scene);
|
||||
DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
|
@ -3106,7 +3133,7 @@ void SEQUENCER_OT_meta_separate(wmOperatorType *ot)
|
|||
|
||||
/* API callbacks. */
|
||||
ot->exec = sequencer_meta_separate_exec;
|
||||
ot->poll = sequencer_edit_poll;
|
||||
ot->poll = sequencer_strip_editable_and_selected_poll;
|
||||
|
||||
/* Flags. */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
|
|
|||
|
|
@ -193,6 +193,7 @@ bool sequencer_editing_initialized_and_active(bContext *C);
|
|||
/* UNUSED */
|
||||
// bool sequencer_strip_poll( bContext *C);
|
||||
bool sequencer_strip_editable_poll(bContext *C);
|
||||
bool sequencer_strip_editable_and_selected_poll(bContext *C);
|
||||
bool sequencer_strip_has_path_poll(bContext *C);
|
||||
bool sequencer_view_has_preview_poll(bContext *C);
|
||||
bool sequencer_view_preview_only_poll(const bContext *C);
|
||||
|
|
@ -283,7 +284,6 @@ rctf strip_bounds_get(const Scene *scene, const Strip *strip);
|
|||
rcti strip_int_bounds_get(const Scene *scene, const Strip *strip);
|
||||
|
||||
Strip *find_neighboring_strip(const Scene *scene, const Strip *test, const int lr, int sel);
|
||||
void recurs_sel_strip(Strip *strip_meta);
|
||||
|
||||
void SEQUENCER_OT_select_all(wmOperatorType *ot);
|
||||
void SEQUENCER_OT_select(wmOperatorType *ot);
|
||||
|
|
|
|||
|
|
@ -159,7 +159,6 @@ static void select_surrounding_handles(Scene *scene, Strip *test) /* XXX BRING B
|
|||
neighbor->flag |= SEQ_RIGHTSEL;
|
||||
}
|
||||
neighbor->flag |= SEQ_SELECT;
|
||||
recurs_sel_strip(neighbor);
|
||||
}
|
||||
neighbor = find_neighboring_strip(scene, test, seq::SIDE_RIGHT, -1);
|
||||
if (neighbor) {
|
||||
|
|
@ -167,7 +166,6 @@ static void select_surrounding_handles(Scene *scene, Strip *test) /* XXX BRING B
|
|||
neighbor->flag |= SEQ_LEFTSEL;
|
||||
}
|
||||
neighbor->flag |= SEQ_SELECT;
|
||||
recurs_sel_strip(neighbor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -251,17 +249,14 @@ static void select_linked_time_strip(const Scene *scene,
|
|||
/* Direct match, copy all selection settings. */
|
||||
strip_dest.flag &= ~STRIP_ALLSEL;
|
||||
strip_dest.flag |= strip_source->flag & STRIP_ALLSEL;
|
||||
recurs_sel_strip(&strip_dest);
|
||||
}
|
||||
else if (left_match && handle_clicked == STRIP_HANDLE_LEFT) {
|
||||
strip_dest.flag &= ~(SEQ_SELECT | SEQ_LEFTSEL);
|
||||
strip_dest.flag |= strip_source->flag & (SEQ_SELECT | SEQ_LEFTSEL);
|
||||
recurs_sel_strip(&strip_dest);
|
||||
}
|
||||
else if (right_match && handle_clicked == STRIP_HANDLE_RIGHT) {
|
||||
strip_dest.flag &= ~(SEQ_SELECT | SEQ_RIGHTSEL);
|
||||
strip_dest.flag |= strip_source->flag & (SEQ_SELECT | SEQ_RIGHTSEL);
|
||||
recurs_sel_strip(&strip_dest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -289,7 +284,6 @@ void select_strip_single(Scene *scene, Strip *strip, bool deselect_all)
|
|||
seq::select_active_set(scene, strip);
|
||||
|
||||
strip->flag |= SEQ_SELECT;
|
||||
recurs_sel_strip(strip);
|
||||
}
|
||||
|
||||
rctf strip_bounds_get(const Scene *scene, const Strip *strip)
|
||||
|
|
@ -379,31 +373,6 @@ static void select_neighbor_from_last(Scene *scene, int lr)
|
|||
}
|
||||
#endif
|
||||
|
||||
void recurs_sel_strip(Strip *strip_meta)
|
||||
{
|
||||
Strip *strip;
|
||||
strip = static_cast<Strip *>(strip_meta->seqbase.first);
|
||||
|
||||
while (strip) {
|
||||
|
||||
if (strip_meta->flag & (SEQ_LEFTSEL + SEQ_RIGHTSEL)) {
|
||||
strip->flag &= ~STRIP_ALLSEL;
|
||||
}
|
||||
else if (strip_meta->flag & SEQ_SELECT) {
|
||||
strip->flag |= SEQ_SELECT;
|
||||
}
|
||||
else {
|
||||
strip->flag &= ~STRIP_ALLSEL;
|
||||
}
|
||||
|
||||
if (strip->seqbase.first) {
|
||||
recurs_sel_strip(strip);
|
||||
}
|
||||
|
||||
strip = static_cast<Strip *>(strip->next);
|
||||
}
|
||||
}
|
||||
|
||||
bool strip_point_image_isect(const Scene *scene, const Strip *strip, float point_view[2])
|
||||
{
|
||||
const Array<float2> strip_image_quad = seq::image_transform_quad_get(scene, strip);
|
||||
|
|
@ -505,7 +474,6 @@ void SEQUENCER_OT_select_all(wmOperatorType *ot)
|
|||
static void sequencer_select_set_active(Scene *scene, Strip *strip)
|
||||
{
|
||||
seq::select_active_set(scene, strip);
|
||||
recurs_sel_strip(strip);
|
||||
}
|
||||
|
||||
static void sequencer_select_side_of_frame(const bContext *C,
|
||||
|
|
@ -522,7 +490,6 @@ static void sequencer_select_side_of_frame(const bContext *C,
|
|||
{
|
||||
/* Select left or right. */
|
||||
strip_iter.flag |= SEQ_SELECT;
|
||||
recurs_sel_strip(&strip_iter);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -580,10 +547,9 @@ static void sequencer_select_linked_handle(const bContext *C,
|
|||
}
|
||||
else {
|
||||
strip->flag |= SEQ_SELECT;
|
||||
neighbor->flag |= SEQ_SELECT;
|
||||
recurs_sel_strip(neighbor);
|
||||
neighbor->flag |= SEQ_RIGHTSEL;
|
||||
strip->flag |= SEQ_LEFTSEL;
|
||||
neighbor->flag |= SEQ_SELECT;
|
||||
neighbor->flag |= SEQ_RIGHTSEL;
|
||||
}
|
||||
break;
|
||||
case seq::SIDE_RIGHT:
|
||||
|
|
@ -594,10 +560,9 @@ static void sequencer_select_linked_handle(const bContext *C,
|
|||
}
|
||||
else {
|
||||
strip->flag |= SEQ_SELECT;
|
||||
neighbor->flag |= SEQ_SELECT;
|
||||
recurs_sel_strip(neighbor);
|
||||
neighbor->flag |= SEQ_LEFTSEL;
|
||||
strip->flag |= SEQ_RIGHTSEL;
|
||||
neighbor->flag |= SEQ_SELECT;
|
||||
neighbor->flag |= SEQ_LEFTSEL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -1535,13 +1500,11 @@ static bool select_linked_internal(Scene *scene)
|
|||
Strip *neighbor = find_neighboring_strip(scene, &strip, seq::SIDE_LEFT, 0);
|
||||
if (neighbor) {
|
||||
neighbor->flag |= SEQ_SELECT;
|
||||
recurs_sel_strip(neighbor);
|
||||
changed = true;
|
||||
}
|
||||
neighbor = find_neighboring_strip(scene, &strip, seq::SIDE_RIGHT, 0);
|
||||
if (neighbor) {
|
||||
neighbor->flag |= SEQ_SELECT;
|
||||
recurs_sel_strip(neighbor);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1581,7 +1544,6 @@ static bool select_more_less_impl(Scene *scene, bool select_more)
|
|||
for (Strip *neighbor : neighbors) {
|
||||
if (select_more) {
|
||||
neighbor->flag |= SEQ_SELECT;
|
||||
recurs_sel_strip(neighbor);
|
||||
}
|
||||
else {
|
||||
neighbor->flag &= ~SEQ_SELECT;
|
||||
|
|
@ -1686,7 +1648,6 @@ static wmOperatorStatus sequencer_select_linked_pick_invoke(bContext *C,
|
|||
}
|
||||
|
||||
mouse_selection.strip1->flag |= SEQ_SELECT;
|
||||
recurs_sel_strip(mouse_selection.strip1);
|
||||
|
||||
bool selected = true;
|
||||
while (selected) {
|
||||
|
|
@ -1839,7 +1800,6 @@ static wmOperatorStatus sequencer_select_handles_exec(bContext *C, wmOperator *o
|
|||
if ((strip.flag & SEQ_LEFTSEL) || (strip.flag & SEQ_RIGHTSEL)) {
|
||||
if (!(strip.flag & SEQ_SELECT)) {
|
||||
strip.flag |= SEQ_SELECT;
|
||||
recurs_sel_strip(&strip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1910,7 +1870,6 @@ static wmOperatorStatus sequencer_select_side_of_frame_exec(bContext *C, wmOpera
|
|||
|
||||
if (test) {
|
||||
strip.flag |= SEQ_SELECT;
|
||||
recurs_sel_strip(&strip);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue