summaryrefslogtreecommitdiff
path: root/src/doc.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-03-16 17:36:04 +0100
committerLaurenz <laurmaedje@gmail.com>2023-03-17 11:30:58 +0100
commite8435df5ec718e8ecc8a2ad48e4eb3ddd1f92a72 (patch)
tree58d8356ec1c615f898e342a479b5f967a8177468 /src/doc.rs
parentecb5543985cc0788d9c01e8c2e28d8ca6d8e19b6 (diff)
More jump targets
Diffstat (limited to 'src/doc.rs')
-rw-r--r--src/doc.rs35
1 files changed, 20 insertions, 15 deletions
diff --git a/src/doc.rs b/src/doc.rs
index 6add64fc..03885b03 100644
--- a/src/doc.rs
+++ b/src/doc.rs
@@ -288,7 +288,7 @@ impl Frame {
pub fn fill(&mut self, fill: Paint) {
self.prepend(
Point::zero(),
- Element::Shape(Geometry::Rect(self.size()).filled(fill)),
+ Element::Shape(Geometry::Rect(self.size()).filled(fill), Span::detached()),
);
}
@@ -299,6 +299,7 @@ impl Frame {
stroke: Sides<Option<Stroke>>,
outset: Sides<Rel<Abs>>,
radius: Corners<Rel<Abs>>,
+ span: Span,
) {
let outset = outset.relative_to(self.size());
let size = self.size() + outset.sum_by_axis();
@@ -307,7 +308,7 @@ impl Frame {
self.prepend_multiple(
rounded_rect(size, radius, fill, stroke)
.into_iter()
- .map(|x| (pos, Element::Shape(x))),
+ .map(|x| (pos, Element::Shape(x, span))),
)
}
@@ -349,6 +350,7 @@ impl Frame {
Element::Shape(
Geometry::Rect(self.size)
.filled(RgbaColor { a: 100, ..Color::TEAL.to_rgba() }.into()),
+ Span::detached(),
),
);
self.insert(
@@ -359,6 +361,7 @@ impl Frame {
paint: Color::RED.into(),
thickness: Abs::pt(1.0),
}),
+ Span::detached(),
),
);
self
@@ -369,11 +372,10 @@ impl Frame {
let radius = Abs::pt(2.0);
self.push(
pos - Point::splat(radius),
- Element::Shape(geom::ellipse(
- Size::splat(2.0 * radius),
- Some(Color::GREEN.into()),
- None,
- )),
+ Element::Shape(
+ geom::ellipse(Size::splat(2.0 * radius), Some(Color::GREEN.into()), None),
+ Span::detached(),
+ ),
);
}
@@ -381,10 +383,13 @@ impl Frame {
pub fn mark_line(&mut self, y: Abs) {
self.push(
Point::with_y(y),
- Element::Shape(Geometry::Line(Point::with_x(self.size.x)).stroked(Stroke {
- paint: Color::GREEN.into(),
- thickness: Abs::pt(1.0),
- })),
+ Element::Shape(
+ Geometry::Line(Point::with_x(self.size.x)).stroked(Stroke {
+ paint: Color::GREEN.into(),
+ thickness: Abs::pt(1.0),
+ }),
+ Span::detached(),
+ ),
);
}
}
@@ -406,9 +411,9 @@ pub enum Element {
/// A run of shaped text.
Text(Text),
/// A geometric shape with optional fill and stroke.
- Shape(Shape),
+ Shape(Shape, Span),
/// An image and its size.
- Image(Image, Size),
+ Image(Image, Size, Span),
/// Meta information and the region it applies to.
Meta(Meta, Size),
}
@@ -418,8 +423,8 @@ impl Debug for Element {
match self {
Self::Group(group) => group.fmt(f),
Self::Text(text) => write!(f, "{text:?}"),
- Self::Shape(shape) => write!(f, "{shape:?}"),
- Self::Image(image, _) => write!(f, "{image:?}"),
+ Self::Shape(shape, _) => write!(f, "{shape:?}"),
+ Self::Image(image, _, _) => write!(f, "{image:?}"),
Self::Meta(meta, _) => write!(f, "{meta:?}"),
}
}