Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

High DPI for 4k displays? #103

Open
dibok opened this issue Jan 20, 2025 · 10 comments
Open

High DPI for 4k displays? #103

dibok opened this issue Jan 20, 2025 · 10 comments

Comments

@dibok
Copy link

dibok commented Jan 20, 2025

Hi,
Does MSEGUI have support for high DPI? I have 4k monitor with Linux Mint, resolution 3840x2160 and scale 200% and MSEIDE and default demo app are just tiny :( . Is there any workaround?
Regards

@fredvs
Copy link
Contributor

fredvs commented Jan 20, 2025

Is there any workaround?

I use a "auto sizer" depending of the font.height selected in the config for ideU and StrumPract.
https://github.com/fredvs/ideU/releases
https://github.com/fredvs/strumpract/releases

resize.mp4

Maybe something similar could be used to ajust for DPI?

@fredvs
Copy link
Contributor

fredvs commented Jan 21, 2025

fpGUI has some DPI feature.

Here one:

  Description:
      This unit has helper function to help you create high dpi applications,
      scalling the UI as needed.

https://github.com/graemeg/fpGUI/blob/develop/src/gui/fpg_toolbox.pas

Maybe take some inspiration?

@fredvs
Copy link
Contributor

fredvs commented Jan 21, 2025

msegui-font has xscale property.

Image

@dibok
Copy link
Author

dibok commented Jan 21, 2025

fpGUI has some DPI feature.

Here one:

  Description:
      This unit has helper function to help you create high dpi applications,
      scalling the UI as needed.

https://github.com/graemeg/fpGUI/blob/develop/src/gui/fpg_toolbox.pas

Maybe take some inspiration?

Well, I'm not familiar on such low level layer but I guess that some kind of X11 event is getting what is a user scale (beside resolution). I don't expect to be easy in implementation. On my day work I'm working on Delphi 11 and even on such newest version, DPI is a nightmare on windows. Lazarus on Linux Mint is working just like that with my 4k monitor and scale settings, I even don't need to change anything in project settings

@fredvs
Copy link
Contributor

fredvs commented Jan 21, 2025

Did you try a fpgui app, is it ok using the DPI fpc_toolbox (I think it is also gdi32-Windows compatibe)?
Sorry but I dont have such a 4k monitor to test.

@dibok
Copy link
Author

dibok commented Jan 21, 2025

Well. Just downloaded fpGUI source from git (develop branch) and tried few examples. Not everything is good (edits are still to small for me), but looks promising. Don't know if some adjust is needed for example autosize for labels etc. The last screenshot is MSEGUI demo compared to properly scaled Rhythmbox and calculator. MainMenu in IDE is barely clickable :(
Image
Image
Image
Image
Image

@fredvs
Copy link
Contributor

fredvs commented Jan 21, 2025

May I ask you to try with ideU?
If the font is not ok, try after setting a bigger "font height" and disabled "Suggested font height" in menu "Settings/Extra settings" ?
https://github.com/fredvs/ideU/releases/

Image

@dibok
Copy link
Author

dibok commented Jan 21, 2025

Well. With this IDE it is much much better! I even didn't have to change anything. Bellow my whole desktop with this ide compared to Rhythmbox and to normal MSEIDE

Image

Image

@fredvs
Copy link
Contributor

fredvs commented Jan 21, 2025

I am happy that you like it!

For auto-sizing, it is very simple.
First I decided for a "initial resolution", it is 1024x800 and default font.height = 12 for ideU and did place all the widgets as wanted.
Then in each form.oncreate, a array of all size of widgets:

setlength(boundchildsp, childrencount);
    for i1 := 0 to childrencount - 1 do
    begin
      boundchildsp[i1].left   := children[i1].left;
      boundchildsp[i1].top    := children[i1].top;
      boundchildsp[i1].Width  := children[i1].Width;
      boundchildsp[i1].Height := children[i1].Height;
      boundchildsp[i1].Name   := children[i1].Name;
    end;

And then a resize method:

procedure resize(screenheight: integer);
var
  i1, i2: integer;
  ratio: double;
begin
  ratio        := screenheight / 800;
  bounds_cxmax := 0;
  bounds_cxmin := 0;
  bounds_cymax := 0;
  bounds_cymin := 0;
  bounds_cxmax := roundmath(442 * ratio);
  bounds_cxmin := bounds_cxmax;
  bounds_cymax := roundmath(128 * ratio);
  bounds_cymin := bounds_cymax;
  font.Height  := round(12*ratio);
 
 for i1 := 0 to childrencount - 1 do
      for i2 := 0 to length(boundchildsp) - 1 do
        if children[i1].Name = boundchildsp[i2].Name then
        begin
          children[i1].left   := roundmath(boundchildsp[i2].left * ratio);
          children[i1].top    := roundmath(boundchildsp[i2].top * ratio);
          children[i1].Width  := roundmath(boundchildsp[i2].Width * ratio);
          children[i1].Height := roundmath(boundchildsp[i2].Height * ratio);
        end;

end;

To get the resolution of screen:

var
  rect1: rectty;
begin
  rect1 := application.screenrect(window);
  Caption := 'Resolution: ' + IntToStr(rect1.cx) + 'x' +
    IntToStr(rect1.cy) ;

@fredvs
Copy link
Contributor

fredvs commented Jan 21, 2025

 boundchild = record
    left: integer;
    top: integer;
    Width: integer;
    Height: integer;
    Name: string;
  end;

var
  boundchildscl: array of boundchild;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants