[Lazarus] Hi-DPI tweak of components
Ondrej Pokorny
lazarus at kluug.net
Thu Jun 8 11:49:42 CEST 2023
On 08.06.2023 11:34, Giuliano Colla wrote:
> Il 08/06/2023 08:08, Ondrej Pokorny via lazarus ha scritto:
>
>> Check TCustomColorBox how it handles FColorRectWidth as an example
>> (it uses a default value and if the user overwrites it, it gets
>> scaled in DoAutoAdjustLayout().
>
> I believe that scaling for different DPI has been implemented with a
> shortsighted approach.
> IMHO the general approach should have been (or should be if someone is
> willing to face it) to have *two* parameters for width and height: a
> pixel value and a linear value (in mm, inches, whatever).
> If the designer or user sets the pixel value, this value is taken and
> used, but the linear value is calculated.
> If the designer or user sets the linear value, the pixel value is
> calculated using the current DPI, and is used to paint the control.
> A new DPI will cause all pixel values to be updated from the linear
> values.
> I don't know if there are some cases where the pixel value should be
> retained even for a significant DPI change. A FixedPixel boolean or a
> zero value in the linear value might override the resizing.
>
> I understand that this would require a revision of all TControl
> descendants, by exposing the new properties, but I believe it to be
> the only way to make the DPI handling user friendly and mainly
> transparent to the users.
LOL. What advantage do you get from this approach? You get rid of
rounding errors when scaling occurs? So you get rid of problems within
1px margins? And what do you have to pay for it? To double-up all
current pixel (integer precision) values with other double-precision
units and do conversions between them all the time? No way it is a
better approach.
Well, you can create your own component library from scratch that will
use double-precision units for positions&sizes (Delphi FireMonkey is one
example). VCL and LCL have been designed when scaling was not an issue,
so you have to live with the preconditions.
Ondrej
More information about the lazarus
mailing list