Page MenuHome

VSE: Transform overwrite mode
ClosedPublic

Authored by Richard Antalik (ISS) on Jul 5 2021, 7:49 AM.

Details

Summary

Add mode to overwrite strips on overlap instead of resolving overlap.
When overlap is created, 3 things can happen:

  • On partial overlap, handles of overlapped strip are moved
  • On complete overlap with smaller strip, overlapped strip is split
  • On complete overlap with larger strip, overlapped strip is removed

This mode can be enabled in header.


Demonstration:

Diff Detail

Repository
rB Blender
Branch
arcpatch-D11805 (branched from master)
Build Status
Buildable 16645
Build 16645: arc lint + arc unit

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
  • Add overlap handling mode to header
  • Fix generator effect strips not overwriting
Richard Antalik (ISS) retitled this revision from [WIP] VSE: Transform overwrite mode to VSE: Transform overwrite mode.Jul 17 2021, 3:15 AM
Richard Antalik (ISS) edited the summary of this revision. (Show Details)Jul 17 2021, 3:24 AM

Getting two errors with the overlap patch:

Build FAILED.
C:\blender\blender-git\source\blender\blenloader\intern\versioning_300.c(204,3): error C2065: 'bmain': undeclared identifier [C:\blender\build_windows_Full_x64_vc16_Release\source\blender\blenloader\bf_blenloader.vcxproj]
C:\blender\blender-git\source\blender\blenloader\intern\versioning_300.c(204,3): error C2223: left of '->scenes' must point to struct/union [C:\blender\build_windows_Full_x64_vc16_Release\source\blender\blenloader\bf_blenloader.vcxproj]
    0 Warning(s)
    2 Error(s)

Time Elapsed 00:05:44.16

Besides this, it is working really well. 🙂

Maybe consider using the word "Insert" instead of "Expand", since this is an industry term, and this function should insert the strip when drag and dropping it inside another strip, meaning it'll make a split at the in point and ripple push all following strips to the right(but I know that this isn't the main focus right now).

It's a great addition to the VSE! Although, I agree with Peter. It should be optional. A toggle on the interface is great. It could be activated also with a modifier key when dragging the strip over another.

You properly have them on your to do list.

When using the time panel:

When adding a strip & adjust last:

Drag and drop:

The same problems applies to using Extend too.

  • remove unrelated change
  • Add only overwrite mode to header.
Richard Antalik (ISS) edited the summary of this revision. (Show Details)Jul 28 2021, 4:22 PM

I have SEQ_iterator.h:38:20: error: declaration of ‘iter’ shadows a previous local [-Werror=shadow] warning escalated to error around transform_convert_sequencer.c:534. Think typical approach of solving this is to append a line number in the macro. You'd need an extra level of indirection, something like:

