mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-26 12:21:08 +01:00
Circle: switching Third Point by Dragging keeps a center placed with From Center
This commit is contained in:
1 parent
bd597c019d
commit
cecaf16bae
3 files changed
+21
-2
No files matched your search
@@ -640,7 +640,8 @@ impl Tool for CircleTool {
|
||||
if let Some(switch) = self.options.switch(key) {
|
||||
*switch = on;
|
||||
}
|
||||
if self.options.drag_third != was {
|
||||
// A circle drawn from its center has no third point, so its center stays placed.
|
||||
if self.options.drag_third != was && !self.centered {
|
||||
self.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -857,6 +857,24 @@ fn from_center_holds_for_the_circle_being_drawn() {
|
||||
assert_eq!(t.options()["fromCenter"], json!(false), "a value that is not true or false is ignored");
|
||||
}
|
||||
|
||||
/// Switching `dragThird` while a center is placed keeps the center: the circle from it is still
|
||||
/// drawn. Without From Center, the switch drops the point placed.
|
||||
#[test]
|
||||
fn switching_third_point_by_dragging_keeps_a_placed_center() {
|
||||
let (d, _) = doc_with_rect();
|
||||
let (s, p) = (Selection::default(), paint());
|
||||
let cx = ToolContext { smart_guides: false, ..cx(&d, &s, &p) };
|
||||
let mut t = from_center();
|
||||
click(&mut t, &cx, (100.0, 100.0));
|
||||
t.set_option("dragThird", &json!(false));
|
||||
assert!(t.ends_on_escape(&cx), "the center is still placed");
|
||||
assert_eq!(click(&mut t, &cx, (100.0, 150.0)), centered((100.0, 100.0), (100.0, 150.0)));
|
||||
let mut t = CircleTool::default();
|
||||
click(&mut t, &cx, (100.0, 100.0));
|
||||
t.set_option("dragThird", &json!(false));
|
||||
assert!(!t.ends_on_escape(&cx), "the first point is dropped");
|
||||
}
|
||||
|
||||
/// `tool.setOption` takes `fromCenter` as true or false, and no other key.
|
||||
#[test]
|
||||
fn the_options_are_checked() {
|
||||
|
||||
+1
-1
@@ -7396,7 +7396,7 @@ default except `fromCenter`, which is off, and `color` is `"blue"`:
|
||||
the opposite corner, with the diagonal as its radius. Shift keeps the second point at 45° steps from the center, and
|
||||
Alt rounds the diameter (twice the distance from the center) to the nearest ruler tick. The tool shows one radius, to
|
||||
the pointer. A second click on the center places nothing. The setting in force when the first point is placed applies
|
||||
to that circle, and `dragThird` does not apply to it.
|
||||
to that circle, and `dragThird` does not apply to it: switching `dragThird` keeps a placed center.
|
||||
|
||||
`tool.setOption` returns an error and changes none of the options when a value is not one the option takes
|
||||
(`` `radii` must be true or false ``, `` `color` must be one of red, blue, magenta, green, black, gray ``) or the key is
|
||||
|
||||
Reference in new issue
Block a user