mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-14 05:24:44 +00:00
Live Paint: the Bucket's swatch preview and highlight go when the pointer leaves the canvas
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user