Skip to content

feat: toggle text outline in inverted color with Alt - #574

Merged
RobertMueller2 merged 3 commits into
Satty-org:mainfrom
rokokol:feat/text-outline
Jul 4, 2026
Merged

feat: toggle text outline in inverted color with Alt#574
RobertMueller2 merged 3 commits into
Satty-org:mainfrom
rokokol:feat/text-outline

Conversation

@rokokol

@rokokol rokokol commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Closes #573

What

Adds an optional outline to the text tool. While editing text, tapping Alt toggles an outline drawn in the inverted text color (255 - channel per RGB, alpha preserved). The outline is preserved when the text is committed.

Adds an optional outline to the text tool. While editing text, tapping Alt toggles an outline drawn in the inverted text color (255 - channel per RGB, alpha preserved). The outline is preserved when the text is committed.

2026-07-04.13-33-24.mp4

Why

Text can blend into the background and become unreadable. An inverted-color outline always contrasts with the fill, keeping annotations legible over any background, with no new color setting to configure.

How

  • Color::inverted() in style.rs — per-channel RGB inversion, alpha kept.
  • In Text::draw, when the outline is enabled each line is stroked with the inverted color (line width ×2) underneath the fill, so the visible border wraps the glyphs. The outline flag lives on Text, so it is carried into the committed drawable via clone_box.
  • Toggling uses a genuine Alt tap rather than the raw keydown: handle_key_event marks a tap candidate on Alt_L/Alt_R and clears it on any other key; handle_key_release_event flips outline only if the candidate survived. This prevents Alt-based combos (Ctrl+Alt+Arrow to move text) and key auto-repeat from flipping the state.

Docs

  • README.md: added the shortcut under the Text tool section with a NEXTRELEASE marker.

Testing

  • make fix (cargo fmt + clippy -D warnings) — clean.
  • cargo build — clean.
  • tested on NixOS with Hyprland.

Notes

No new dependencies

Tapping Alt while editing text toggles an outline drawn in the inverted
text color (255 - channel per RGB, alpha kept). The outline is rendered
by stroking each line with the inverted color underneath the fill, so it
forms a border around the glyphs, and it is preserved when the text is
committed.

To avoid interfering with Alt-based combos (e.g. Ctrl+Alt+Arrow to move
the text) and key auto-repeat, the toggle only fires on a genuine Alt
tap: press then release with no other key pressed in between.
@RobertMueller2

Copy link
Copy Markdown
Member

Looks good, nice addition.

We may revamp the way tool styles, secondary modes, tool specific actions etc are accessed in the future, ideally even allow configuring keybindings for this. Will definitely be after #555. In order to allow that, it'd be nice if you could flag the Alt toggle in the README as Experimental. Thanks :)

I also have a bonus idea, feel free to reject it, though, we can always do that later. 😉 How about there are different outline modes:

enum OutlineMode {
  #[default]
  None,
  Inverted,
  Contrast
}

and hitting alt cycles through them?

Inverted is what you just implemented, Contrast picks black or white based on Luminance?

rokokol added 2 commits July 4, 2026 14:19
The way tool styles, secondary modes and tool-specific actions are
accessed may be revamped (ideally with configurable keybindings) after
issue Satty-org#555, so mark this binding as experimental for now.
Replace the boolean outline flag with an OutlineMode enum that the Alt
tap cycles through: None -> Inverted -> Contrast -> None. Inverted keeps
the previous behaviour (per-channel 255 - value); Contrast picks black or
white based on the text color's perceived luminance (YIQ).

Co-authored idea by the maintainer.
@rokokol

rokokol commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

Done! My goal was to keep everything as simple and concise as possible, without any extra interface buttons or unnecessary settings, so that the app would remain minimalistic and straightforward :Ъ

@RobertMueller2

Copy link
Copy Markdown
Member

lgtm, thanks for the PR :)

@RobertMueller2
RobertMueller2 merged commit 5e4ff7f into Satty-org:main Jul 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Text tool: option to draw text with a contrasting outline

2 participants