Status & Roadmap
Authors & License
Funding U++
Search on this site

SourceForge.net Logo

SourceForge.net Logo

GitHub Logo

Discord Logo

Reacting to actual resolution, UHD support

While all widgets coordinates are always in pixels, applications need to react actual settings of target GUI to scale things accordingly.


In U++, the basic scaling factor is always determined by standard font size, which is read from host platform (scaling factor can also be adjusted by application, but that is less relevant here).


All layouts are designed in some artificial defined, relatively small, 'basic font' font size, then scaled based on ratios of standard system font to this basic font. Also, it is possible to scale individual dimensions by Ctrl::[Horz|Vert]LayoutZoom or Zx/Zy/Zsz functions.


This, when used appropriately, works well for host GUI font size between 12-22. When GUI font gets bigger, there starts to be a problem with Images (e.g. button icons) being too small. This is typical for UHD display.


To resolve this problem, upscaled Images need to provided in this case. This is not a problem for Images that are created by code (because they can easily incorporate scaling factor into the algorithm), but would be a problem for images from .iml resources.


To this means, Image has Resolution info. This can have 3 values - Standard, UHD, None. This info can be adjusted in Icon designed (right click Image name and choose Image..., or double-click Image name)



U++ can be switched to "UHD" mode. In this mode, if icon is retrieved from .iml and it is in Standard resolution, it is upscaled 2x (relatively smart algorithm is used so that it looks quite fine on UHD display). Correspondingly, in standard mode, UHD resolution icons are downscaled. Icons with "None" resolution are left intact.


It is also possible and preferable to have both standard and UHD variants in the same .iml file. If this the case, UHD variant name is changed to name__UHD in C++ code (to avoid name clash). Also, in UHD mode, UHD variant is used to actually overwrite standard resolution variant.


UHD is normally activated when standard icon height is greater than 22.


In addition to Zx/Zy/Zsz functions, U++ also provides set of DPI functions which simply double arguments when UHD mode is active - this is sometimes better approach for scaling things that are related to images.


Last but not least, some host platforms (Windows) need to be specifically informed that the application is able to handle UHD, otherwise they enter into mode when application is rendered in standard resolution and upscaled by windows (which looks quite terrible). Normally, U++ is in this "HiDPI" mode by default. You can revert to ugly upscaling mode by calling Ctrl::SetUHDEnabled(false) in INITIBLOCK.

Do you want to contribute?