Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iss-1881: Better handling for moving frames beyond the track cell area #1882

Merged

Conversation

MrStevns
Copy link
Member

This fixes #1881

Instead of moving keyframes back to where they were, the frames will now be shifted to the right until there's room for all selected frames.

issue-1881

Rather than putting them back to where they were
@MrStevns MrStevns changed the title iss-1881: Move frames as far as possible iss-1881: Better handling for moving frames beyond the track cell area Sep 29, 2024
@MrStevns MrStevns added this to the 0.8.0 milestone Oct 3, 2024
@J5lx J5lx self-assigned this Feb 15, 2025
Copy link
Member

@J5lx J5lx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok so this fix seems to work just as described (except that it also affects frames being moved on top of other frames, but I assume that’s intended), however I’m a little confused why it requires so much work. To me it seems like the simplified diff below would essentially have the same effect, yet you must have had a reason to go with the more involved approach. Do you still remember what it is that necessitates the extra work?

diff --git a/core_lib/src/structure/layer.cpp b/core_lib/src/structure/layer.cpp
index c05ca919..09ad6bde 100644
--- a/core_lib/src/structure/layer.cpp
+++ b/core_lib/src/structure/layer.cpp
@@ -640,10 +640,11 @@ bool Layer::moveSelectedFrames(int offset)
         step = 1;
 
         // Check if we are not moving out of the timeline
-        if (mSelectedFrames_byPosition[0] + offset < 1) return false;
+        if (mSelectedFrames_byPosition[0] + offset < 1) offset = 1 - mSelectedFrames_byPosition[0];
     }
 
-    if (!canMoveSelectedFramesToOffset(offset)) { return false; }
+    while (!canMoveSelectedFramesToOffset(offset)) { offset += 1; }
+    if (offset == 0) { return false; }
 
     for (; indexInSelection > -1 && indexInSelection < mSelectedFrames_byPosition.count(); indexInSelection += step)
     {

@MrStevns
Copy link
Member Author

MrStevns commented Feb 19, 2025

Thanks for reviewing Jakob. If there was a reason for making it so elaborated, I cannot remember it anymore.

Your suggested diff does indeed work. I don't see a reason to complicate the logic further if we can avoid it. I'll revert my changes and apply yours instead.

Copy link
Member

@J5lx J5lx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, alright then! Thanks for double checking.

@J5lx J5lx merged commit fe07f10 into pencil2d:master Feb 20, 2025
7 of 8 checks passed
chchwy pushed a commit that referenced this pull request Feb 25, 2025
* iss-1881: Move frames as far as possible

Rather than putting them back to where they were

* Exchange implementation for a simpler one

* Remove stray parameter doc

---------

Co-authored-by: Jakob Gahde <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

0.7 Keyframe Moving Beyond Layer Names
2 participants