Fix T104073: Unable to add more than two strips in one channel

Originally, function `sequencer_generic_invoke_xy_guess_channel`
looked in what channel the last strip of the same type is and the
channel used for new strip placement. This was changed as a workaround
when sound strips were added below movie strips
(58bea005c5).
Now these workarounds aren't necessary, but the function was left
unchanged.

Current logic is for adding movie strip to channel 1 is:
- Sound is added to channel 1
- Video is added to channel 2
- If there is only video, it is added to channel 1

Since movie may, or may not contain sound, it is not possible to align
added strips in a way that was done before, unless timeline is analyzed
more in detail, but this would be quite inefficient.
Also, note, that the code did not work, if strip is added next to
previous one, so it mostly did not work as intended.

This commit changes:
- Fix alignment not working when strip is added right next to previous
  strip
- Assume that movie strips have sound strip underneath it, so channel
  below last movie strip is picked
- For other strip types, pick channel of the last strip of same type

Ultimately, the code is still rather weak, and better system, like using
channel where strip was manually moved, or concept of "typed channels"
would improve this feature.
This commit is contained in:
Richard Antalik 2023-01-24 23:17:32 +01:00
parent 1ad11355a3
commit c5d9938adc
Notes: blender-bot 2023-02-14 00:09:06 +01:00
Referenced by issue #104073, Unable to add more than two sequence strips in one channel
1 changed files with 2 additions and 2 deletions

View File

@ -201,7 +201,7 @@ static int sequencer_generic_invoke_xy_guess_channel(bContext *C, int type)
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
const int strip_end = SEQ_time_right_handle_frame_get(scene, seq);
if (ELEM(type, -1, seq->type) && (strip_end < timeline_frame) &&
if (ELEM(type, -1, seq->type) && (strip_end <= timeline_frame) &&
(timeline_frame - strip_end < proximity)) {
tgt = seq;
proximity = timeline_frame - strip_end;
@ -209,7 +209,7 @@ static int sequencer_generic_invoke_xy_guess_channel(bContext *C, int type)
}
if (tgt) {
return tgt->machine + 1;
return (type == SEQ_TYPE_MOVIE) ? tgt->machine - 1 : tgt->machine;
}
return 1;
}