Improve ergonomics of span background highlighting

This commit is contained in:
Héctor Ramón Jiménez 2024-07-28 13:44:08 +02:00
parent 4dc7b9b961
commit f7fe1edcbb
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
3 changed files with 63 additions and 35 deletions

View file

@ -248,17 +248,17 @@ where
// Draw backgrounds
for (index, span) in self.spans.iter().enumerate() {
if let Some(background) = span.background {
if let Some(highlight) = span.highlight {
let translation = layout.position() - Point::ORIGIN;
for bounds in state.paragraph.span_bounds(index) {
renderer.fill_quad(
renderer::Quad {
bounds: bounds + translation,
border: background.border,
border: highlight.border,
..Default::default()
},
background.color,
highlight.background,
);
}
}