Recent

Author Topic: Documentation for Application's Scaled property  (Read 3202 times)

jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
Documentation for Application's Scaled property
« on: June 27, 2019, 01:54:51 am »
When compiling one of my projects on an older Lazarus version (1.6 for Raspbian) I stumbled over the line

Code: Pascal  [Select][+][-]
  1. Application.Scaled := True;

in the main project file. This old Lazarus version compiles the app after commenting out this line only.

What is the function of this property? Following the source code inspector, it seems to be defined in the forms unit and to do nothing more than to read or write the private FScaled variable. Is there any documentation available? I didn't find anything (apart from this old mail: https://lists.lazarus-ide.org/pipermail/lazarus/2017-February/230964.html, but it doesn't provide satisfactory information).
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Documentation for Application's Scaled property
« Reply #1 on: June 27, 2019, 02:07:24 am »
I thought it was to ensure that your form did not shrink on high DPI monitors.

 I could be wrong; I've been wrong before :o


jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
Re: Documentation for Application's Scaled property
« Reply #2 on: June 27, 2019, 02:52:36 pm »
By inspecting the SVN archive I at least found out that this property was introduced with version 1.8 of the LCL. So I can restrict its integration to newer versions with the help of compiler condictionals.

However, I would prefer to know what I do. This property must be documented anywhere, beyond the more than sparse information to be found in the wiki.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Documentation for Application's Scaled property
« Reply #3 on: June 27, 2019, 03:57:07 pm »
I may be wrong but I kind of remember having read somewhere that Scaled is there for compatibility with the VCL; i.e. it does nothing. I was wrong; see below after "ETA"

But to make sure just try to find where, if anywhere, either the property or the field are read from/written upon.

Setters for size/position and similar methods are good candidates, as well as methods which create controls, like CreateForm(), etc.

ETA: I was wrong. doing a:
grep -Fir "application.scaled" *
in the LCL directory results in:
Code: [Select]
buttonpanel.pas:      if Application.Scaled and AParent.Scaled then
include/customform.inc:  if Application.Scaled and Scaled and (Monitor.PixelsPerInch<>PixelsPerInch) then
include/customform.inc:  if Application.Scaled and (PixelsPerInch<>Monitor.PixelsPerInch) then
include/customform.inc:      if Application.Scaled and (ParentForm<>nil) and ParentForm.Scaled
include/customform.inc:    if Application.Scaled and Scaled and (NewDpi<>PixelsPerInch) then
include/customform.inc:  if Application.Scaled and Scaled and (Monitor.PixelsPerInch<>PixelsPerInch) then
include/hintwindow.inc:  if Application.Scaled and Scaled and (Mon<>nil) and (PixelsPerInch<>Mon.PixelsPerInch) then
include/customdesigncontrol.inc:  if Application.Scaled then
include/customdesigncontrol.inc:  if Application.Scaled and Scaled then
include/customframe.inc:    if Application.Scaled and (ParentForm<>nil) and ParentForm.Scaled
which is just a minimum; there are probably more instances of use in there and in "./components/" and elsewhere.
« Last Edit: June 27, 2019, 04:18:34 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
Re: Documentation for Application's Scaled property
« Reply #4 on: June 27, 2019, 04:53:43 pm »
ETA: I was wrong. doing a:
grep -Fir "application.scaled" *
in the LCL directory results in:
Code: [Select]
buttonpanel.pas:      if Application.Scaled and AParent.Scaled then
include/customform.inc:  if Application.Scaled and Scaled and (Monitor.PixelsPerInch<>PixelsPerInch) then
include/customform.inc:  if Application.Scaled and (PixelsPerInch<>Monitor.PixelsPerInch) then
include/customform.inc:      if Application.Scaled and (ParentForm<>nil) and ParentForm.Scaled
include/customform.inc:    if Application.Scaled and Scaled and (NewDpi<>PixelsPerInch) then
include/customform.inc:  if Application.Scaled and Scaled and (Monitor.PixelsPerInch<>PixelsPerInch) then
include/hintwindow.inc:  if Application.Scaled and Scaled and (Mon<>nil) and (PixelsPerInch<>Mon.PixelsPerInch) then
include/customdesigncontrol.inc:  if Application.Scaled then
include/customdesigncontrol.inc:  if Application.Scaled and Scaled then
include/customframe.inc:    if Application.Scaled and (ParentForm<>nil) and ParentForm.Scaled
which is just a minimum; there are probably more instances of use in there and in "./components/" and elsewhere.

Thanks, I found out about the same in parallel to you. This property seems to have to do with adaptation to high-resolution (e.g. Retina) displays.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Documentation for Application's Scaled property
« Reply #5 on: June 27, 2019, 05:04:59 pm »
Thanks, I found out about the same in parallel to you. This property seems to have to do with adaptation to high-resolution (e.g. Retina) displays.

Yes, it has to do with HighDPI adaptation. But it seems to be just a hint: "hey, the programmer wants ..." and child controls ignore it or not at their will :)

My guess is that it's meant for those controls which are not automagically scaled by the OS, so they know they should do it themselves.
« Last Edit: June 27, 2019, 05:06:52 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Ondrej Pokorny

  • Full Member
  • ***
  • Posts: 220

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: Documentation for Application's Scaled property
« Reply #7 on: July 03, 2019, 12:05:29 pm »
When compiling one of my projects on an older Lazarus version (1.6 for Raspbian) I stumbled over the line

Code: Pascal  [Select][+][-]
  1. Application.Scaled := True;

in the main project file. This old Lazarus version compiles the app after commenting out this line only.

What is the function of this property?
In addition to Ondrej's post I'd like to add that "Application.Scaled := true" is added whenever the box "Use LCL scaling" of "Project options" > "Application" has been checked (which is the default in Laz 2.0+). It activates automatic scaling of controls according to screen resolution.

jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
Re: Documentation for Application's Scaled property
« Reply #8 on: July 08, 2019, 12:37:33 pm »
Thanks.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

 

TinyPortal © 2005-2018