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

Add Continuous Auto-Scrolling #7396

Merged
merged 26 commits into from
Aug 4, 2024

Conversation

regulus79
Copy link
Contributor

@regulus79 regulus79 commented Jul 26, 2024

Description

This pull request adds the option to have auto-scrolling continuously scroll the view to keep up with the playback.

Changes

  • New icons for Stepped/Continuous auto-scrolling
  • AutoScrollState enum changed from Enabled/Disabled to Stepped/Continuous/Disabled
  • The auto-scroll button in TimeLineWidget.cpp is changed from having 2 states (Enabled/Disabled) to having 3 states (Stepped/Continuous/Disabled)
  • In the code for auto-scrolling in both SongEditor.cpp and PianoRoll.cpp, a check is added for whether the mode is Stepped or Continuous; if it's Stepped, then is runs the old code for auto-scrolling; if it's Continuous, then it snaps the horizontal scroll to halfway behind the time line so that the line appears in the center of the view.
  • SongEditor.cpp's horizontal scrollbar's functionality was changed to make it scroll by ticks instead of bars. This required modifying TrackContentWidget.cpp to be positioned by ticks instead of bars to properly draw the grid background.
  • Additionally, due to the change in scrollbar step size, the scrolling sensitivity for the Song Editor had to be changed to a reasonable rate. In this PR, the scrolling rate behaves as normal and does not depend on the zooming. I had mentioned the possibility of adding that in the discord, but I decided to save it for another PR.

Copy link
Contributor

@Rossmaxx Rossmaxx left a comment

Choose a reason for hiding this comment

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

Minor style review, also pay attention to codefactor.

Btw you forgot classic theme.

src/gui/editors/PianoRoll.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
@regulus79
Copy link
Contributor Author

Okay, I made some icons for classic, and hopefully I've fixed all the style issues.

Copy link
Contributor

@Rossmaxx Rossmaxx left a comment

Choose a reason for hiding this comment

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

Looks good.

Copy link
Contributor

@sakertooth sakertooth left a comment

Choose a reason for hiding this comment

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

We should do testing before merge.

src/gui/editors/SongEditor.cpp Outdated Show resolved Hide resolved
src/gui/editors/PianoRoll.cpp Outdated Show resolved Hide resolved
src/gui/editors/SongEditor.cpp Outdated Show resolved Hide resolved
@michaelgregorius michaelgregorius self-requested a review July 26, 2024 15:26
Copy link
Contributor

@michaelgregorius michaelgregorius left a comment

Choose a reason for hiding this comment

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

I have found a bug that's introduced by this PR, i.e. that is not in master.

Steps to reproduce

  1. Load a song.
  2. Set the mode to "Continuous".
  3. Play the song.
  4. Quickly change to "Off" and then to "Paged".

The line of the play head line will not move with the play head anymore.

@regulus79
Copy link
Contributor Author

I think I found the problem. The return statement in the simplification of the stepped auto scrolling code exited the function too soon, which happened to skip the code for updating the play head line position. I fixed it by modifying the if statement to not require a return.

@sakertooth
Copy link
Contributor

I think I found the problem. The return statement in the simplification of the stepped auto scrolling code exited the function too soon, which happened to skip the code for updating the play head line position. I fixed it by modifying the if statement to not require a return.

Had a feeling this would break something, my bad. I got tunnel vision on that one piece of code and forgot about the surrounding function.

@sakertooth
Copy link
Contributor

I'll test then approve. 👍

@sakertooth
Copy link
Contributor

I think it might be helpful to have more descriptions for the tooltip when toggling between the modes (i.e., you can tell the user what this mode will do in particular rather than simply saying "Auto scrolling", because not all modes auto scroll).

@regulus79
Copy link
Contributor Author

I added specific tooltips for each button state: "Stepped auto scrolling", "Continuous auto scrolling", and "Auto scrolling disabled"

Copy link
Contributor

@sakertooth sakertooth left a comment

Choose a reason for hiding this comment

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

LGTM, also something minor I noticed

src/gui/editors/SongEditor.cpp Outdated Show resolved Hide resolved
@regulus79
Copy link
Contributor Author

I realized that changing the scrolling step size also broke zooming centered around the mouse position. I have now fixed that; just a simple multiplication by TimePos::ticksPerBar().

@regulus79
Copy link
Contributor Author

Just remembered that there was another bug when drawing the rubberband selection rect, where the left side would get teleported to the left as everything scrolled. Once again, a simple division by TimePos::ticksPerBar() fixed it.

@regulus79
Copy link
Contributor Author

Alright, I think those are all the necessary changes, so unless anyone spots a new issue, this should pr should be ready to merge.

@michaelgregorius michaelgregorius merged commit ce17c95 into LMMS:master Aug 4, 2024
10 checks passed
@Gabrielxd195
Copy link

I have a question about this, and it is that the continuous scrolling is more fluid and consistent in the Piano Roll than in the Song Editor, since in the latter the scrolling stops suddenly and is not constant. I show you this in the following videos:

Autoscrolling in Piano Roll

Autoscroolling.Piano.Roll.mp4

Autoscrolling in Song Editor

Autoscroolling.Editor.de.Cancion.mp4

Is this on purpose? Or is there some other way to improve this?

@regulus79
Copy link
Contributor Author

Ah, whoops, I forgot to test it with smooth scroll enabled. I should have set the scroll using m_leftRightScroll->setValue() instead of animateScroll().

For now, you can temporarily fix it by disabling smooth scroll in the settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants