pianobooster / PianoBooster

A MIDI file player/game that displays the musical notes and teaches you how to play the piano.
Other
397 stars 74 forks source link

Add preferences option that adjusts size of staves/keyboard #314

Open zeocs opened 2 years ago

zeocs commented 2 years ago

Hello everyone,

while using PB to learn playing the piano and reading musical notation, I had a hard time reading the notes on my laptop screen (1920x1080), especially with some distance to my eyes (midi keyboard in between). All workarounds seemed cumbersome. I looked around and noticed issue #199 where other people mentioned this as well. I really like PB a lot, but for me personally, this made it hard to learn smoothly and focus on what's important.

Having some coding experience, I decided to make a PR that implements scaling of the staves/notes and the keyboard widget. The scaling factor can be adjusted manually via the preferences dialog within a range of 50% to 250% of the original size, while 100% (original size) is still the default. I think this way graphics can be scaled to a good size for everyone's screen and needs. The scrolling area's max width gets adjusted accordingly. I do understand the concerns mentioned in #199 about flickering/tearing on older computers if the scrolling area is too large for them. With this approach, they will get the same size as before by default, while other people with more powerful hardware and larger screens are free to use larger sizes. On my mid-range laptop, scrolling worked smoothly even beyond 250%.

I did my best to integrate this feature cleanly into the codebase and follow code style conventions. The main challenge was to propagate the scaling factor everywhere it needs to be known (in a clean way) and trigger all necessary updates when it changes. I hope this PR will be considered useful, I'm looking forward to feedback, and I'm open to make corrections if needed.

PianoBooster_scaling_demo

zeocs commented 2 years ago

Added another small commit because I realized I missed a part of the keyboard widget scaling. Anyways, it should all be there now. @Martchus Thanks!