Recent

Author Topic: High DPI and TFrame  (Read 646 times)

JohnQMetro

  • Newbie
  • Posts: 4
High DPI and TFrame
« on: November 24, 2019, 10:48:49 pm »
I've just started using a High DPI screen with Lazarus for the first time. I've read the Docs on high DPI, but I am still having a problem: Any TFrames in the app that are included at design-time get scaled at least twice, messing up things. Does anyone know how to get around this?

lainz

  • Hero Member
  • *****
  • Posts: 3307
    • Lainz
Re: High DPI and TFrame
« Reply #1 on: November 24, 2019, 11:04:00 pm »
Maybe it's scaled once when created, and once when added to the form... just a guess

I don't know the method names, but there must exist a method to do the opposite, like scaling it back. Try at the component you're adding with the IDE autocomplete typing 'scale' or 'dpi' to find a method you can use.

wp

  • Hero Member
  • *****
  • Posts: 6471
Re: High DPI and TFrame
« Reply #2 on: November 25, 2019, 12:03:28 am »
I cannot reproduce this. See attached demo. Its main form contains a design-time added frame as well as a frame added at runtime. Both scale correctly in Win10/96ppi (64bit) and Win7/144ppi (32 bit). (Laz 2.0.6/fpc 3.0.4, 32 bit)

What is your Lazarus/FPC version? OS/Widgetset?
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

JohnQMetro

  • Newbie
  • Posts: 4
Re: High DPI and TFrame
« Reply #3 on: November 25, 2019, 01:17:43 am »
I've attached a cropped screenshot. The widgets don't seem to be scaled twice, only the positions and frame sizes. I'm running Lazarus 2.0.4 with the default LCL that comes with that version. The dev environment is Windows 7 Home Pro in a VirtualBox 6.0.14 VM under Windows 10. I've gotten a new high dpi MacBook, and since VirtualBox scaling is resource-intensive, set dpi scaling inside Windows 7 display options (to 175%). This was the result for my app when I opened it in Lazarus. (DPI scaling was not on previously, but all of the forms and frames has Scale=True).

I've found that making the scale property for the frames only false (before opening in a High DPI environment) makes the app look correct (in the main form, and when compiled), but makes the frames hard to edit. I suppose I can revert to VirtualBox scaling instead of using Windows 7 options, but this still strikes me as not working the way it is supposed to. 
« Last Edit: November 25, 2019, 01:20:06 am by JohnQMetro »

wp

  • Hero Member
  • *****
  • Posts: 6471
Re: High DPI and TFrame
« Reply #4 on: November 25, 2019, 11:29:30 pm »
Sorry, I don't understand what the screenshot is supposed to say. Please post a screenshot from the design machine (which PPI?) and a screenshot from the other machine which looks wrong as you say (which PPI?). - Do I understand correctly that this is a Mac?

Does the demo program which I posted above behave correctly for you? It does for me. I am attaching the screenshots from the development machine (96ppi) and test machine (144ppi). Since the forum software scales the images to the same width you see that everything is in proportion although, when you open the images, you see that have different sizes.

Never used VirtualBox scaling. My Win7 run @144ppi in a VM, too, I only set the font size in the Windows settings to 150%. Nothing's changed in the compatibility settings.
« Last Edit: November 25, 2019, 11:31:18 pm by wp »
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

JohnQMetro

  • Newbie
  • Posts: 4
Re: High DPI and TFrame
« Reply #5 on: November 26, 2019, 12:21:52 am »
I've added 3 screenshots. The first is my app using 100% dpi in the Windows 7 VM (with VirtualBox scaling at 150% to make things visible). You can compare it with my earlier screenshot and see the difference.

The next two are for your demo program, the first at 100% dpi and the second at 150%. So, no, your demo program does NOT scale correctly for me. The heights of the widgets are okay, but the spacing is messed up. This messing up applies to the compiled file as well.

If I compile at 100% dpi (in the Dev environment), the program is fine and scales correctly at runtime on high dpi. If I then close Lazarus, change the Windows 7 dpi to 150% or 175%, reboot, and then open the project in Lazarus again, it gets messed up (and changing the Project Options, before or afterwards, makes no difference).

Note that I previously used my VM for a non high dpi machine. It may be that the Lazarus IDE somehow records the dpi when installed, so I can perhaps check later if this has any effect.

wp

  • Hero Member
  • *****
  • Posts: 6471
Re: High DPI and TFrame
« Reply #6 on: November 26, 2019, 01:00:09 am »
OK I see the issue now. The frame was created at 96 ppt with a width of 200 pixel. At 144 ppi it becomes 300 pixels which is correct (150% of 200 pixels). But when the form into which the frame had been inserted at designtime and at 96 ppt, is loaded at 144 ppi the frame gets scaled twice, once as a frame and once as a control inserted into the frame, it is now 450 pixels wide.

Setting Scaled to true will create trouble later on. I'd recommend to insert the frame at runtime. This also avoids other issues when changes are applied to the frame later and updating the form requires to reload it.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

JohnQMetro

  • Newbie
  • Posts: 4
Re: High DPI and TFrame
« Reply #7 on: November 26, 2019, 09:26:27 pm »
Okay then, Thanks. Since this still seems like unexpected behavior to me, I'm wondering if I should report it as a bug.

wp

  • Hero Member
  • *****
  • Posts: 6471
Re: High DPI and TFrame
« Reply #8 on: November 26, 2019, 09:27:52 pm »
Yes please do so.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10