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

Font sizes in custom UI elements may need to scale to DPI settings #81

Closed
philipbelesky opened this issue Aug 18, 2021 · 5 comments
Closed
Labels
enhancement New feature or request

Comments

@philipbelesky
Copy link
Collaborator

Not sure if this is a weird artefact of my setup, but the font size values (and perhaps UI dimensions more broadly) seem much overscaled in Grasshopper. This creates some clipping in the dropdown menus. This is at 200% UI scale on a 5120x2880px screen.

Screen Shot 2021-08-18 at 5 58 29 pm

@philipbelesky philipbelesky added the enhancement New feature or request label Aug 18, 2021
@mariuszhermansdorfer
Copy link
Owner

Thanks for reporting. I never work with UI scaling, so never caught this bug. Definitely an oversight in the UI code.

@mariuszhermansdorfer
Copy link
Owner

@philipbelesky, I tried replicating this on my end - but it's a pain to work with 200% UI scale on a low-res monitor.
I'm not sure what the issue is? Are all the UI elements way too big and all text should be made smaller, or is the font size ok, and the UI containers are too small?

If it's the former - try changing these values:

string name = "Arial";
int num = 8;
TextFont = new Font(new FontFamily(name), num, FontStyle.Regular);
string name2 = "Arial";
int num2 = 8;
DropdownFont = new Font(new FontFamily(name2), num2, FontStyle.Italic);
string name3 = "Arial";
int num3 = 8;
MenuHeaderFont = new Font(new FontFamily(name3), num3, FontStyle.Bold);
string name4 = "Arial";
int num4 = 10;
SliderValueTagFont = new Font(new FontFamily(name4), num4, FontStyle.Italic);
int width = 8;
int height = 8;
RadioButtonSize = new Size(width, height);
RadioButtonPadding = 4;
int width2 = 8;
int height2 = 8;
CheckBoxSize = new Size(width2, height2);
CheckBoxPadding = 4;

For the latter - it seems, that there is a hard-coded 20 px height value for each menu item:

System.Drawing.Drawing2D.GraphicsPath rect = RoundedRect(new Rectangle((int)base.Transform.X, (int)base.Transform.Y + 20 * num, (int)base.Width, 20), 2);
graphics.FillPath(white, rect);
graphics.DrawString(_dropMenu.Items[i].content, WidgetServer.Instance.DropdownFont, white2, base.Transform.X + base.Width / 2f, (int)base.Transform.Y + 20 * num + 5, stringFormat);

Quick search for '20' shows that it is referenced multiple times in the code. Replacing it with a proper variable relating to Windows' UI scaling factor could fix it.

@mariuszhermansdorfer
Copy link
Owner

@philipbelesky, did you make any progress on this issue?

@philipbelesky
Copy link
Collaborator Author

Hadn't had a go at it yet. I'd be happy to, but it might be more useful for you to look at given your work with Custom UI things?

@mariuszhermansdorfer
Copy link
Owner

I can help with the code, but don't have a high-res monitor around to test it on.

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

No branches or pull requests

2 participants