Constraint icons size at Sketcher edit (PR ready)

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
Elyas
Posts: 58
Joined: Fri Sep 04, 2020 12:25 pm

Constraint icons size at Sketcher edit (PR ready)

Post by Elyas »

Hello everyone.
I'm just user at moment.
On my 180 dpi dysplay constraint icons are too small.
I look a bit source and want propose:

Now in ViewProviderSketch::renderConstrIcon
font.setPixelSize(11);
replace with something like:
font.setPixelSize( hGrp->GetInt("EditSketcherFontSize", 17) *0.7 );

It's not a code, just idea.

Separare editable properties not very needed, i thinking.
Thanks, sorry for my english.
Last edited by Elyas on Fri Dec 18, 2020 12:37 pm, edited 2 times in total.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Constraint icons size

Post by Kunda1 »

Elyas wrote: Fri Sep 04, 2020 12:46 pm It's not a code, just idea.
Can you make a before/after image showing your proposed improvement ?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
vanuan
Posts: 539
Joined: Wed Oct 24, 2018 9:49 pm

Re: Constraint icons size

Post by vanuan »

Please read this:
https://wiki.freecadweb.org/HiDPI_support

Are you saying that the contraint icon size is currently derived from the font pixel size? And your solution is to make it configurable by the user?

I would rather replace this:

Code: Select all

font.setPixelSize(11);
with this:

Code: Select all

font.setPointSize(8)
But I'm not convinced that the icon depends on the font size:

Code: Select all

    QImage icon = Gui::BitmapFactory().pixmap(type.toLatin1()).toImage();
It looks like it isn't. So you would have to specify the size:

Code: Select all

 
  qreal pRatio = devicePixelRatio();
  qreal defaultCursorSize = 64;
  qreal iconSize = defaultIconSize * pRatio;

  QImage icon = Gui::BitmapFactory().pixmapFromSvg(type.toLatin1(), QSizeF(iconSize, iconSize)).toImage();
64 pixels is a 48 pt size. So maybe like this:

Code: Select all

 
    QFont font = QApplication::font();
    font.setPointSize(48);
    QFontMetricsF qfm = QFontMetricsF(font);

    qreal iconSize = qfm.xHeight();

    QImage icon = Gui::BitmapFactory().pixmapFromSvg(type.toLatin1(), QSizeF(iconSize, iconSize)).toImage();
Maybe 48pt is too large of a size, so I would start with 24pt (32 virtual pixels, 64 device pixels at 200%) which should be equal to the cursor size.
Elyas
Posts: 58
Joined: Fri Sep 04, 2020 12:25 pm

Re: Constraint icons size

Post by Elyas »

vanuan wrote: Fri Sep 04, 2020 2:01 pm Are you saying that the contraint icon size is currently derived from the font pixel size? And your solution is to make it configurable by the user?
No. Currently contraint icon size is hardcoded by 11 pixel.
I'm not sure next: because it is on GL window it not controlled by common scale metod.

Already there is a "EditSketcherFontSize" property . It affect at displayed measure contraint but not contraint icon.
So i suggest to bind contraint icon size to "EditSketcherFontSize"
Elyas
Posts: 58
Joined: Fri Sep 04, 2020 12:25 pm

Re: Constraint icons size

Post by Elyas »

Kunda1 wrote: Fri Sep 04, 2020 1:40 pm Can you make a before/after image showing your proposed improvement ?
Some pictures to illustrate the subject.
Edit->preferences->Sketcher->Display
SketcherFontSize.png
SketcherFontSize.png (20.12 KiB) Viewed 3210 times
Default
FontSize17.png
FontSize17.png (5.56 KiB) Viewed 3210 times
Fontsize 12
FontSize12.png
FontSize12.png (4.11 KiB) Viewed 3210 times
Fontsize 17, QT_SCREEN_SCALE_FACTORS=2
FontSize17-QTSF2.png
FontSize17-QTSF2.png (3.09 KiB) Viewed 3210 times
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: Constraint icons size at Sketcher edit

Post by chrisb »

We have seen here several times requests to increase the constraint icons size. Especially users with HIDPI screens may benefit. The proposal to link it to the font size sounds reasonable to me; other options could be MarkerSize or to create a new configuration parameter.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Constraint icons size at Sketcher edit

Post by Kunda1 »

chrisb wrote: Mon Sep 07, 2020 11:39 am We have seen here several times requests to increase the constraint icons size. Especially users with HIDPI screens may benefit. The proposal to link it to the font size sounds reasonable to me; other options could be MarkerSize or to create a new configuration parameter.
+1
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Elyas
Posts: 58
Joined: Fri Sep 04, 2020 12:25 pm

Re: Constraint icons size at Sketcher edit

Post by Elyas »

I have prepared a scalable icon.
You can see they look at equal sizes with the font (35 hardware pixels)
ScalableIcons.png
ScalableIcons.png (232.64 KiB) Viewed 3010 times
Let's determine if a separate slider is needed or relate to the font size.
If we link, we set it equal or slightly less. Or a slider, but in a fraction of the font size.
User avatar
vanuan
Posts: 539
Joined: Wed Oct 24, 2018 9:49 pm

Re: Constraint icons size at Sketcher edit

Post by vanuan »

Elyas wrote: Fri Sep 18, 2020 7:19 am I have prepared a scalable icon.
You can see they look at equal sizes with the font (35 hardware pixels)
ScalableIcons.png
Let's determine if a separate slider is needed or relate to the font size.
If we link, we set it equal or slightly less. Or a slider, but in a fraction of the font size.
Do you mean the new setting with a number input to configure the constraint size?

I'd prefer a minimal amount of size related settings.

If we really need to provide user with font customization, I'd use QSS. Something like this:

Code: Select all

CustomOpenGLWidget[type="constraintIcon"] {
  font-size: 12pt;
}
I think UI styling should be provided in a single text file. So that users can change multiple sets of sizes by a single select box.
Elyas
Posts: 58
Joined: Fri Sep 04, 2020 12:25 pm

Re: Constraint icons size at Sketcher edit

Post by Elyas »

Scalable icons, the size is related to the default font:
DefaultNoto10.png
DefaultNoto10.png (133.37 KiB) Viewed 2910 times
Noto14.png
Noto14.png (148.77 KiB) Viewed 2910 times
Noto12Bold.png
Noto12Bold.png (127.51 KiB) Viewed 2910 times
Main code:

Code: Select all

void ViewProviderSketch::InitSizes()
{
    int defaultFontSize = QApplication::fontMetrics().capHeight();
    qreal ldpi = QApplication::desktop()->logicalDpiX();
    float k = 96./ldpi;
    ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View");
    float view3D_factor = 1.25;
    constraintIconSize = hGrp->GetInt("EditSketcherFontSize", defaultFontSize*view3D_factor);
    coinFontSize = constraintIconSize * k;
    return;
}
Notes:
checked when"EditSketcherFontSize" was removed from users.cfg
view3D_factor - since it is a little more difficult to read in the view3D window, you should zoom in a little.
"EditSketcherFontSize" - would mean physical pixels.
Post Reply