klonyyy / MCUViewer

Real-time embedded variable & trace viewer
GNU General Public License v3.0
802 stars 80 forks source link

Added scaling for hidpi displays #42

Closed Copper280z closed 7 months ago

Copper280z commented 7 months ago

Hi, wonderful project!

This PR adds scaling for hidpi displays. It gets the scale factor once early in the main function, then applies the scale to all text and objects that have a statically defined size. I think I found every definition, but it's certainly possible I missed some.

I believe this means that for systems that have different scale factors per display the scale factor will be set on startup and not updated if the window is moved between displays. This might be a useful future addition.

I've verified this behaves well on Ubuntu 22.04 at both 3840x2160 scaled at 175% and 1920x1080 scaled at 100%, but am unable to test on Windows. Attached is a screenshot showing before/after (before is an earlier version, in addition to not having this scaling modification).

image

klonyyy commented 7 months ago

Hello @Copper280z,

Thanks for your input! I currently don't have a proper setup to test it out, I can only confirm it builds fine on Windows. Would it be possible for you to merge these changes into devel instead of main?

Copper280z commented 7 months ago

I think that should do it, I added scaling to the new gui items.

Additionally, I noticed a segfault on application close and traced it to the dlclose call in the UnixSoLoader destructor, handle needs a null check here so I added it.

klonyyy commented 7 months ago

Thanks! I tested it on Windows and it works :) I'll merge the PR now, and if any problems arise on Windows for hidpi users we'll work them out then.