mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-26 20:46:22 +01:00
Merge pull request #9379 from dotCooCoo/fix/followup-8706
Tools: a shared option set through another tool during a held press is kept
This commit is contained in:
2 files changed
+28
-1
No files matched your search
@@ -267,6 +267,25 @@ fn an_option_set_on_a_lending_tool_during_a_dropped_press_is_kept() {
|
||||
assert_eq!(s.prefs.corner_radius, 30.0, "the preference keeps it");
|
||||
}
|
||||
|
||||
/// A shared Liquify brush size set through another Liquify tool during a held press survives the
|
||||
/// dropped press, also when the set value equals the size the press's drag has made current.
|
||||
#[test]
|
||||
fn a_shared_option_set_through_another_tool_during_a_dropped_press_is_kept() {
|
||||
let mut s = session();
|
||||
select(&mut s, "warp");
|
||||
let v = ViewInfo { smart_guides: false, ..Default::default() };
|
||||
s.pointer(&PointerEvent::new(PointerKind::Down, 100.0, 100.0), v).unwrap();
|
||||
s.pointer(&PointerEvent::new(PointerKind::Drag, 200.0, 180.0), v).unwrap();
|
||||
let before = s.tool_options()["width"].as_f64().unwrap();
|
||||
// The press's own change to the shared size, not stored.
|
||||
s.tool.set_option("width", &json!(before + 40.0));
|
||||
let current = s.tool_options()["width"].clone();
|
||||
s.set_tool_option_cmd(&json!({"tool": "pucker", "key": "width", "value": before + 40.0})).unwrap();
|
||||
s.drop_tool_press(v).unwrap();
|
||||
assert_eq!(s.tool_options()["width"], current, "the tool keeps the size set through the other tool");
|
||||
assert_eq!(s.prefs.tool_settings["liquify"]["width"], current, "and stores it");
|
||||
}
|
||||
|
||||
/// A dropped Pen press drops only the anchor it was placing: the path being drawn goes on with
|
||||
/// the next click.
|
||||
#[test]
|
||||
|
||||
@@ -1582,7 +1582,15 @@ impl Session {
|
||||
let set = other.id();
|
||||
Self::restore_stores(&self.prefs, self.tool.as_mut(), |store| settings::stores(set).any(|(s, _)| s == store));
|
||||
}
|
||||
self.keep_press_set(before_press, |k| sets_pressed && values.contains_key(k), sets_pressed);
|
||||
// Another tool's set also names the keys of the stores it shares with the pressed tool.
|
||||
let shared: Vec<&str> = match (self.pressed_tool().map(|t| t.id()), id) {
|
||||
(Some(pressed), Some(set)) if pressed != set => settings::stores(pressed)
|
||||
.filter(|(store, _)| settings::stores(set).any(|(s, _)| s == *store))
|
||||
.flat_map(|(_, keys)| keys.iter().copied())
|
||||
.collect(),
|
||||
_ => Vec::new(),
|
||||
};
|
||||
self.keep_press_set(before_press, |k| values.contains_key(k) && (sets_pressed || shared.contains(&k)), sets_pressed);
|
||||
// The Eyedropper waiting for a Cmd-drag it lent a selection tool to is armed as the active one.
|
||||
if (active || lender) && values.contains_key("stop") {
|
||||
let eyedropper = id.unwrap_or(self.tool.id()) == "eyedropper";
|
||||
|
||||
Reference in new issue
Block a user