edit
edit copied to clipboard
Consolidate button/checkbox creation
Before this PR, there are three possibilities for a Button's checked state:
- Nothing, e.g.
[Yes] - Unchecked, e.g.
| About |This only leaves space for a checkmark. - Checked, e.g.
|🗹 Word Wrap...
The button only shows the provided checked state, without internal toggle logic.
Separately, there is a checkbox() function that partly overlaps with the button logic:
- Unchecked, e.g.
[☐ Match Case]This is not available viaButtonStyle - Checked, e.g.
[🗹 Match Case]
The checkbox automatically toggles the given bool parameter if activated.
Note that the 'unchecked' variants of the button and checkbox are different, meaning there are four total states/styles.
Change
I have consolidated (to some degree) the checkmark-drawing code.
- I changed the
checked: Option<bool>to anenum Checkmarkthat now consolidates the four possible states/styles. (Absent, AlignOnly, Checked, Unchecked) - The
checkbox()now uses thebutton()+ButtonStyle, where previously most of its code was duplicated. - The
Word Wraptoggle is now a proper checkbox. Edit: I had also converted the OVR (overtype) indicator, but reverted it on request.
Sorry if this should have been multiple PRs, the chronological order of the changes was quite chaotic. If any of this is controversial, e.g. the OVR checkbox, I can revert it.