-
Notifications
You must be signed in to change notification settings - Fork 275
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
Maintain active layer track in view #1867
Maintain active layer track in view #1867
Conversation
automatically scroll the layer UI vertically in order to maintain the current layer visible, so that selecting layers with the Up and Down arrows doesn't end up with the active one being out of view if you have many layers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution, this is an excellent improvement to the timeline.
Changes looks good to me, and it works as expected for me.
Good job 👍
Feel free to merge if you're happy with the changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, I missed the quite important caveat, which I can confirm happens. We need to take care of that.
Unfortunately the timeline cell logic is such a mess, it might not be trivial to fix without introducing some other bug.
You don't need to click on a half hidden layer to make it happen either, if you add 5 layers and click on layer 2, then it also happens.
Maybe instead of listening to Or a simpler way, which I couldn't figure out is to directly listen to arrow key presses from Or maybe even change the |
@MrStevns is the signature change of |
I'm not convinced that either of these will fix the problem. Why should changing the signature of edit: upon further inspection, it is indeed caused by the code in TimelineCells. For this to work properly, I think you'll have to add some logic that prevents it from doing the layer swapping on mouse release when you're not explicitly dragging. |
Consider the following: void TimeLine::currentLayerChanged(int layerIndex, LayerChangeSource source) I can check whether
I'll have to see what I can do about that. |
Just checked on Nightly and indeed it does not scroll by default when clicking, which means my theoretical fix could work. 2024-07-26.17-07-02.mp4 |
I did a quick test and it did work, but I ended up changing too many places that use the 2024-07-26.17-21-59.mp4 |
...and listen to it in timeline.cpp instead of the old signal. this fixes an issue with the current layer scrolling implementation where clicking a barely-visible layer would move it due to the scrolling happening while the pointer was still being pressed. now clicking layers no longer triggers the scrolling, only the Up and Down arrow keys do. note that I didn't remove the original signal emission from the goto methods not to break anything else.
We do not want to complicate the layer manager with what source; be it keyboard or mouse, is required to trigger an behavior that is meant for a GUI element. It's a good thing that you're experimenting and that you've found a few solutions that works. However, I still think we should deal with this through the interface code, rather than adding an additional emitter logic to the LayerManager, when the source of the problem comes from the timeline logic. I can understand if you're reluctant to add more code to the timeline cell logic, as it's a mess but that's imo. the correct way to fix this issue. Any other way is beating around the bush. |
I wouldn't even know where to begin. I understand that this simple fix is not the ideal solution but it works and unfortunately this is all I can provide at the moment. |
This reverts commit 662ba4f.
This prevents the timeline cells from swapping layers while the scrollbar emits changes.
So we can reset the 'mScrollingVertically' properly.
e1dd21b
to
c1cdbb2
Compare
No worries, I took a stab at it which required minimal amount of changes to TimeLineCells. I figured that a timer that triggers after x milliseconds would do the trick. It will only trigger once we've scrolled one way or another, and only once. After inspecting the TimeLine class myself I also noticed that we had a ´layerChanged` slot already, so I've refactored your logic into that method instead of having an additional signal. Let me know what you think. |
I personally don't understand why you would opt for a more complex implementation that uses a timer over simply emitting two signals and picking one to listen to depending on what makes the most sense. Sure, it wasn't an elegant solution, but it was simple and worked pretty well. That being said, if the new solution works better for you then there's nothing I can do about it. |
I get your point but what might seem like a simpler solution at first, doesn't make sense in the long run. Your solution adds seemingly abysmal complexity to the core layer manager, an object that is tied to everything, to fix a specific scenario in a specific GUI component, while I add logic to the timeline, which only affects that specific component and lives in the APP part of the code base. Consider this example. Another person writes their own app client for Pencil2D; possibly for mobile, and write a better timeline implementation. Why should they have to deal with this new signal, when it's a problem in our GUI code? Small things like this add up over time and makes the code base less maintainable. Even though we're open source, doesn't mean we don't want the code to be as good as it can be. It's not a rant nor critique, truthfully, I'm just trying to voice why I think it's important to fix bugs where they appear. :) |
Fixes #1858.
This change maintains the currently selected layer visible when the active layer changes, so that using the Up and Down arrow keys works as expected:
2024-07-24.02-20-20.mp4
It also works when the layer is far away from view, not just right above/below:
2024-07-24.02-38-54.mp4
Caveat
When clicking on a layer that is barely in view (which isn't considered as in view by the code), it is moved due to the sudden scroll as the cursor is still being held:
2024-07-24.01-59-36.mp4
I thought of making it so that the layer is only selected upon mouse release but I'm willing to bet the code responsible for reordering layers decides which one to move based on which one is active, but I could be wrong.
Another potential solution would be to snap the timeline height so that it never shows half a layer: