fix(editor): match ts boolean toolbar actions
This commit is contained in:
parent
fa2f200d9a
commit
1ee91daf0f
|
|
@ -72,18 +72,10 @@ const SQUARES_INTERSECT: &[&str] = &[
|
|||
"M8 10a2 2 0 0 1 2-2h5a1 1 0 0 1 1 1v5a2 2 0 0 1-2 2H9a1 1 0 0 1-1-1z",
|
||||
"M8 2h2",
|
||||
];
|
||||
const SQUARES_EXCLUDE: &[&str] = &[
|
||||
"M4 2h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2z",
|
||||
"M10 8h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H10a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2z",
|
||||
"M9.5 9.5l5 5",
|
||||
"M14.5 9.5l-5 5",
|
||||
];
|
||||
|
||||
const BOOLEAN_ITEMS: &[(BooleanOp, &[&str])] = &[
|
||||
(BooleanOp::Union, SQUARES_UNITE),
|
||||
(BooleanOp::Subtract, SQUARES_SUBTRACT),
|
||||
(BooleanOp::Intersect, SQUARES_INTERSECT),
|
||||
(BooleanOp::Exclude, SQUARES_EXCLUDE),
|
||||
];
|
||||
|
||||
/// Group divider indices (after these positions, insert a `GROUP_GAP`
|
||||
|
|
@ -370,6 +362,8 @@ mod tests {
|
|||
let doc = doc_with_two_rects_selected();
|
||||
let tb = AlignToolbar::for_canvas_region(canvas(), &doc).unwrap();
|
||||
assert!(tb.rect.size.x > ALIGN_TOOLBAR_WIDTH);
|
||||
let expected_width = ALIGN_TOOLBAR_WIDTH + GROUP_GAP + BUTTON_SIZE * 3.0 + INNER_GAP * 2.0;
|
||||
assert_eq!(tb.rect.size.x, expected_width);
|
||||
let first_boolean = tb.button_rect(ITEMS.len());
|
||||
let center = Point2D::new(
|
||||
first_boolean.origin.x + first_boolean.size.x / 2.0,
|
||||
|
|
@ -380,14 +374,14 @@ mod tests {
|
|||
Some(AlignToolbarHit::Boolean(BooleanOp::Union))
|
||||
);
|
||||
assert_eq!(tb.hit_test(center), None);
|
||||
let exclude = tb.button_rect(ITEMS.len() + BOOLEAN_ITEMS.len() - 1);
|
||||
let intersect = tb.button_rect(ITEMS.len() + 2);
|
||||
let center = Point2D::new(
|
||||
exclude.origin.x + exclude.size.x / 2.0,
|
||||
exclude.origin.y + exclude.size.y / 2.0,
|
||||
intersect.origin.x + intersect.size.x / 2.0,
|
||||
intersect.origin.y + intersect.size.y / 2.0,
|
||||
);
|
||||
assert_eq!(
|
||||
tb.hit_test_action(center),
|
||||
Some(AlignToolbarHit::Boolean(BooleanOp::Exclude))
|
||||
Some(AlignToolbarHit::Boolean(BooleanOp::Intersect))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue