esternin / eXtrema

https://www.physics.brocku.ca/Labs/extrema/
GNU General Public License v2.0
6 stars 1 forks source link

bitmapButton size too small on high-dpi displays #34

Closed esternin closed 3 years ago

esternin commented 3 years ago

wxBitmapButton class description has no ::Scale control, and the bitmap is not stretched to occupy the full button size, in fact the button is sized to fit the bitmap. The SetUserScale() des not seem to affect the bitmap button scaling. There are 39 such buttons.

$ grep -R new\ wxBitmapButton src | wc -l
39

On high-dpi displays this makes such bitmap-based buttons tiny and unreadable. We could double up all button bitmap imagess, but then they would be too large on normal-dpi displays.

A suggestion here is to convert it to wxImage with wxBitmap::ConvertToImage(), then use wxImage::Scale(), then convert the scaled wxImage back to wxBitmap.

Is there a better way, like converting to a scalable type (like SVG?) of button images, if such buttons are supported in wx?

vadz commented 3 years ago

There is wxSVG but it's pretty old and I don't know how well does it work nowadays.

The solution used so far is to have 2 copies of the bitmaps, the normal and x2 one, and select the right one during run-time. Better/more automatic support for this is only available in wx 3.1...

esternin commented 3 years ago

The code at the end of this uses nanoSVG, and seems reasonable.

But if a better way is coming in 3.1, we should just wait.

esternin commented 3 years ago

Under wx 3.1.5 (on a Chromebook, so Debian/Wayland) the buttons do scale up in size nicely, but the bitmaps within them remain small, the white margin gets bigger. Not sure if this means 3.1.5 is not going to resolve this, or some change in the code is required.

vadz commented 3 years ago

To look nicely, some changes in the code are definitely required as we need to have bigger images and not just upscaled (i.e. blurry) versions of the current ones.

esternin commented 3 years ago

Is there a way to switch to the currently installed theme's images for the "standard" buttons, like "Save", "Exit", "Help", etc. There are only a couple of buttons that are not "standard", and we could then create just those.

If we need to fix to a specific set of images, which of the GPL icons sets could we steal from and re-distribute within eXtrema without violating license?

vadz commented 3 years ago

There used to be some standard Gnome icons, but I don't think GTK-3 still provides them otherwise than via CSS, and while it might not be a bad idea to use it, it would be very GTK-specific and require a lot of changes.

Most "free" icon sets are compatible with GPL, so there is no need to "steal" them, you should be allowed to use them just fine. But, of course, you need to check the licence of whichever one you'd like to use...

esternin commented 3 years ago

Closing the issue.

Switching to wx 3.1.5 and tweaking ~/.config/gtk-3.0/settings.ini (adding the last line below) fixes the button-scaling problem. It was caused by Google's theme settings.

[Settings]
gtk-application-prefer-dark-theme=0
gtk-icon-sizes="panel-menu=12,11:panel=12,11:gtk-menu=12,11:gtk-large-toolbar=12,11:gtk-small-toolbar=12,11:gtk-button=12,11"