#define SEQ_ITERATOR_FOREACH_IMPL(var, collection, suffix)
  for (SeqIterator iter ## suffix = {{{NULL}}}; \
       SEQ_iterator_ensure(collection, &iter ## suffix, &var) && var != NULL; \
       var = SEQ_iterator_yield(&iter ## suffix))

#define SEQ_ITERATOR_FOREACH(var, collection) SEQ_ITERATOR_FOREACH_IMPL(var, collection, __LINE__)

Generally fine, but not sure what/where is the best fit for the transform code. Germano will know better.
From me just some strict flags/formatting.

source/blender/makesdna/DNA_scene_types.h
1350

Seems to not be clang-formatted.

The logic of the transform code hasn't changed much.
Basically seq_transform_handle_overlap has been incremented/improved.
I just fear that creating so many SeqCollections during the transformation can become a heavy operation.
(But if we compare with other datablocks the computation here is minimal).

I just reviewed the transform part.
Here are my observations:

source/blender/editors/transform/transform_convert_sequencer.c
353

This name makes it look like the seqbase is from the trans_info, but apparently it is in the scene referenced by trans_info.
Would a name like seqbase_active_get or seqbase_editing_get be more descriptive?

389

It seems more overlapping than overwritten.
(But english is not my native language so I could be wrong).

397

ymin and ymax don't seem to be being used.
So it doesn't seem like they need to be calculated.

source/blender/editors/transform/transform_mode_edge_seq_slide.c
76

Do we need to use TIP_ on "("?

Richard Antalik (ISS) marked 5 inline comments as done.Aug 10 2021, 4:31 AM

I just fear that creating so many SeqCollections during the transformation can become a heavy operation.
(But if we compare with other datablocks the computation here is minimal).

Not sure if that is valid concern in this case. If you look at transformed_strips here, the collection is created once and then passed where it is needed. Before you would have to iterate whole ListBase with strips, and check which are selected, which is arguably slower but also not quite precise (effects don't have to be selected to be moved).

But you could argue that iterating SeqCollection can be slower when its length is small, but then it doesn't matter. Still this would be good to measure in practice.

source/blender/editors/transform/transform_convert_sequencer.c
389

In practice there are overlapping strips both in transformed_strips and remaining strips
By overwrite targets I mean strips that overlap, but don't belong to transformed_strips collection.

I guess this could be overlapping (belong to transformed_strips) and overlapped (not belong to transformed_strips). But I like overwrite_targets more because it's more specific.

Also there is overlap flag that is set only to strips in transformed_strips that overlap other strips.

397

They are?

r_boundbox->ymin = min_ii(r_boundbox->ymin, seq->machine);
r_boundbox->ymax = max_ii(r_boundbox->ymax, seq->machine);

But I have decided to use more precise approach, as there can be "hole" in boundbox where no overlap would occur.

source/blender/editors/transform/transform_mode_edge_seq_slide.c
76

Probably not :) Looks like mindless attempt for no functional changes... But I have still done it wrong :/ I missed comma.

Richard Antalik (ISS) marked 3 inline comments as done.
  • Fix iterator macro shadowing previos declaration
  • Address inlines
  • Cleanup: unused include
  • Cleaup: typo
  • Simplify trimming overwrite function

There was no reaction to this post above: https://developer.blender.org/D11805#308170
When the function is always exposed in the header, users will expect it to apply in all operations(and not just during Transform).
Same thing with Snapping and Extend(Insert). How are they working during similar operations?
Should I make an additional (bug-)report on this?

There was no reaction to this post above: https://developer.blender.org/D11805#308170
When the function is always exposed in the header, users will expect it to apply in all operations(and not just during Transform).
Same thing with Snapping and Extend(Insert). How are they working during similar operations?
Should I make an additional (bug-)report on this?

Thanks for the feedback on this. No need for an additional report.
I also understand the suggestion about having a "ripple" insert as well, and will take that into account in the next design iteration.

I also understand the suggestion about having a "ripple" insert as well, and will take that into account in the next design iteration.

Since you mention it yourself, is the main function of Insert(called: Expand) already implemented, it's just a question of giving it proper exposure in the header ex.: D10074
Ricard already had the exposure of Insert implemented as another edit mode in an enum with Overwrite in this patch.
It is working just as well as the Overwrite mode, so why has it been removed again? Was that your decision?

Germano Cavalcante (mano-wii) accepted this revision.EditedAug 10 2021, 9:06 PM

Oh, I didn't realize that this code is only called at the end of the transformation. Performance isn't really an issue here.
It's just a little uncomfortable to see that all these functions are called inside freeSeqData. But it's not something introduced in the patch.

I just have a few personal taste notes in the code. I'm not sure they are viable changes:

release/scripts/startup/bl_ui/space_sequencer.py
155

Just a touch, here the bool is called "Overwrite Mode" and in RNA it's called "Overlap Mode".
Is it intentional?

Personally I prefer not to have to override the property text that is automatically placed.

source/blender/editors/transform/transform_convert_sequencer.c
410–450

Personally I would prefer that all these functions that test overlap were merged into a single function that returns the enum describing the overlap.
Something like:

typedef enum eOvelap {
  STRIP_OVERLAP_NONE = 0,
  STRIP_OVERLAP_IS_SAME,
  STRIP_OVERLAP_IS_FULL,
  STRIP_OVERLAP_IS_INSIDE,
  STRIP_OVERLAP_LEFT_SIDE,
  STRIP_OVERLAP_RIGHT_SIDE,
} eOvelap;

There was no reaction to this post above: https://developer.blender.org/D11805#308170
When the function is always exposed in the header, users will expect it to apply in all operations(and not just during Transform).
Same thing with Snapping and Extend(Insert). How are they working during similar operations?
Should I make an additional (bug-)report on this?

These settings only apply to transform operator.

I also understand the suggestion about having a "ripple" insert as well, and will take that into account in the next design iteration.

Since you mention it yourself, is the main function of Insert(called: Expand) already implemented, it's just a question of giving it proper exposure in the header ex.: D10074
Ricard already had the exposure of Insert implemented as another edit mode in an enum with Overwrite in this patch.

Idea was to implement this feature in bit more defined way before adding it as option

! In D11805#315747, @Richard Antalik (ISS) wrote:
These settings only apply to transform operator.

How are the users supposed to know this? When exposing it in the main vse header, there is no reason not to assume, that all operations moving strips/clips or changing durations should be affected by this setting? Should it be moved into the Tool Settings header? And what about snap and extend are they also only for the transform operator? If so, should they also be moved into the Tool Settings header?

[From a user perspective it would make perfectly sense to let these setting affect all strip movement, and not just when the movement is done through the Transform operator]

Richard Antalik (ISS) marked an inline comment as done.
  • Revert ovelap mode property back to enum
  • Merge functions describing overlap into single function.
release/scripts/startup/bl_ui/space_sequencer.py
155

Yes, this is kinda intentional, because this is supposed to be enum instead of boolean property in future.

And it turns out, that future is now, so will convert it back to enum :)

Germano Cavalcante (mano-wii) added inline comments.
source/blender/editors/transform/transform_convert_sequencer.c
412

Maybe it's better you put this description directly over the enum definition. So IntelliSense could use it to display a quick info.

You could also optionally use earlier returns in this function.

503

You could use the ELEM macro here:
ELEM(overlap, STRIP_OVERLAP_LEFT_SIDE, STRIP_OVERLAP_RIGHT_SIDE)

Also, if I'm not mistaken, when we have if {...} else {...} in blender we usually put the comments inside the block.

if (overlap == STRIP_OVERLAP_IS_FULL) {
  /* Remove covered strip. */
  SEQ_edit_flag_for_removal(t->scene, seqbase_active_get(t), target);
  strips_delete = true;
}
else if (overlap == STRIP_OVERLAP_IS_INSIDE) {
  /* Split strip in 3 parts, remove middle part and fit transformed inside. */

To me this makes it clearer what the comment is referring to and avoids moving the else away from the }.

Richard Antalik (ISS) marked 2 inline comments as done.
  • Address inlines.

For the record, I had a chat with Richard about reverting to an earlier version of the patch, where the 3 possible transform modes are are presented through and enum.
In a next version of the patch (or after it's merged) it would be ideal to have some icons instead of the enum. @Pablo Vazquez (pablovazquez) was working on a proposal, also taking into account the suggestion from @Peter Fog (tintwotin).

source/blender/editors/transform/transform_convert_sequencer.c
503

My personal preference if to put always comment above block or statement it applies to.

for if ... else I usually do

/* Clarify something. */
if (something) {
  do_this();
}
else { /* Clarify something else. */
  do_that();
}

But for else if I place them above condition.

I guess here these comments aren't that necessary even and could be placed above function definitions, so I will do that.

source/blender/editors/transform/transform_convert_sequencer.c
444

To make it clearer what is written and what is only read, I tend to rely on the const qualifier.
It might be a good idea to see where const can be used in the parameters of these new functions.

463

Since this function should only be called with overlap STRIP_OVERLAP_LEFT_SIDE or STRIP_OVERLAP_RIGHT_SIDE, this if doesn't seem to be necessary.

Could you use BLI_assert(overlap == STRIP_OVERLAP_RIGHT_SIDE) instead?

Richard Antalik (ISS) marked 3 inline comments as done.
  • Use const where possible
  • Remove unnecessary if condition
  • Fix warning for const qualifier

It seems to fail when several strips are moved:

Limit the red warning outline to Shuffle mode only.

Imo, the Overlay enum doesn't need the text: "Overlap Mode".

Shift+S with a handle selected is also a situation users might expect Overwrite to work(but it isn't handled by the Transform operator):

The "transparent during transform" look is added when strip is placed, and only corrected when transformed again:

  • Fix incorrect condition in query_overwrite_targets

It seems to fail when several strips are moved:

Limit the red warning outline to Shuffle mode only.

I think overlapping strip/area should be visible in all modes, but it could be distinguished somehow

Imo, the Overlay enum doesn't need the text: "Overlap Mode".

This will be fixed with icons.

Shift+S with a handle selected is also a situation users might expect Overwrite to work(but it isn't handled by the Transform operator):

I can imagine this mode being used with different modal operator. I guess here it would make sense too, but not sure really.

The "transparent during transform" look is added when strip is placed, and only corrected when transformed again:

Yes, I have noticed

It seems to fail when several strips are moved:

Notice that the strips are overlapping after release and not overwritten, as they're supposed to be.

  • Fix overlapped strip transparent after resolving overlap
  • Don't draw red outline when using overwrite mode

I suggest to remove the "Overlap mode:" label and then this is good to merge.

  • Remove overwrite mode label

Let's merge this!
I prepared some documentation text, which will be pushed as soon as the code is merged. Suggestions are welcome.

Overlap Mode
============

Overlap Mode defines the result of transforming a strip so that it overlaps another strip.

Shuffle
   The default behavior. The overlapping strip will be moved to the nearest free space so that
   it does not overlap.
Overwrite
   The overlapped strip will be overwritten, trimmed or split by the overlapping strip.
Expand
   All strips will be shifted forward to accommodate the overlapping strip.
This revision is now accepted and ready to land.Aug 27 2021, 12:17 PM

Let's merge this!
I prepared some documentation text, which will be pushed as soon as the code is merged. Suggestions are welcome.

Expand
   All strips will be shifted forward to accommodate the overlapping strip.

It's more "all strips on right side of (each) transformed strip will be shifted forward...", if I remember correctly.

There are some other oddities and exceptions, but then you may copy paste code to documentation.

This revision was automatically updated to reflect the committed changes.

Great to see this being committed, but just a note on the name of Expand(and on the documentation). In the Strip/Transform menu there is also an Extend function, this is for extending the duration of strips only.
The function now exposed in the Overlap enum is also for moving strips around, where you can insert strips in between other strips. Both inserting material by trimming/transforming strip durations and moving around the order of the strips is referred to as "Insert" as industry standard. So maybe you could consider renaming this function at some point, so it'll fit better with the functionality of it, and improve the UX.

The functionality:

A freeware reference:
Flowblade: https://jliljebl.github.io/flowblade/webhelp/edit_tools.html#Insert