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

Enhanced snapping in song editor #4973

Merged
merged 68 commits into from
Jul 27, 2019
Merged

Enhanced snapping in song editor #4973

merged 68 commits into from
Jul 27, 2019

Conversation

Spekular
Copy link
Member

@Spekular Spekular commented May 15, 2019

  • New default behavior: Preserves offsets when moving clips, resizes in fixed increments.
  • Adds shift + drag: Snaps moved start position (like current behavior) or end position (new), based on which is closest to real position. Snaps clip's edge when resizing. When moving a selection, the grabbed clip snaps into position and the rest move relative to it.
  • Adds alt + drag: Allows fine adjustment of a clip's position or size, as an alternative to drag + ctrl.
  • Adds a Q dropdown in the song editor to allow finer or coarser snapping (8 bars to 1/16th bar)
  • Adds a proportional snap toggle. When enabled, snapping size/Q adjusts based on zoom, and a label appears showing the current snap size. In other words, onscreen distance between snap points remains the same regardless of zoom level. This is disabled by default.

Will close #874.

Ready to merge.

Enhanced

Video Preview
(This shows a version where snapping modes are switched via toggle button. Since then I've switched to using modifier keys, but the snapping shown still works)

@Spekular
Copy link
Member Author

Spekular commented May 17, 2019

Icon ideas/mockups for the "proportional snap" button. Two far left are the current Quantization and zoom icons.

image

If someone feels like doing a reaction vote:
image

@Spekular Spekular changed the title Adjustable snapping in song editor [WIP] Adjustable snapping in song editor [Needs Review] May 17, 2019
@BaraMGB BaraMGB added needs code review A functional code review is currently required for this PR and removed in progress labels May 17, 2019
@Spekular Spekular changed the title Adjustable snapping in song editor [Needs Review] Adjustable snapping in song editor May 18, 2019
@Spekular Spekular changed the title Adjustable snapping in song editor Enhanced snapping in song editor May 21, 2019
@JohannesLorenz
Copy link
Contributor

The mockup voting is for a pixmap at the position where the current "Q" is?

What where your reasons to use the "Q" letter?

@Spekular
Copy link
Member Author

@JohannesLorenz The Q is there because this dropdown sets the snapping size/quantization used when moving and resizing clips (like in piano roll), so I think it works fine. The icon that needs to be made is for the proportional snap button, which is currently using the "add automation" icon.

@Spekular
Copy link
Member Author

Spekular commented May 23, 2019

Something that could be documented is the reason for the setInitialPos() function.

The mouseMoveEvent() function is called continuously(?) on mouse move. The old code worked by getting the difference between the latest update and right now. It's possible to preserve offsets with this method, or snap to grid, but you CAN'T toggle between them. Once the pattern is snapped to grid, the latest position is quantized. This means all following positions are based on a quantized position, and as such the user's offset is permanently lost.

setInitialPos() is called on mouse click, and saves:

  • Mouse position
  • Start position of the clicked TCO
  • End position of the clicked TCO
  • Offsets between every selected TCO and the clicked TCO.

Since you can't click again during a move/resize event (you're holding the mouse down to drag things around), calling setInitialPos() on a click saves the position before move. (Sidebar: can you middle or right click while moving and destroy this logic?). By saving the initial position, you always have access to the initial offset. This means you can toggle between snapping to grid and snapping in increments without losing information. All you have to do is:

  • Get the distance the mouse has moved since the last click (start of the move/resize)
  • Convert mouse distance to ticks
  • Add that to your initial position to get new position
  • Quantize according to the current snap mode

Basically, I've rewritten a lot of the code to be relative to the initial position, rather than the latest position.

One thing that could be considered a downside to this is that, currently, move and resize events stick to their initial offset the whole time. If you begin a move event by fine-adjusting the position of a clip and then release ctrl/alt, the clip will go back to snapping to the initial offset. If we consider this to be a problem, I believe there's a solution. When fine moving, we should call setInitialPos(), this saving the offset. This might need some additional changes, since it's possible that updating the initial positions this often could break other move code. We'd have to use "relative to latest position" code on fine adjustments, and "relative to initial position" on snapped.

EDIT: I've since updated the PR to fix the final paragraph above.

src/core/Track.cpp Outdated Show resolved Hide resolved
@Spekular
Copy link
Member Author

Spekular commented May 28, 2019

BaraMGB reported a bug with this on Discord. Current steps to reproduce are:

  • Click to create a clip
  • Zoom in or scroll right
  • Click on the clip

The clip should jump over towards the left.
Current suspicions:

  • mapToParent() and setInitialPos() feel relevant for investigation

@Spekular
Copy link
Member Author

@BaraMGB I believe I've fixed the bug you discovered now.

@BaraMGB
Copy link
Contributor

BaraMGB commented Jun 2, 2019

This seems to work now. But I'm not sure about this button. It is quite misleading and I can not imagine a situation where a user needs this function. The snapping works like a charm, though. 👍

src/core/Track.cpp Outdated Show resolved Hide resolved
src/core/Track.cpp Outdated Show resolved Hide resolved
src/gui/editors/SongEditor.cpp Outdated Show resolved Hide resolved
src/gui/editors/SongEditor.cpp Outdated Show resolved Hide resolved
@Spekular
Copy link
Member Author

