Recent

Author Topic: Size of controls automatically change between Linux & Windows  (Read 450 times)

Nevada Smith

  • New Member
  • *
  • Posts: 20
I am developing a cross-platform application (Windows and Linux) and I have cloned the same repo form GIT on respective OS platforms. However, when I switch between Windows and Linux, I see that the location (top, left) and size (height, width) of several controls change - automatically. The change is small though, usually <10 pts.

GIT diff:-

   object cbSelect: TCheckBox
     Left = 8
-    Height = 21
+    Height = 19
     Top = 11
-    Width = 21
+    Width = 20
     TabOrder = 0
   end
   object dtpSet: TDateTimePicker
-    Left = 320
-    Height = 22
+    Left = 318
+    Height = 23
     Top = 10
-    Width = 63
+    Width = 65
     


This creates unnecessary versions for lfm files in GIT.

Can this somehow be avoided? Or is this something every cross-platformer is living with?

y.ivanov

  • Sr. Member
  • ****
  • Posts: 438
Re: Size of controls automatically change between Linux & Windows
« Reply #1 on: July 01, 2022, 03:08:29 pm »
*snip*
Can this somehow be avoided? Or is this something every cross-platformer is living with?

Being a one which works at different screens at home and at work (120ppi vs 96ppi) this constantly drives me nuts.
I must actually keep in mind what forms I have really changed to commit only them afterwards. Sometimes before the commit, I have to cherry-pick only the lines that were not Top/Left/Width/Height/DesignTimePPI changes not to spoil the source into the repository. The DesignTimePPI is the real spoiler, because if you let it slip through, then (according to Scaled property and DPI awareness) some of your controls got shrunk (those not taught with anchors, e.g. buttons) and then I must go back in file history to correct it.

I'll be also very glad if somebody shares some practical recipes how to minimize the effect.
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

MarkMLl

  • Hero Member
  • *****
  • Posts: 4738
Re: Size of controls automatically change between Linux & Windows
« Reply #2 on: July 01, 2022, 03:54:14 pm »
However, when I switch between Windows and Linux,

Stop right there. That is entirely down to the widget set(s) being used, nothing at all to do with Linux per se.

I agree it's irritating, but it applies equally if trying to develop for- e.g.- gtk2 vs Qt, and it applies equally if developing for e.g. gtk2 on an OS such as Solaris.

It also depends on the dpi setting- not known during development- and on the hints passed from the window manager to the widget set (the can of worms you get with Qt on KDE hosted by Linux doesn't quite taste the same as the one that comes free with Qt on the RPi's homegrown window manager).

Need I point out that that your OP is somewhat sort of detail?

In practice, the best I've found is to have OS- and widget-set-specific code that tweaks placement etc. at runtime. I don't know whether it would be possible to improve on this by characterising the various platforms and then leaving final positioning to something like DeltaBlue constraint-solving.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

y.ivanov

  • Sr. Member
  • ****
  • Posts: 438
Re: Size of controls automatically change between Linux & Windows
« Reply #3 on: July 01, 2022, 04:32:21 pm »
However, when I switch between Windows and Linux,

