[Lazarus] Layout auto-adjustment for smartphones / dpi awareness

Felipe Monteiro de Carvalho felipemonteiro.carvalho at gmail.com
Tue Dec 6 17:25:42 CET 2011


Hello,

I'd like to ask for some input about the best strategy to implement
support in the LCL for auto-adjustment of the layout for smartphones
and dpi awareness (this one affects Windows too, but would be optional
there).

When it comes to simple desktop dpi awareness all controls should be
repositioned and scaled by a factor which can be determined by
something like: NewX := OldX * (RunTimeDPI / DesignTimeDPI) and the
same for the Y axis and font sizes and default fonts.

So if you design your software in DPI 96 with a Button.Left=100 then
you run it in a platform with DPI 144 it will increase the value of
Left for the button, and also of width, height, top, etc. Controls
which use the property Align would very likely be skipped in this.

But then for smartphones another kind of auto-adjustment can be
applied: The scaling on Android for the X axis is different then for
the Y axis. While the Y axis and font sizes should be scaled via a
normal DPI adjustment, the X axis should be scaled in order to fit all
controls inside the available screen width so that the user does not
require horizontal scrolling to use the form, only vertical scrolling
is allowed.

So the questions which come with this are:

1> Obviously designed sizes should all be auto-scaled, but what about
sizes added at run-time? Auto-scale them too? To me so far I'd say no.
Which adds a complication for developers, but it can also be annoying
if the LCL tries to do "too much".

2> How to call the new property to control the layout adjustment
policy? My initial idea was DPIAwareness, but this is not only for
DPI, but also changes according to the platform policies ... so maybe
LayoutAdjustmentPolicy ?

3> Allow the user to bypass the Android policy of never scrolling
forms horizontally? My initial answer would be no, because I have
never seen an application which does that. People looking for that
would need to place a TCDScrollableControl or similar inside the form.

-- 
Felipe Monteiro de Carvalho




More information about the Lazarus mailing list