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

Scroll at a consistent speed. #6637

Merged
merged 1 commit into from Apr 29, 2022
Merged

Conversation

mesilliac
Copy link
Contributor

Fixes #3607

The controller_base::handle_scroll function is being called inside a loop that doesn't seem to be limited by anything. So if processing is fast, it loops and scrolls a lot, and if processing is slow, it doesn't.

I made it scroll by an amount proportional to the amount of time between calls to handle_scroll.

@stevecotton stevecotton added Bug Issues involving unexpected behavior. Backport A reminder of a bugfix that was added to master that needs to be duplicated on the stable branch. UI User interface issues, including both back-end and front-end issues. labels Apr 25, 2022
@stevecotton
Copy link
Contributor

Looks and feels good to me. I'm not sure if the acceleration is necessary (as it seems to be full speed within about 3 frames), but the speed limit definitely is.

@CelticMinstrel
Copy link
Member

I vote we merge this immediately.

@mesilliac
Copy link
Contributor Author

I'm not sure if the acceleration is necessary

The slow start is mostly so all the variables (scrolling_, last_scroll_tick_ etc) get set correctly. It was simpler than writing extra handling code. The small bit of acceleration is a nice side-benefit.

@Vultraz
Copy link
Member

Vultraz commented Apr 27, 2022

I like this. :) Is it possible we could use a proper Bezier function to calculate position? ease-in-out maybe?

@mesilliac
Copy link
Contributor Author

Yeah, applying an ease-in to scroll_amount should work. It would just need another variable to track the time since scroll start and apply the easing function based on that. I wasn't sure if there was an existing easing function / system to use so i didn't try anything fancy.

@Vultraz
Copy link
Member

Vultraz commented Apr 27, 2022

What about replacing last_scroll_tick_ with a scroll_start_ var. We don't (oddly enough) have any built-in easing functions (they should be added), so for now a helper function in the file would do.

@mesilliac
Copy link
Contributor Author

Nah it still needs it for the time delta. As there's no endpoint for mouse/keyboard scrolling, only a direction, the speed can be eased but not the absolute position.

In any case it's pushing the scope for this a bit, as it's basically just a bugfix as is.

@Vultraz Vultraz merged commit 195cc4c into wesnoth:master Apr 29, 2022
@mesilliac mesilliac deleted the smooth_scroll_speed branch April 30, 2022 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backport A reminder of a bugfix that was added to master that needs to be duplicated on the stable branch. Bug Issues involving unexpected behavior. UI User interface issues, including both back-end and front-end issues.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scrolling in game / editor is erratic to the point of being annoying
4 participants