Recent

Author Topic: VirtualtreeView and DPI related issues  (Read 5493 times)

ChristianH

  • New Member
  • *
  • Posts: 46
VirtualtreeView and DPI related issues
« on: January 31, 2019, 02:45:19 pm »
Hi,

i'm not sure if this suits this section, but is there an existing solution to use VirtualtreeView on Hi DPI properly? I mean the plus and minus mode-bitmaps are extremely small when it comes to DPI rates higher than 128.

I solved this issue by adding the following code:

Code: Pascal  [Select][+][-]
  1. procedure DoScaleBitmap(const ABitmap: TBitmap);
  2. var Dst: TBitmap;
  3. begin
  4.  Dst := TBitmap.Create;
  5.  Dst.SetSize(MulDiv(ABitmap.Width,Screen.PixelsPerInch, 96),
  6.   MulDiv(ABitmap.Height, Screen.PixelsPerInch, 96));
  7.  Dst.Canvas.Clear;
  8.  Dst.Canvas.StretchDraw(Rect(0,0,Dst.Width,Dst.Height), ABitmap);
  9.  ABitmap.Assign(Dst);
  10.  Dst.free;
  11. end;  
  12. ...
  13. procedure TBaseVirtualTree.PrepareBitmaps(NeedButtons, NeedLines: Boolean);
  14. ...
  15.   {$ifdef ThemeSupport}
  16.   //  if Theme <> 0 then
  17.   //    CloseThemeData(Theme);
  18.   {$endif}
  19.  
  20. // last code before end of PrepareBitmaps function in
  21.   DoScaleBitmap(FHotPlusBM);
  22.   DoScaleBitmap(FPlusBM);
  23.   DoScaleBitmap(FHotMinusBM);
  24.   DoScaleBitmap(FMinusBM);
  25. end;
  26.  

This does work like it should, but there should be a different way to solve, or?

Christian
« Last Edit: January 31, 2019, 02:58:05 pm by ChristianH »

wp

  • Hero Member
  • *****
  • Posts: 11857
Re: VirtualtreeView and DPI related issues
« Reply #1 on: January 31, 2019, 03:09:37 pm »
Use the one which comes with Lazarus-trunk from palette LazControls (the package is renamed to laz.virtualtreeview.package now, all unit names have a prefix "laz." and the registered components are called TLaz* - this allows for an additional VTV installation within the same IDE) or the "lazarus-v5" branch from https://github.com/blikblum/VirtualTreeView-Lazarus/tree/lazarus-v5 - I think this is also available through Online-Package-Manager. These versions use the Lazarus HiDPI-aware multi-resolution image list.

ChristianH

  • New Member
  • *
  • Posts: 46
Re: VirtualtreeView and DPI related issues
« Reply #2 on: January 31, 2019, 09:16:07 pm »
Thanks, this one works really good and seem to be more clean than my proof of concept build.

Christian

apeoperaio

  • Sr. Member
  • ****
  • Posts: 272
Re: VirtualtreeView and DPI related issues
« Reply #3 on: March 20, 2019, 01:26:57 pm »
I am starting using VTV on cocoa. But I have some issues, mostly related to how text is drawn on virtualstringtree.
The text is not drawn well as for the other components but it is quite blurry.
See attached image of the online package manager.
Anyone faced the same problem?
Is it related to HiDPI? Is VTV HiDPI aware?
Andrea

I am using Lazarus trunk, 2.1.0 r60622M FPC 3.0.4 x86_64-darwin-cocoa (alpha)

balazsszekely

  • Guest
Re: VirtualtreeView and DPI related issues
« Reply #4 on: March 20, 2019, 02:47:43 pm »
I am starting using VTV on cocoa. But I have some issues, mostly related to how text is drawn on virtualstringtree.
The text is not drawn well as for the other components but it is quite blurry.
See attached image of the online package manager.
Anyone faced the same problem?
Is it related to HiDPI? Is VTV HiDPI aware?
Andrea

I am using Lazarus trunk, 2.1.0 r60622M FPC 3.0.4 x86_64-darwin-cocoa (alpha)

Please try the following:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin  
  3.    VST.AutoAdjustLayout(lapAutoAdjustForDPI, 96, Screen.PixelsPerInch, 0, 0);
  4.   //...
  5. end;

apeoperaio

  • Sr. Member
  • ****
  • Posts: 272
Re: VirtualtreeView and DPI related issues
« Reply #5 on: March 20, 2019, 02:56:49 pm »
Thanks for your answer.
I added the suggested line but it has no effect.
Here a screenshot of a sample project using VTV on Cocoa.

balazsszekely

  • Guest
Re: VirtualtreeView and DPI related issues
« Reply #6 on: March 20, 2019, 03:01:00 pm »
@apeoperaio
Is Project Options -> Application -> "Use LCL scaling (Hi-DPI)" checked?

apeoperaio

  • Sr. Member
  • ****
  • Posts: 272
Re: VirtualtreeView and DPI related issues
« Reply #7 on: March 20, 2019, 03:01:52 pm »
Yes, it was checked.

balazsszekely

  • Guest
Re: VirtualtreeView and DPI related issues
« Reply #8 on: March 20, 2019, 04:19:58 pm »
Unfortunately I'm out of ideas. One last thing you can try is to change PixelsPerInch of the font, inside OnPaintText at see if it helps:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.LazVirtualStringTree1PaintText(Sender: TBaseVirtualTree;
  2.   const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
  3.   TextType: TVSTTextType);
  4. begin
  5.   TargetCanvas.Font.PixelsPerInch := Screen.PixelPerInch;
  6. end;


wp

  • Hero Member
  • *****
  • Posts: 11857
Re: VirtualtreeView and DPI related issues
« Reply #9 on: March 20, 2019, 04:37:35 pm »
Is this a cocoa-only issue? Because on Windows VTV scales nicely in high-dpi mode.

balazsszekely

  • Guest
Re: VirtualtreeView and DPI related issues
« Reply #10 on: March 20, 2019, 06:19:41 pm »
Is this a cocoa-only issue? Because on Windows VTV scales nicely in high-dpi mode.
Yes. It works for me too on windows and linux.

apeoperaio

  • Sr. Member
  • ****
  • Posts: 272
Re: VirtualtreeView and DPI related issues
« Reply #11 on: March 20, 2019, 08:24:23 pm »
I tested:
Code: Pascal  [Select][+][-]
  1. TargetCanvas.Font.PixelsPerInch := Screen.PixelPerInch;
but nothing change.
And yes it is a cocoa issue, I tested on windows and Linux it works properly.

apeoperaio

  • Sr. Member
  • ****
  • Posts: 272
Re: VirtualtreeView and DPI related issues
« Reply #12 on: March 21, 2019, 11:36:39 am »
Anyone else noticed the same issues using VTV and Cocoa?

BeniBela

  • Hero Member
  • *****
  • Posts: 905
    • homepage
Re: VirtualtreeView and DPI related issues
« Reply #13 on: March 21, 2019, 11:58:52 am »
Is there a way to test dpi issues with a VM without having a high dpi monitor?

wp

  • Hero Member
  • *****
  • Posts: 11857
Re: VirtualtreeView and DPI related issues
« Reply #14 on: March 21, 2019, 12:53:33 pm »
I don't have a high-dpi monitor either, i.e. it runs at 96 dpi, but I have a VM with Windows set up to 144 dpi (150%). When a form or control scales correctly with dpi then its size in this VM should be 1.5 times that outside the VM.

 

TinyPortal © 2005-2018