#5747·slint

Fractional border rendering

Author: EnyiumCreated Aug 2, 2024Updated Sep 29, 2026
Labelsa:runtime

This issue serves the purpose of discussing (and concluding) on whether to support synthetic borders / lines or not.

Original description:

The only method of Window that allows you to register a callback is on_close_requested(). I think adding the method on_scale_factor_changed() would make sense. The callback would need to be called when the user is dragging the window onto another monitor with a different scale factor, or if the system settings change. Maybe you'd also or instead want to provide a solution for .slint code.

Usefulness: When drawing a diagram with a grid implemented via Rectangles, you may want to ensure a minimum grid border width of 1 phx as well as round the width to whole phx, so that (I hope) no effect of the kind "2 phx border, 1 phx border, 2 phx border, 1 phx border" comes to be. With the pixel snapping approach Slint seems to use for everything but Path (as opposed to pixel-fractional rendering like SVG in the browser), these larger–smaller effects should be reserved for larger objects (like the areas between grid lines) where it's not that noticeable if they differ in size by 1 phx.

(I'm currently not sure if a clever calculation in .slint code involving a user-defined length, 1px and 1phx would already allow you to ensure the above border constraints, since Slint updates the scale factor when dragging the window to another monitor as the rendering shows.)

If Slint could render everything pixel-fraction-accurate like SVG in the browser and like it's already doing with Path, diagrams may look even better, though. Is that realistic for future Slint?