Stop right there. That is entirely down to the widget set(s) being used, nothing at all to do with Linux per se.
*snip*
My personal troubles are caused by difference in the screen PPI in design time, not by the difference in the widget set (both are Windows PC's).
It is expected to have deviations when running your program compiled for different platforms,  and it must be taken into consideration during development.
But every time I open a *.pas file to edit the source at home, the respective *.lfm got open too and immediately changes because of the different PPI. When I save, both files got modified. I haven't found a way to save only the *.pas file.

I thought previously, wouldn't it be convenient if there (in IDE) was some type of locking for the form editor to prevent that automatic modification and/or modifications by accident - if the hand twitches and moves something?
 

"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

Nevada Smith

  • New Member
  • *
  • Posts: 20
Re: Size of controls automatically change between Linux & Windows
« Reply #4 on: July 01, 2022, 04:40:00 pm »
In my (specific) case, it not due to DPI. It is 96 for both OSes. It is the widget-set: I use Windows(Win32), XFCE (GTK) and LxQT (QT).

Even if I do the placement of widgets, sizing etc at runtime, it will not save us from the hassle of checking in the lfm every time I switch environments (even when no changes were made to the form).

MarkMLl

  • Hero Member
  • *****
  • Posts: 4738
Re: Size of controls automatically change between Linux & Windows
« Reply #5 on: July 01, 2022, 05:06:39 pm »
I thought previously, wouldn't it be convenient if there (in IDE) was some type of locking for the form editor to prevent that automatic modification and/or modifications by accident - if the hand twitches and moves something?

I agree, and I think it's related to my comments elsewhere about being able to lock down parts of a project against unauthorised etc. change.

What happens if you simply make the .lfm read-only to your normal login ID? Alternatively store it in a local repository and periodically force your local copy back to a known state.

Having said that, is the .lfm actually being changed, or simply touched (same binary content, but a timestamp update)?

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

VTwin

  • Hero Member
  • *****
  • Posts: 1112
  • Former Turbo Pascal 3 user
Re: Size of controls automatically change between Linux & Windows
« Reply #6 on: July 01, 2022, 06:03:03 pm »
Just noting the same, or similar, problem on macOS and Windows. I develop mainly on macOS, and use the Anchor Editor for all controls. I use a standard spacing, say 12 pixels, between controls. This works fine when compiling the project for Linux and Windows.

However, if I modify a Form while in Windows, the spacings change to, say, 10. I usually go back and revert them back to 12 on the Mac before final compiles. It would be nice to be able to lock the design time.
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 10.13.6: Lazarus 2.2.0 (64 bit Cocoa)
macOS 12.0.1: Lazarus 2.2.0 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.0 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.0 (64 bit on VBox)

MarkMLl

  • Hero Member
  • *****
  • Posts: 4738
Re: Size of controls automatically change between Linux & Windows
« Reply #7 on: July 01, 2022, 06:25:22 pm »
However, if I modify a Form while in Windows, the spacings change to, say, 10. I usually go back and revert them back to 12 on the Mac before final compiles. It would be nice to be able to lock the design time.

This has, of course, been a longstanding problem when working with multiple versions (as distinct from variants) of Lazarus: it was possible to tune the .lfm so that it didn't contain any references to non-portable properties (e.g. when SynEdit or TNotebook was reorganised) but as soon as you as much looked at it on a too-recent version...

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

MarkMLl

  • Hero Member
  • *****
  • Posts: 4738
Re: Size of controls automatically change between Linux & Windows
« Reply #8 on: July 02, 2022, 02:46:55 pm »
Thinking about the collected comments, about multiple people mentioning DPI (which on at least some desktops is controlled as part of the font setup) and

However, if I modify a Form while in Windows, the spacings change to, say, 10. I usually go back and revert them back to 12 on the Mac before final compiles.

I wonder whether this problem is caused by some assumption being made by the widgetset relating to default font sizes, i.e. Windows favours 10 but the Mac favours 12 and different Linux widget sets have their own preference (or have an uninitialised value)?

If so it might be fixable...

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

y.ivanov

  • Sr. Member
  • ****
  • Posts: 438
Re: Size of controls automatically change between Linux & Windows
« Reply #9 on: July 02, 2022, 06:14:40 pm »
*snip*
I wonder whether this problem is caused by some assumption being made by the widgetset relating to default font sizes, i.e. Windows favours 10 but the Mac favours 12 and different Linux widget sets have their own preference (or have an uninitialised value)?

If so it might be fixable...

MarkMLl

Actually - yes.

Since the display ppi is a coefficient into the conversion: font pt -> screen pixels  (you know, 72pt=1 inch).

My case is the following: In the office I have dual monitor setup, both monitors are relatively large in size with resolution 1920x1080. The Windows font size in settings is 100% which result in 96ppi.

But I have a laptop with 14.1 inch display with a resolution of 3200x1800. In the default setup, the font size is 250% (in order to read anything on screen!). There is virtually no Windows program that looks normally in that PPI (216), except the explorer and a few Windows config dialogs (added recently, older also looks as miniatures). Firefox looks good, but the web browsers have different rendering and tend to show only icons recently.

In order to work normally I've reduced my resolution from 3200x1800 to 1600x900 (1/4). Even then the 100% fonts (96ppi) are not comfortable for me to read, and I switched to 125% (120ppi).

That way I have 96 PPI at the office and 120 PPI at home and the above mentioned troubles.



"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

 

TinyPortal © 2005-2018