[Sketcher] Tweaking the Constraint label

About the development of the Part Design module/workbench. PLEASE DO NOT POST HELP REQUESTS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
chennes
Veteran
Posts: 3878
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

[Sketcher] Tweaking the Constraint label

Post by chennes »

In the "Solver messages" area of the tasks panel in Sketcher, there are two labels:
Constraint and Solver Label.png
Constraint and Solver Label.png (19.87 KiB) Viewed 5165 times
Those labels change color depending on whether the constraints are valid, complete, etc., and whether the solver found a solution or not. That color change is done by hardcoded CSS style tags in the QLabels. Of course, this drives stylesheet authors crazy, because the label's color can't be changed. I've partially solved this (see the note below for details). But there is one element that I haven't solved, and need opinions on: the embedded URL.

You can't style an "<a>" element in a QLabel via the Qt theme stylesheets, only via css embedded/hardcoded directly in the QLabel. But of course we really need to be able to style via a stylesheet! For standalone URLs we've historically solved this by specifically creating a "UrlLabel" subclass. You then put an "<a>" element, and ONLY that element, in that label. It gets styled independently, and viola! A "styled" URL. The problem is that Sketcher's URL is not standalone: in some cases, like the one shown above, the link is embedded within the sentence (in this case "2 degrees" is a link).

I have three proposed solutions to this (and am open to whatever others you can come up with!):
  1. Separate the single label into three: "preURlLabel", "urlLabel", "postUrlLabel" and put them in a horizontal layout. As long as no wrapping occurs, this will look the same as it does now. It's a bit awkward in the code, but not totally horrifying.
  2. Separate the single label into two, and change the link to always be at the end. So, e.g. "Under-constrained sketch with 2 degrees of freedom. (Click to select)". Possibly place this label underneath the other, so wrapping is not an issue. Code is nicer-looking than option 1, but changes what the UI looks like.
  3. Switch from a link/url to a QPushButton, either to the right or below the text. Label that button "Select DOFS", "Select redundants", etc. as needed. Cleaner code (no extra style handling needed, buttons look like buttons), but much bigger UI change.
I'd like to hear your feedback on these options.

Note: Details of the solution for the QLabel coloring... I think I've managed to solve this problem by creating a new QLabel subclass called "StatefulLabel" that can have arbitrary style information set for arbitrary "states" (which are just strings, so things like "overconstrained" or "partially redundant constraints", etc.). Stylesheets can set up a style for a given state, and if it's not set it falls back to the default (e.g. red for overconstrained, green for fully constrained, etc.). There's a bit more to it, but that's the gist. So, that's one solved problem.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
chrisb
Veteran
Posts: 53920
Joined: Tue Mar 17, 2015 9:14 am

Re: [Sketcher] Tweaking the Constraint label

Post by chrisb »

I frequently work on a smaller screen where every millimeter counts. I make the panel as small as possible so that I still can see as much as possible from the constraints and the elements list. I am not against a UI change as long as it doesn't cost any space.
Option 2 costs more space and wraps the line where the current solution doesn't.
Option 3 would always cost an additional line.
So I would prefer the most space saving solution, which is option 1.
I would even like to see the "Solved in x sec" message to be suppressed, be it as an option or permanently.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
chennes
Veteran
Posts: 3878
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: [Sketcher] Tweaking the Constraint label

Post by chennes »

chrisb wrote: Sun Oct 03, 2021 9:43 pm I frequently work on a smaller screen where every millimeter counts.
In your work does the text usually wrap to two lines, or do you size it so it fits on one?
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
chrisb
Veteran
Posts: 53920
Joined: Tue Mar 17, 2015 9:14 am

Re: [Sketcher] Tweaking the Constraint label

Post by chrisb »

chennes wrote: Sun Oct 03, 2021 10:20 pm In your work does the text usually wrap to two lines, or do you size it so it fits on one?
I usually have it in two lines.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
chennes
Veteran
Posts: 3878
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: [Sketcher] Tweaking the Constraint label

Post by chennes »

If space is a concern, maybe we should shorten the text to something like just
  • N degrees of freedom (select)
  • Fully constrained
  • Redundant constraints (select)
  • (etc.)
The solver time label could be hidden unless the solver failed (then the message is "Unsolved", which you probably want to know!).
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
chrisb
Veteran
Posts: 53920
Joined: Tue Mar 17, 2015 9:14 am

Re: [Sketcher] Tweaking the Constraint label

Post by chrisb »

I'm all for shorter messages.
"Unsolved" could even better be shown as solver message, because now the corresponding solver message is rather arbitrary: on "unsolved" the same state can be shown with different solver messages, depending on the last non-unsolved message.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
jais
Posts: 6
Joined: Wed Aug 18, 2021 7:53 am

Re: [Sketcher] Tweaking the Constraint label

Post by jais »

As a new user, I assumed that clicking the "2 degrees" link would open a wiki page in my browser that would explain degrees of freedom or constraints in general, which I think I already understand, so I never clicked on it.

Like chrisb I also sometimes work on small screen and prefer the sidebar to be as small as possible, so option 4 sounds ideal to me if (select) can be a small button.
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: [Sketcher] Tweaking the Constraint label

Post by abdullah »

jais wrote: Mon Oct 04, 2021 4:02 am As a new user, I assumed that clicking the "2 degrees" link would open a wiki page in my browser that would explain degrees of freedom or constraints in general, which I think I already understand, so I never clicked on it.
By all means, click on it on an unconstrained sketch. It will show you what you could constraint further to remove those DoFs.
User avatar
chennes
Veteran
Posts: 3878
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: [Sketcher] Tweaking the Constraint label

Post by chennes »

For more compact phrasing (and the link and text separated into two components), how about:
Proposed wording.png
Proposed wording.png (49.07 KiB) Viewed 4660 times
(The colors here are only approximate, I am not going to change the default colors, just make them settable via the stylesheet and user preferences).
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
chrisb
Veteran
Posts: 53920
Joined: Tue Mar 17, 2015 9:14 am

Re: [Sketcher] Tweaking the Constraint label

Post by chrisb »

chennes wrote: Mon Oct 04, 2021 6:54 pm Proposed wording.png
Looks good to me. How about making "Unsolved" a solver message? Abdullah may know why it is not.
Abdullah wrote:ping
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply