Repository navigation
fix(toast): draw the toast as widgets so the message can be selected - #1262
Conversation
The toast was painted straight onto the layer with painter.galley(), and
painted text is never hit-tested: nothing in it could be selected or
copied. A toast often carries the path or the command the user needs
elsewhere ("Exported frame to /path"), and egui's selectable labels —
on by default — only work on real widgets.
Draw it as an Area with a Frame and a wrapping Label instead, keeping the
same centring, 6 px radius, 20/11 padding and the 0.25 s fade-out.
The new tests assert the toast has an area of its own, that the pointer
reaches the text (egui offers the text cursor over it), and that a long
message still wraps within the canvas. All three fail when the toast is
painted, which is what they are for.
|
Landed on main in #1426 — thank you, @switch87, for the contribution! If you haven't already, come join us on Discord: https://discord.gg/artcraft |
…rea doesn't fade in (storytold#1262), storytold#1282's test runs on Windows
…cks meant for what is under it (a dialog's button)
|
A follow-up on this one, @switch87: it landed in batch 32a (#1426), and #1431 had to take it out again. Drawn as an egui Selectable toast text is still wanted. Ways that would keep clicks going through: make only the text interactive while the pointer is over it, add a small copy button, or keep the last messages in a place they can be copied from. A new PR along one of those lines is welcome. Generated by Claude Code |
|
Follow-up: this was taken back out of main in #1431 ("the toast as a widget takes the clicks meant for what is under it (a dialog's button)"). If you'd like to rework it so the toast doesn't intercept clicks, a new PR is very welcome — thanks again! |
…rea doesn't fade in (storytold#1262), storytold#1282's test runs on Windows Ember: the toast hunk (an egui Area) is left out; Ember keeps its painted toast. (cherry picked from commit 2e877ad)
The problem
The toast at the bottom centre of the canvas was drawn straight onto its layer:
Painted text is never hit-tested, so nothing in a toast could be selected or copied. That is a real loss for exactly the messages this surface exists for — they are paths and commands:
toast_errorcarriesDownloadOutcome::Failed(e)andThe SAM 3 download failed: {e}toast_forexists for "messages that say where to look or what to do next"Event::Toast/s.toast(…)reach here as text likeExported frame to /path/to/frame.pngegui's
Labelis selectable by default (style.interaction.selectable_labels), and LightCraft never turns that off — but it only helps widgets. The other craft apps already render their toasts as labels; this one was the odd one out.The change
Same toast, drawn as an
Area+Frame+ wrappingLabel. Everything visual is carried over unchanged: the centring oncanvas.bottom() - 60, the 6 px radius, the 40/22 px of padding (nowMargin::symmetric(20, 11)), the wrap width ofcanvas.width() - 80clamped to 200–720, and the 0.25 s fade, which now tints the frame and the text instead of the galley.Tests
crates/ui-egui/src/tests_toast.rs:the_toast_is_a_widget_the_pointer_reaches— the toast has anarea_rectof its own, and moving the pointer onto it makes egui offer the text cursor. Painted text is never hit-tested, so this fails against the old code.the_toast_still_wraps_a_long_message_inside_the_canvas— a long message still wraps inside the canvas.Both fail on the pre-change code (
the toast is laid out as a widget, not paint) and pass after.About the local
cargo xtask ciI could not get a fully green
cargo xtask cihere, and neither of the two blockers is in this change — both reproduce on a pristinemainwith everything stashed:crates/pipeline/src/spots.rs:250withclippy::chunks_exact_to_as_chunks, a lint that only exists from Rust 1.98. With that one lint allowed,-p lightcraft-ui-egui --all-targets -- -D warningsis clean.tests_model_setup, allinvalid parameters for 'denoise.models.install': this build cannot run denoise models— the denoise models are unavailable in this environment.The gates that do run are green:
fmt,parity(every cited id and path exists),layers(31 crates, no violations) andassets(42 files, all attributed).