mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-27 03:06:57 -06:00
Tab stops: Shift snaps to the ruler's binary inch ticks
`shift_drag_snaps_a_stop_to_the_nearest_tick` landed while this branch was out and asserts the tick an inch ruler used to carry: "the ticks are a tenth of an inch (7.2 pt) apart", snapping 100 pt to 100.8. That tenth is what this change removes -- an inch ruler divides the inch in half, not in ten. The nearest tick to 100 pt is now 99 pt: 1 3/8 in, an eighth of an inch from 1 1/4. The test says so, and also asserts the result is a binary fraction of an inch rather than a particular number, so it holds if the ladder is retuned.
This commit is contained in:
@@ -592,10 +592,12 @@ mod tests {
|
||||
let from = position(&app);
|
||||
drag_on_ruler(&ctx, &mut app, from, 41.6, true);
|
||||
assert_eq!(position(&app), 40.0);
|
||||
// In an inches document the ticks are a tenth of an inch (7.2 pt) apart.
|
||||
// In an inches document the ticks divide the inch in half, not in ten (#2827), so the
|
||||
// nearest one to 100 pt is 99 pt -- 1 3/8 in, an eighth of an inch from 1 1/4.
|
||||
app.session.execute("document.setUnits", &json!({"units": "in"})).unwrap();
|
||||
drag_on_ruler(&ctx, &mut app, 40.0, 100.0, true);
|
||||
assert!((position(&app) - 100.8).abs() < 1e-9, "{}", position(&app));
|
||||
assert!((position(&app) - 99.0).abs() < 1e-9, "{}", position(&app));
|
||||
assert_eq!((position(&app) / 72.0 * 8.0).round(), position(&app) / 72.0 * 8.0, "a binary fraction of an inch");
|
||||
}
|
||||
|
||||
/// One frame of the panel menu with `events` → the rows' texts and where they are painted.
|
||||
|
||||
Reference in New Issue
Block a user