mirror of
https://github.com/typst/typst
synced 2025-08-15 07:28:32 +08:00
Address review
This commit is contained in:
parent
5865f0e9e9
commit
61f9f7389f
@ -59,7 +59,13 @@ pub fn jump_from_click(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let pos = pos.transform_inf(group.transform.invert().unwrap());
|
// Realistic transforms should always be invertible.
|
||||||
|
// An example of one that isn't is a scale of 0, which would
|
||||||
|
// not be clickable anyway.
|
||||||
|
let Some(inv_transform) = group.transform.invert() else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
let pos = pos.transform_inf(inv_transform);
|
||||||
if let Some(span) = jump_from_click(world, document, &group.frame, pos) {
|
if let Some(span) = jump_from_click(world, document, &group.frame, pos) {
|
||||||
return Some(span);
|
return Some(span);
|
||||||
}
|
}
|
||||||
@ -292,7 +298,8 @@ mod tests {
|
|||||||
cursor(45),
|
cursor(45),
|
||||||
);
|
);
|
||||||
test_click(
|
test_click(
|
||||||
"#box(width: 10pt, height: 10pt, clip: true, scale(x: 300%, y: 300%, origin: top + left, rect(width: 10pt, height: 10pt)))",
|
"#box(width: 10pt, height: 10pt, clip: true, scale(x: 300%, y: 300%, \
|
||||||
|
origin: top + left, rect(width: 10pt, height: 10pt)))",
|
||||||
point(20.0, 20.0) + margin,
|
point(20.0, 20.0) + margin,
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
@ -306,6 +313,11 @@ mod tests {
|
|||||||
point(20.0, 20.0) + margin,
|
point(20.0, 20.0) + margin,
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
test_click(
|
||||||
|
"#rotate(90deg, origin: bottom + left)[hello world]",
|
||||||
|
point(5.0, 15.0) + margin,
|
||||||
|
cursor(40),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -531,10 +531,6 @@ impl Curve {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn point_to_kurbo(point: Point) -> kurbo::Point {
|
|
||||||
kurbo::Point::new(point.x.to_raw(), point.y.to_raw())
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Curve {
|
impl Curve {
|
||||||
fn to_kurbo(&self) -> kurbo::BezPath {
|
fn to_kurbo(&self) -> kurbo::BezPath {
|
||||||
use kurbo::{BezPath, PathEl};
|
use kurbo::{BezPath, PathEl};
|
||||||
@ -557,3 +553,7 @@ impl Curve {
|
|||||||
kurbo::Shape::contains(&self.to_kurbo(), point_to_kurbo(needle))
|
kurbo::Shape::contains(&self.to_kurbo(), point_to_kurbo(needle))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn point_to_kurbo(point: Point) -> kurbo::Point {
|
||||||
|
kurbo::Point::new(point.x.to_raw(), point.y.to_raw())
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user