[Lazarus] Hi-DPI tweak of components
Vojtěch Čihák
vojtech.cihak at atlas.cz
Sat Jun 17 18:46:16 CEST 2023
TLabeledEdit is probably not a good example since both TEdit and TLabel are native widgets (maybe they scale by widgetset) and there is some Spacing between them hardcoded to 3px. I cannot see any scaling related code in this simple component.
Anyway, I know what's going on:
procedure TWinControl.AutoAdjustLayout(AMode: TLayoutAdjustmentPolicy;
const AFromPPI, AToPPI, AOldFormWidth, ANewFormWidth: Integer);
var
i: Integer;
begin
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.AutoAdjustLayout'){$ENDIF};
try
for i:=0 to ControlCount-1 do
Controls[i].AutoAdjustLayout(AMode, AFromPPI, AToPPI, AOldFormWidth, ANewFormWidth);
inherited;
finally
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.AutoAdjustLayout'){$ENDIF};
end;
end;
i.e. form loops all its children and scale them. But when component is dropped on the form, scaling is done before Parent is set. Therefore only main component's DoAutoAdjustLayout is called, subcomponent is ommited.
I noticed that it is opposite when loading from *.lfm. There scaling done after the Parent is set, so both component's and subcomponent's DoAutoAdjustLayout is called.
It's fine since there are simplier ways how to do initial scaling (when component is created and put on the form).
Thanks, I only needed to understand better how it works.
______________________________________________________________
> Od: "Ondrej Pokorny" <lazarus at kluug.net>
> Komu: "Lazarus mailing list" <lazarus at lists.lazarus-ide.org>
> Datum: 15.06.2023 08:35
> Předmět: Re: [Lazarus] Hi-DPI tweak of components
>
On 14.06.2023 21:52, Vojtěch Čihák via lazarus wrote:This is strange. All controls should be adjusted regardless of the Owner. TLabeledEdit works fine (edit that has an attached label).
Ondrej
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20230617/5a288183/attachment.htm>
More information about the lazarus
mailing list