Live Paint: the Bucket's swatch preview and highlight go when the pointer leaves the canvas

This commit is contained in:
dotCooCoo
2026-11-13 17:24:40 -08:00
parent f74fe81292
commit 270e58a461
2 changed files with 21 additions and 0 deletions
+6
View File
@@ -456,6 +456,12 @@ impl Tool for LivePaintBucketTool {
if self.fill_drag.take().is_some() { vec![Action::Commit] } else { vec![] }
}
/// The pointer hovers nothing for the tool: its highlight and its swatch preview go.
fn hover_ended(&mut self, _cx: &ToolContext) {
self.hover = LpHover::None;
self.at = None;
}
fn overlays(&self, cx: &ToolContext) -> Vec<Overlay> {
let mut out = lp_overlays(&self.hover, &self.cache, self.color, self.width as f32, (self.width * LP_BUCKET_EDGE_FRACTION) as f32);
// No chips during a fill drag, or while Alt makes the tool sample with the eyedropper.
+15
View File
@@ -1108,6 +1108,21 @@ fn bucket_swatch_preview_follows_the_release_point() {
assert_eq!(chip_x(&t), Some(75.0));
}
/// When the pointer leaves the canvas, the Live Paint Bucket's swatch preview and highlight go.
#[test]
fn bucket_hover_ended_drops_the_swatch_preview_and_highlight() {
let (d, ..) = live_group_doc();
let s = Selection::default();
let p = paint();
let cx = cx(&d, &s, &p);
let mut t = LivePaintBucketTool::default();
t.pointer(&cx, &ev(PointerKind::Move, 75.0, 25.0));
let ov = t.overlays(&cx);
assert!(ov.iter().any(|o| matches!(o, Overlay::Swatch { .. })) && ov.iter().any(|o| matches!(o, Overlay::Path { .. })), "{ov:?}");
t.hover_ended(&cx);
assert!(t.overlays(&cx).is_empty());
}
#[test]
fn bucket_options_choose_what_a_click_paints() {
let (d, gid, ..) = live_group_doc();