Spekular commented Jun 2, 2019 via email

@BaraMGB
Copy link
Contributor

BaraMGB commented Jun 2, 2019

The code looks fine except the small issues. About the button: perhaps someone else could test it. I find it misleading, because if I set 1 bar, I expect that the TCO also shifts by 1 bar.

@Spekular
Copy link
Member Author

Spekular commented Jun 2, 2019

Ah, so you want the adaptive snap to be disabled completely. I thought you wanted it to be permanently on.

src/core/Track.cpp Outdated Show resolved Hide resolved
src/core/Track.cpp Outdated Show resolved Hide resolved
src/gui/editors/SongEditor.cpp Outdated Show resolved Hide resolved
src/gui/editors/SongEditor.cpp Outdated Show resolved Hide resolved
src/gui/editors/SongEditor.cpp Outdated Show resolved Hide resolved
src/gui/editors/SongEditor.cpp Outdated Show resolved Hide resolved
src/gui/editors/SongEditor.cpp Outdated Show resolved Hide resolved
src/gui/editors/SongEditor.cpp Outdated Show resolved Hide resolved
@BaraMGB
Copy link
Contributor

BaraMGB commented Jun 3, 2019

Please, can somebody look at the proportional snapping? @zonkmachine @tresf @PhysSong @JohannesLorenz

src/gui/editors/SongEditor.cpp Outdated Show resolved Hide resolved
src/core/Track.cpp Outdated Show resolved Hide resolved
src/core/Track.cpp Outdated Show resolved Hide resolved
@PhysSong PhysSong added needs testing This pull request needs more testing and removed needs code review A functional code review is currently required for this PR labels Jul 14, 2019
@PhysSong
Copy link
Member

I will merge this in a few days if there are no objections or new reviews.

@LostRobotMusic
Copy link
Contributor

LostRobotMusic commented Jul 20, 2019

@Spekular Hey, thank you for the PR! I've been wanting this feature for a long time now.
I tested it out and I have not really noticed any problems. I tested it with messed up time signatures, groups of TCOs, individual TCOs, everything. It all works perfectly, except for one small thing which might not actually be a bug.

If your TCO's edge does not match up with a snap line, you can use Shift+drag to make it match up. But, if you use Shift+drag to do that, and let go of the Shift without letting go of the mouse, it will revert to the normal behavior, reverting the changes made by holding Shift even after those changes are displayed on the screen. So if you want to match something up with a snap line and then resize it, you have to Shift+drag it, let go of your mouse button and Shift key, and then resize it normally. That may or may not be intentional, I'm not sure, but it may be confusing to people. It's a very minor thing though, and people may prefer either behavior. It probably isn't a problem to be honest, since you can achieve the same effect by just holding down Shift the entire time when doing that, I just thought I'd point it out just in case.

Otherwise, everything seems to be working 100% perfectly. 👍

@Spekular
Copy link
Member Author

Spekular commented Jul 20, 2019 via email

@PhysSong
Copy link
Member

@douglasdgi Are you fine with the new shift behavior?

@LostRobotMusic
Copy link
Contributor

@PhysSong Yes, it's just fine. I approve.

@Spekular
Copy link
Member Author

I will merge this in a few days

@PhysSong now?

@PhysSong
Copy link
Member

Okay. Could you write a suitable commit message for this PR? The default message in Squash and merge is too messy.

@Spekular
Copy link
Member Author

A full length one, or the short title? A long one could probably be copied from the first post in this thread. As for a short one, I have trouble with those but here's some attempts

  • If we should mention the core change in MidiTime: "Replace MidiTime's 'toNearestTact' with 'quantize', allow different snap sizes in song editor"
  • Otherwise: "Add snap size selection and new snap behaviors to song editor"

@PhysSong
Copy link
Member

Thanks. Do you think the summary in the first post is okay for long one?

@Spekular
Copy link
Member Author

Yes, I do. Just change "will close" to "closes" and remove everything after that line and it seems good to me.

@PhysSong PhysSong merged commit 1c715bc into LMMS:master Jul 27, 2019
@Spekular
Copy link
Member Author

🎉

@musikBear
Copy link

Will there be binaries for tests?

@Spekular
Copy link
Member Author

Spekular commented Aug 2, 2019

Master branch should get nightly builds at some point in the future, considering that I haven't planned on building binaries for this.

@zonkmachine zonkmachine removed the needs testing This pull request needs more testing label Sep 8, 2019
@Spekular Spekular deleted the SESnap branch August 10, 2020 15:21
sdasda7777 pushed a commit to sdasda7777/lmms that referenced this pull request Jun 28, 2022
* New default behavior: Preserves offsets when moving clips, resizes in fixed increments.

* Adds shift + drag: Snaps move start position (like current behavior) or end position (new),
based on which is closest to the real position. When moving a selection,
the grabbed clip snaps into position and the rest move relative to it.

* Adds alt + drag: Allows fine adjustment of a clip's position or size,
as an alternative to ctrl + drag.

* Adds a Q dropdown in the song editor to allow finer or coarser snapping (8 bars to 1/16th bar)

* Adds a proportional snap toggle. When enabled, snapping size/Q adjusts based on zoom,
and a label appears showing the current snap size. This is disabled by default.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

Finer Scaling In The Sequencer
8 participants