这是indexloc提供的服务,不要输入任何密码
Skip to content

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 <j5lx@fmail.co.uk>
@chchwy chchwy changed the title iss-1881: Better handling for moving frames beyond the track cell area #1881: Better handling for moving frames beyond the track cell area Jun 19, 2025
@chchwy chchwy modified the milestones: 0.8.0, 0.7.1 Jun 19, 2025
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

3 participants