Fix #10547: tools draw their move, resize, grab and not-allowed cursors
Most tool cursors are drawn by the app at its own cursor size, but Cursor::Move, the four resize cursors, HandGrab, NotAllowed, Text and the vertical type cursors were handed to the system. On Wayland the compositor draws those from the desktop's cursor theme at the theme's size, so one tool switched between a small drawn cursor and a large themed one, for example the Curvature tool over an anchor, the bounding box handles, or the Hand while panning. These cursors are now drawn too: new move, resize, not-allowed and vertical I-beam glyphs in assets/cursors, the framework's I-beam for Text, and the framework's hand, which closes while the primary button is down, for HandGrab. The busy pointer of a long operation stays the system's.
No files matched your search
@@ -83,11 +83,18 @@ Generated-in-code art is original and has no file to list. This covers the defau
|
||||
| `assets/cursors/cursor-mark-ring.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/cursors/cursor-mark-square.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/cursors/cursor-mark-star.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/cursors/cursor-move.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/cursors/cursor-not-allowed.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/cursors/cursor-pen-convert.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/cursors/cursor-pen-curvature.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/cursors/cursor-pen-join.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/cursors/cursor-pen-new.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/cursors/cursor-reshape-segment.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/cursors/cursor-resize-h.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/cursors/cursor-resize-nesw.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/cursors/cursor-resize-nwse.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/cursors/cursor-resize-v.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/cursors/cursor-type-vertical.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/fonts/Inter-Medium.ttf` | Rasmus Andersson / The Inter Project Authors | https://github.com/rsms/inter | OFL-1.1 (`assets/fonts/OFL-Inter.txt`) | Open-source typeface, not product iconography or artwork |
|
||||
| `assets/fonts/Inter-Regular.ttf` | Rasmus Andersson / The Inter Project Authors | https://github.com/rsms/inter | OFL-1.1 (`assets/fonts/OFL-Inter.txt`) | Open-source typeface, not product iconography or artwork |
|
||||
| `assets/fonts/Inter-SemiBold.ttf` | Rasmus Andersson / The Inter Project Authors | https://github.com/rsms/inter | OFL-1.1 (`assets/fonts/OFL-Inter.txt`) | Open-source typeface, not product iconography or artwork |
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="#000"><path d="M11 5h2v14h-2Z"/><path d="M5 11h14v2H5Z"/><path d="M12 1.5L15.5 5.5H8.5Z"/><path d="M12 22.5L8.5 18.5H15.5Z"/><path d="M1.5 12L5.5 8.5V15.5Z"/><path d="M22.5 12L18.5 15.5V8.5Z"/></svg>
|
||||
|
After Width: | Height: | Size: 289 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="#000"><path fill-rule="evenodd" d="M12 4a8 8 0 1 1 0 16a8 8 0 1 1 0-16ZM12 6a6 6 0 1 0 0 12a6 6 0 1 0 0-12Z"/><path d="M6.9 15.7L15.7 6.9L17.1 8.3L8.3 17.1Z"/></svg>
|
||||
|
After Width: | Height: | Size: 255 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="#000"><path d="M5 11h14v2H5Z"/><path d="M1.5 12L6 8V16Z"/><path d="M22.5 12L18 16V8Z"/></svg>
|
||||
|
After Width: | Height: | Size: 183 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="#000"><path d="M17.3 5.3L5.3 17.3L6.7 18.7L18.7 6.7Z"/><path d="M21.5 2.5L14.5 3.5L20.5 9.5Z"/><path d="M2.5 21.5L9.5 20.5L3.5 14.5Z"/></svg>
|
||||
|
After Width: | Height: | Size: 231 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="#000"><path d="M6.7 5.3L18.7 17.3L17.3 18.7L5.3 6.7Z"/><path d="M2.5 2.5L9.5 3.5L3.5 9.5Z"/><path d="M21.5 21.5L14.5 20.5L20.5 14.5Z"/></svg>
|
||||
|
After Width: | Height: | Size: 231 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="#000"><path d="M11 5h2v14h-2Z"/><path d="M12 1.5L16 6H8Z"/><path d="M12 22.5L8 18H16Z"/></svg>
|
||||
|
After Width: | Height: | Size: 184 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="#000"><path d="M5 11.25h14v1.5H5Z"/><path d="M4.25 8.5h1.5v7h-1.5Z"/><path d="M18.25 8.5h1.5v7h-1.5Z"/></svg>
|
||||
|
After Width: | Height: | Size: 199 B |
@@ -483,7 +483,7 @@ shown_when = [
|
||||
"The Smooth tool, and the Pencil or Blob Brush where Alt gives the Smooth tool, when no path is selected that the Smooth tool can act on: a drag changes nothing.",
|
||||
]
|
||||
hotspot = "The centre."
|
||||
designer = false
|
||||
look = "A ring crossed by a diagonal bar."
|
||||
|
||||
[[cursor]]
|
||||
id = "Busy"
|
||||
|
||||
@@ -29,11 +29,18 @@ pub static CURSOR_ICONS: AppIcons = AppIcons::new(
|
||||
("cursor-mark-ring", include_bytes!("../../../assets/cursors/cursor-mark-ring.svg")),
|
||||
("cursor-mark-square", include_bytes!("../../../assets/cursors/cursor-mark-square.svg")),
|
||||
("cursor-mark-star", include_bytes!("../../../assets/cursors/cursor-mark-star.svg")),
|
||||
("cursor-move", include_bytes!("../../../assets/cursors/cursor-move.svg")),
|
||||
("cursor-not-allowed", include_bytes!("../../../assets/cursors/cursor-not-allowed.svg")),
|
||||
("cursor-pen-convert", include_bytes!("../../../assets/cursors/cursor-pen-convert.svg")),
|
||||
("cursor-pen-curvature", include_bytes!("../../../assets/cursors/cursor-pen-curvature.svg")),
|
||||
("cursor-pen-join", include_bytes!("../../../assets/cursors/cursor-pen-join.svg")),
|
||||
("cursor-pen-new", include_bytes!("../../../assets/cursors/cursor-pen-new.svg")),
|
||||
("cursor-reshape-segment", include_bytes!("../../../assets/cursors/cursor-reshape-segment.svg")),
|
||||
("cursor-resize-h", include_bytes!("../../../assets/cursors/cursor-resize-h.svg")),
|
||||
("cursor-resize-nesw", include_bytes!("../../../assets/cursors/cursor-resize-nesw.svg")),
|
||||
("cursor-resize-nwse", include_bytes!("../../../assets/cursors/cursor-resize-nwse.svg")),
|
||||
("cursor-resize-v", include_bytes!("../../../assets/cursors/cursor-resize-v.svg")),
|
||||
("cursor-type-vertical", include_bytes!("../../../assets/cursors/cursor-type-vertical.svg")),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -45,6 +52,8 @@ const PIPETTE_TIP: Vec2 = Vec2::new(2.0, 22.0);
|
||||
const CARET: Vec2 = Vec2::new(12.0, 6.0);
|
||||
/// The blade's point of the knife, at the box's upper right.
|
||||
const BLADE_POINT: Vec2 = Vec2::new(20.0, 4.0);
|
||||
/// The middle of the box: the crossing of the move, resize and not-allowed glyphs and the vertical I-beam's center.
|
||||
const CENTER: Vec2 = Vec2::new(12.0, 12.0);
|
||||
/// The bottom of the drop below the paint bucket.
|
||||
const BUCKET_DROP: Vec2 = Vec2::new(20.0, 22.0);
|
||||
/// The bottom of the drop beside the Live Paint diamond.
|
||||
@@ -91,12 +100,12 @@ pub fn tool_cursor(c: Cursor) -> cb::Cursor {
|
||||
Cursor::GroupSelection => badged(CursorBadge::Add),
|
||||
Cursor::SelectionMove => badged(CursorBadge::Move),
|
||||
Cursor::SelectionCopy => badged(CursorBadge::Copy),
|
||||
Cursor::Move => system(CursorIcon::Move),
|
||||
Cursor::Move => tool("cursor-move", CENTER, None),
|
||||
Cursor::Crosshair => PaintedCursor::Crosshair.into(),
|
||||
Cursor::ResizeH => system(CursorIcon::ResizeHorizontal),
|
||||
Cursor::ResizeV => system(CursorIcon::ResizeVertical),
|
||||
Cursor::ResizeNwSe => system(CursorIcon::ResizeNwSe),
|
||||
Cursor::ResizeNeSw => system(CursorIcon::ResizeNeSw),
|
||||
Cursor::ResizeH => tool("cursor-resize-h", CENTER, None),
|
||||
Cursor::ResizeV => tool("cursor-resize-v", CENTER, None),
|
||||
Cursor::ResizeNwSe => tool("cursor-resize-nwse", CENTER, None),
|
||||
Cursor::ResizeNeSw => tool("cursor-resize-nesw", CENTER, None),
|
||||
Cursor::ShearH => PaintedCursor::skew(Vec2::new(1.0, 0.0)).into(),
|
||||
Cursor::ShearV => PaintedCursor::skew(Vec2::new(0.0, -1.0)).into(),
|
||||
Cursor::Rotate => turn_toward(0),
|
||||
@@ -112,16 +121,18 @@ pub fn tool_cursor(c: Cursor) -> cb::Cursor {
|
||||
Cursor::PenConvert => tool("cursor-pen-convert", TIP, None),
|
||||
Cursor::Curvature => tool("cursor-pen-curvature", TIP, None),
|
||||
Cursor::AnchorPoint => tool("cursor-anchor-point", CARET, None),
|
||||
Cursor::Text => system(CursorIcon::Text),
|
||||
Cursor::TypeVertical | Cursor::TypeAreaVertical | Cursor::TypeOnPathVertical => system(CursorIcon::VerticalText),
|
||||
Cursor::Text => PaintedCursor::IBeam.into(),
|
||||
Cursor::TypeVertical | Cursor::TypeAreaVertical | Cursor::TypeOnPathVertical => tool("cursor-type-vertical", CENTER, None),
|
||||
Cursor::TypeArea => PaintedCursor::type_on(false).into(),
|
||||
Cursor::TypeOnPath => PaintedCursor::type_on(true).into(),
|
||||
Cursor::Hand => PaintedCursor::Hand.into(),
|
||||
Cursor::HandGrab => system(CursorIcon::Grabbing),
|
||||
// The framework draws the hand closed while the primary button is down.
|
||||
Cursor::HandGrab => PaintedCursor::Hand.into(),
|
||||
Cursor::ZoomIn => PaintedCursor::zoom(false).into(),
|
||||
Cursor::ZoomOut => PaintedCursor::zoom(true).into(),
|
||||
Cursor::Eyedropper => tool("pipette", PIPETTE_TIP, None),
|
||||
Cursor::NotAllowed => system(CursorIcon::NotAllowed),
|
||||
Cursor::NotAllowed => tool("cursor-not-allowed", CENTER, None),
|
||||
// The window-wide wait pointer of a long operation, not a canvas tool's cursor.
|
||||
Cursor::Busy => system(CursorIcon::Progress),
|
||||
Cursor::AddStop => badged(CursorBadge::Add),
|
||||
Cursor::RemoveStop => badged(CursorBadge::Subtract),
|
||||
|
||||
@@ -35,6 +35,42 @@ fn every_tool_cursors_hotspot_is_on_its_glyph() {
|
||||
assert!(missed.is_empty(), "hotspots off their glyphs: {missed:?}");
|
||||
}
|
||||
|
||||
/// One tool switches between these looks as the pointer moves (the Curvature pen over an anchor, the
|
||||
/// Selection arrow over a corner handle, the Hand while it pans, a tool that has nothing to act on, the
|
||||
/// type tools). The app draws all of them at its own cursor size, so none comes from the desktop's
|
||||
/// cursor theme at another size; only the window-wide wait pointer of a long operation does.
|
||||
#[test]
|
||||
fn a_tools_move_resize_grab_and_not_allowed_cursors_are_drawn_like_its_own() {
|
||||
use craft::ui::primitives::{painted_image, register_app_icons};
|
||||
use craft::ui::runtime::env::Env;
|
||||
crate::icons::register();
|
||||
register_app_icons(&CURSOR_ICONS);
|
||||
let pairs = [
|
||||
(Cursor::Curvature, Cursor::Move),
|
||||
(Cursor::Arrow, Cursor::ResizeNwSe),
|
||||
(Cursor::Arrow, Cursor::ResizeH),
|
||||
(Cursor::Hand, Cursor::HandGrab),
|
||||
(Cursor::Smooth, Cursor::NotAllowed),
|
||||
(Cursor::TypeArea, Cursor::Text),
|
||||
(Cursor::TypeArea, Cursor::TypeVertical),
|
||||
];
|
||||
crate::testing::ui_context()
|
||||
.run_ui(Default::default(), |ui| {
|
||||
let env = Env::of(ui);
|
||||
for (own, other) in pairs {
|
||||
for c in [own, other] {
|
||||
let cb::Cursor::Painted(painted) = tool_cursor(c) else { panic!("{c:?} beside {own:?} comes from the desktop's cursor theme") };
|
||||
let (one, two) = (painted_image(&env, &painted, 1.0), painted_image(&env, &painted, 2.0));
|
||||
let (Some(one), Some(two)) = (one, two) else { panic!("{c:?} has no image") };
|
||||
assert!(two.size[0] > one.size[0] && two.size[1] > one.size[1], "{c:?} grows with the cursor scale");
|
||||
}
|
||||
}
|
||||
})
|
||||
.textures_delta
|
||||
.clear();
|
||||
assert!(matches!(tool_cursor(Cursor::Busy), cb::Cursor::System(_)), "the wait pointer stays the system's");
|
||||
}
|
||||
|
||||
/// A `cursor-` icon name a cursor uses must be in the set the host registers.
|
||||
#[test]
|
||||
fn every_cursor_icon_the_app_names_is_in_its_set() {
|
||||
|
||||