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

Zoom centered on the playhead, if visible #2938

Merged
merged 4 commits into from
Nov 18, 2019

Conversation

ferdnyc
Copy link
Contributor

@ferdnyc ferdnyc commented Aug 14, 2019

Reading the git history for src/timeline/js/controllers.js, I noticed commit 492f68c which added centering around the mouse cursor for Ctrl+mousewheel zooming.

I'll be honest, I never even knew about that feature! But, inspired by it, I added logic to compute the playhead position and use that location to center the zoom, if the cursor isn't over the canvas and the playhead is currently visible on-screen. So, scale adjustments using the zoom slider / buttons will try to keep the playhead visible while zooming.

If the playhead is scrolled offscreen in either direction, the code falls back to the usual centering at the left edge of the canvas.

My editor also cleaned up a whole bunch of non-blank blank lines, sorry. Someday I'm just going to stop apologizing for that.

If the cursor is not over the canvas (Ctrl-mousewheel zooming), and the
playhead is visible, center zooming at the playhead x-position.
@ferdnyc ferdnyc added the interface GUI / user interface issues (i.e. windows, buttons, scrolling, pop-ups, etc...) label Aug 16, 2019
Reusable utility functions which encapsulate logic for determining whether a given timeline position is currently scrolled into view.
@jonoomph
Copy link
Member

Looking good! Some conflicts though...

@jonoomph
Copy link
Member

I think I resolved everything correctly

@jonoomph jonoomph merged commit b0fe642 into OpenShot:develop Nov 18, 2019
@ferdnyc ferdnyc deleted the playhead-zoom branch November 19, 2019 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interface GUI / user interface issues (i.e. windows, buttons, scrolling, pop-ups, etc...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants