mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-01 10:51:11 +01:00
Restore white artboards in Outline and the selection arrow over selected art
This commit is contained in:
1 parent
7415049173
commit
6cd4975e0c
6 files changed
+20
-16
No files matched your search
@@ -17,6 +17,8 @@ pub enum Cursor {
|
||||
GroupSelection,
|
||||
/// Alt-dragging a copy with the Selection or Direct Selection tool: a double arrowhead.
|
||||
SelectionCopy,
|
||||
/// The Selection arrow over movable artwork.
|
||||
SelectionMove,
|
||||
Move,
|
||||
Crosshair,
|
||||
ResizeH,
|
||||
|
||||
@@ -1552,7 +1552,7 @@ impl Tool for SelectionTool {
|
||||
// take the pointer too (on a thin box the centre lies within a handle's reach), and with
|
||||
// Cmd/Ctrl held the press selects the object behind instead.
|
||||
if near_selected && !m.cmd && hit_center(cx, p, cx.point_tol()).is_some() {
|
||||
return Cursor::Move;
|
||||
return Cursor::SelectionMove;
|
||||
}
|
||||
// View → Snap to Point: over an anchor a press would grab the object by, the arrow turns
|
||||
// hollow.
|
||||
@@ -1560,11 +1560,11 @@ impl Tool for SelectionTool {
|
||||
return Cursor::ArrowHollow;
|
||||
}
|
||||
if selected_source_hit(cx, p).is_some() {
|
||||
return Cursor::Move;
|
||||
return Cursor::SelectionMove;
|
||||
}
|
||||
if let Some(h) = hit_test(cx.doc, p, cx.selection_hit_options()) {
|
||||
if selected_under(cx, &h, h.top_object(cx.isolation)).is_some() || m.alt {
|
||||
return Cursor::Move;
|
||||
return Cursor::SelectionMove;
|
||||
}
|
||||
return Cursor::Arrow;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ fn a_press_on_a_selected_shaper_source_moves_it_while_a_mask_is_edited() {
|
||||
let c = ToolContext { isolation: Some(layer), ..cx(&d, &s, &p) };
|
||||
for x in [75.0, 125.0] {
|
||||
let mut t = SelectionTool::default();
|
||||
assert_eq!(t.cursor(&c, Point::new(x, 350.0), Mods::default()), Cursor::Move, "at {x}");
|
||||
assert_eq!(t.cursor(&c, Point::new(x, 350.0), Mods::default()), Cursor::SelectionMove, "at {x}");
|
||||
let down = t.pointer(&c, &ev(PointerKind::Down, x, 350.0));
|
||||
assert!(!down.iter().any(|a| matches!(a, Action::Exec(c, _) if c == "select.set")), "at {x}: {down:?}");
|
||||
let drag = t.pointer(&c, &ev(PointerKind::Drag, x + 20.0, 350.0));
|
||||
@@ -45,7 +45,7 @@ fn a_selected_shaper_source_moves_after_other_objects_and_behind_front_art() {
|
||||
s.set([rect, ids[1]]);
|
||||
let c = ToolContext { isolation: Some(layer), ..cx(&d, &s, &p) };
|
||||
let mut t = SelectionTool::default();
|
||||
assert_eq!(t.cursor(&c, Point::new(125.0, 350.0), Mods::default()), Cursor::Move);
|
||||
assert_eq!(t.cursor(&c, Point::new(125.0, 350.0), Mods::default()), Cursor::SelectionMove);
|
||||
let down = t.pointer(&c, &ev(PointerKind::Down, 125.0, 350.0));
|
||||
assert!(!down.iter().any(|a| matches!(a, Action::Exec(c, _) if c == "select.set")), "{down:?}");
|
||||
let drag = t.pointer(&c, &ev(PointerKind::Drag, 145.0, 350.0));
|
||||
@@ -55,7 +55,7 @@ fn a_selected_shaper_source_moves_after_other_objects_and_behind_front_art() {
|
||||
d.insert(Some(layer), 2, Node::path(front, square, Appearance::default_art())).unwrap();
|
||||
s.set([ids[1]]);
|
||||
let c = ToolContext { isolation: Some(layer), ..cx(&d, &s, &p) };
|
||||
assert_ne!(SelectionTool::default().cursor(&c, Point::new(125.0, 350.0), Mods::default()), Cursor::Move);
|
||||
assert_ne!(SelectionTool::default().cursor(&c, Point::new(125.0, 350.0), Mods::default()), Cursor::SelectionMove);
|
||||
let down = SelectionTool::default().pointer(&c, &ev(PointerKind::Down, 125.0, 350.0));
|
||||
assert!(down.iter().any(|a| matches!(a, Action::Exec(c, v) if c == "select.set" && v["ids"] == json!([front.0]))), "{down:?}");
|
||||
}
|
||||
@@ -1042,7 +1042,7 @@ fn hidden_box_handles_take_no_press_while_anchors_are_selected() {
|
||||
s.anchors.entry(id).or_default().insert((0, 1));
|
||||
let c = cx(&d, &s, &p);
|
||||
let mut t = SelectionTool::default();
|
||||
assert_eq!(t.cursor(&c, top_middle, Mods::default()), Cursor::Move);
|
||||
assert_eq!(t.cursor(&c, top_middle, Mods::default()), Cursor::SelectionMove);
|
||||
let down = t.pointer(&c, &ev(PointerKind::Down, 150.0, 100.0));
|
||||
assert!(!down.contains(&Action::Begin("Scale".into())), "{down:?}");
|
||||
assert!(!crate::select::bbox_handle_at(&c, top_middle));
|
||||
@@ -3006,9 +3006,9 @@ fn a_press_on_the_centre_point_moves_an_unfilled_shape() {
|
||||
let c = ToolContext { path_only: true, ..cx(&d, &s, &p) };
|
||||
let centre = Point::new(150.0, 150.0);
|
||||
let mut t = SelectionTool::default();
|
||||
assert_eq!(t.cursor(&c, centre, Mods::default()), Cursor::Move);
|
||||
assert_eq!(t.cursor(&c, centre, Mods::default()), Cursor::SelectionMove);
|
||||
// Cmd/Ctrl selects the object behind, not the centre point, so the pointer says neither.
|
||||
assert_ne!(t.cursor(&c, centre, Mods { cmd: true, ..Mods::default() }), Cursor::Move);
|
||||
assert_ne!(t.cursor(&c, centre, Mods { cmd: true, ..Mods::default() }), Cursor::SelectionMove);
|
||||
assert!(t.pointer(&c, &ev(PointerKind::Down, centre.x, centre.y)).is_empty());
|
||||
let a = t.pointer(&c, &ev(PointerKind::Drag, 170.0, 160.0));
|
||||
assert_eq!(a.first(), Some(&Action::Begin("Move".into())), "{a:?}");
|
||||
@@ -3102,7 +3102,7 @@ fn a_ruler_guide_under_the_centre_point_keeps_the_pointer() {
|
||||
assert!(hit_center(&c, centre, c.point_tol()).is_some());
|
||||
let mut t = SelectionTool::default();
|
||||
let cursor = t.cursor(&c, centre, Mods::default());
|
||||
assert_ne!(cursor, Cursor::Move, "the guide's cursor, not the move arrow");
|
||||
assert_ne!(cursor, Cursor::SelectionMove, "the guide's cursor, not the move arrow");
|
||||
let down = t.pointer(&c, &ev(PointerKind::Down, centre.x, centre.y));
|
||||
let drag = t.pointer(&c, &ev(PointerKind::Drag, 170.0, 150.0));
|
||||
assert!(drag.iter().any(|a| matches!(a, Action::Preview(cmd, _) if cmd == "guide.move")), "the guide drags: {down:?} {drag:?}");
|
||||
@@ -3177,7 +3177,7 @@ fn a_press_on_a_selected_member_of_a_group_moves_the_selected_members() {
|
||||
s.set(picked.iter().copied());
|
||||
let c = cx(&d, &s, &p);
|
||||
let mut t = SelectionTool::default();
|
||||
assert_eq!(t.cursor(&c, Point::new(125.0, 125.0), Mods::default()), Cursor::Move, "{picked:?}");
|
||||
assert_eq!(t.cursor(&c, Point::new(125.0, 125.0), Mods::default()), Cursor::SelectionMove, "{picked:?}");
|
||||
let down = t.pointer(&c, &ev(PointerKind::Down, 125.0, 125.0));
|
||||
assert!(!is_select(&down), "{picked:?}: {down:?}");
|
||||
let drag = t.pointer(&c, &ev(PointerKind::Drag, 145.0, 125.0));
|
||||
@@ -3218,7 +3218,7 @@ fn a_press_on_a_selected_member_of_a_group_moves_the_selected_members() {
|
||||
s.anchors.insert(a, [(0, 0), (0, 1), (0, 2), (0, 3)].into_iter().collect());
|
||||
let c = cx(&d, &s, &p);
|
||||
let mut t = SelectionTool::default();
|
||||
assert_eq!(t.cursor(&c, Point::new(125.0, 125.0), Mods::default()), Cursor::Move, "every anchor");
|
||||
assert_eq!(t.cursor(&c, Point::new(125.0, 125.0), Mods::default()), Cursor::SelectionMove, "every anchor");
|
||||
let down = t.pointer(&c, &ev(PointerKind::Down, 125.0, 125.0));
|
||||
assert!(!is_select(&down), "every anchor: {down:?}");
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ pub(super) fn checker_of(setup: &vectorcraft_doc::DocSetup) -> Checker {
|
||||
}
|
||||
|
||||
/// The page frames of document `st` seen through `view`: one per artboard, named "01 - name" with the
|
||||
/// Artboard tool or several boards, filled with its paper or the transparency grid (nothing in Outline).
|
||||
/// Artboard tool or several boards, filled with its paper or the transparency grid (white in Outline).
|
||||
/// Empty while the artboards are hidden.
|
||||
pub(super) fn frames(app: &VectorcraftApp, st: &vectorcraft_engine::DocState, view: &View, outline: bool) -> Vec<PageFrame> {
|
||||
if !shows_artboards(app) {
|
||||
@@ -51,7 +51,7 @@ pub(super) fn frames(app: &VectorcraftApp, st: &vectorcraft_engine::DocState, vi
|
||||
frame = frame.name(format!("{:02} - {}", i + 1, ab.name));
|
||||
}
|
||||
if outline {
|
||||
frame
|
||||
frame.fill(DataColor::new(Color32::WHITE))
|
||||
} else if grid {
|
||||
frame.checker(checker_of(setup))
|
||||
} else {
|
||||
|
||||
@@ -47,13 +47,13 @@ fn shift_clicking_a_name_toggles_selection_and_a_plain_click_activates() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn outline_has_a_white_canvas_line_edges_and_no_paper() {
|
||||
fn outline_has_white_artboards_on_a_white_canvas_with_line_edges() {
|
||||
let _view = crate::testing::DefaultProofView::new();
|
||||
let app = app_with(2);
|
||||
let st = app.session.active().unwrap();
|
||||
assert_eq!(pasteboard_color(&app, st, true), PasteboardColor::Custom(DataColor::new(Color32::WHITE)));
|
||||
assert_eq!(border(true), PageBorder::Line);
|
||||
assert!(frames_of(&app, true).iter().all(|f| f.fill.is_none()));
|
||||
assert!(frames_of(&app, true).iter().all(|f| f.fill == Some(PageFill::Color(DataColor::new(Color32::WHITE)))));
|
||||
assert_eq!(pasteboard_color(&app, st, false), PasteboardColor::Default);
|
||||
assert_eq!(border(false), PageBorder::DropShadow);
|
||||
assert!(frames_of(&app, false).iter().all(|f| f.fill.is_some()));
|
||||
|
||||
@@ -89,6 +89,7 @@ pub fn tool_cursor(c: Cursor) -> cb::Cursor {
|
||||
Cursor::DirectAnchorSelected => tool("cursor-direct-anchor-selected", TIP, None),
|
||||
Cursor::ReshapeSegment => tool("cursor-reshape-segment", TIP, None),
|
||||
Cursor::GroupSelection => badged(CursorBadge::Add),
|
||||
Cursor::SelectionMove => badged(CursorBadge::Move),
|
||||
Cursor::SelectionCopy => badged(CursorBadge::Copy),
|
||||
Cursor::Move => system(CursorIcon::Move),
|
||||
Cursor::Crosshair => PaintedCursor::Crosshair.into(),
|
||||
@@ -207,6 +208,7 @@ const GLYPHS: [Cursor; 99] = [
|
||||
Cursor::ReshapeSegment,
|
||||
Cursor::GroupSelection,
|
||||
Cursor::SelectionCopy,
|
||||
Cursor::SelectionMove,
|
||||
Cursor::Move,
|
||||
Cursor::Crosshair,
|
||||
Cursor::ResizeH,
|
||||
|
||||
Reference in new issue
Block a user