edit icon indicating copy to clipboard operation
edit copied to clipboard

Consolidate button/checkbox creation

Open ivanovkirilg opened this issue 6 months ago • 0 comments

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 via ButtonStyle
  • 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.

  1. I changed the checked: Option<bool> to an enum Checkmark that now consolidates the four possible states/styles. (Absent, AlignOnly, Checked, Unchecked)
  2. The checkbox() now uses the button() + ButtonStyle, where previously most of its code was duplicated.
  3. The Word Wrap toggle is now a proper checkbox. Edit: I had also converted the OVR (overtype) indicator, but reverted it on request.

Various checkboxes

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.

ivanovkirilg avatar May 31 '25 15:05 ivanovkirilg