3.11 Device-independent pixels

All position and size specifications in RapaGUI must be in device-independent pixels. This has the advantage that they will be independent of the current monitor's DPI setting so that your application will still look correctly when run on high-DPI monitors, for example.

Consider the following declaration of a window:

 
<window width="640" height="480">
   ...
</window>

This will declare a window whose width is 640dip and whose height is 480dip. If the current monitor doesn't use DPI scaling (e.g. 96dpi on Windows, 72dpi on macOS), the device-independent pixels will be identical to physical pixels so that the window's size will be 640x480 pixels. If the monitor is configured to use DPI scaling, however, the device-independent pixels will automatically be adapted to the monitor's DPI setting. For example, on a 192dpi monitor (i.e. 200% scale on Windows) the window's physical dimensions on the screen will be 1280x960 pixels instead because RapaGUI will automatically adapt the device-independent pixels to the current monitor's DPI.

Note that it is generally a good idea to avoid hard-coding specific positions and sizes and let RapaGUI determine these automatically from your layout. This guarantees a maximum amount of compatibility between different operating systems and their specific window managers, fonts, themes, and decorations.

Also make sure to read the chapter on High-DPI support to learn about other things to consider when designing an application that should be compatible with high-DPI monitors. See High-DPI support for details.


Show TOC