apache / netbeans

Apache NetBeans
https://netbeans.apache.org/
Apache License 2.0
2.64k stars 845 forks source link

Clarify Indeterminate or 3-Way Checkbox (Use FlatTriStateCheckBox for Boolean3WayEditor/Boolean3Inplace) #7418

Open IanKrL opened 4 months ago

IanKrL commented 4 months ago

Description

The visual difference between a checked checkbox and one that is both checked and unchecked (such as in Properties where two objects are selected and for one object the property is true and for the other the property is false) is very small. Checked: Screenshot from 2024-05-29 07-13-45 Indeterminate (Both checked and unchecked): Screenshot from 2024-05-29 07-13-56 The only difference is a very subtle background color shift.

FlatLaf is used throughout the code, and there is a related library called Flatlaf Extras which provides a class FlatTriStageCheckBox which renders a much more visually clear 3rd stage: Screenshot from 2024-05-29 07-15-56

I suggest including Flatlaf Extras (https://mvnrepository.com/artifact/com.formdev/flatlaf-extras) as a dependency in addition to the base Flatlaf, and changing the Boolean3Inplace class (inside Boolean3WayEditor) which currently extends JCheckBox to extend FlatTriStageCheckBox instead in order to make this 3rd state much more clear.

Use case/motivation

Avoid confusion on whether a checkbox is checked or indeterminate.

Related issues

No response

Are you willing to submit a pull request?

No

mbien commented 4 months ago

where do you see 3 state check boxes in NB? The only place I remember would be some trees, where the third state indicates that some but not all of the child nodes are checked (e.g hints settings).

IanKrL commented 4 months ago

My example screenshots are from the Properties window, indicating the properties of the selection in the Projects window. As you say, the third state indicates a boolean property that is not the same for all selected nodes. In my case I'm working with a gradle project, and the selected files are gradle.properties files.

neilcsmith-net commented 4 months ago

Adding the additional library to facilitate this isn't feasible. That module shouldn't depend on FlatLaf.

However, it looks like we could try putClientProperty("JButton.selectedState", "indeterminate"); in the Boolean3WayEditor? See https://github.com/JFormDesigner/FlatLaf/blob/main/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java#L123

IanKrL commented 4 months ago

If that causes it to render with the '-' icon from FlatLaf (or otherwise clearly different from 'selected'), and the checkbox continues to function as expected when activated (indeterminate->selected->deselected->selected->etc.) then that should satisfy my request.

mbien commented 3 months ago

btw since I just worked on it I got reminded about this issue: the controls (not just check boxes) in https://github.com/apache/netbeans/pull/7512 solve the 3+ state problem differently. The text in bold and the extra tooltip indicates that the selected value is not inherited, while still showing what the value actually is. (but this doesn't mean we shouldn't allow 3-state check boxes)