Paint highlighted lines correctly when horizontally scrolled

This commit is contained in:
Max Brunsfeld 2021-11-29 11:28:43 -08:00
parent 7537c3b6d4
commit 88e0fe6f88

View File

@ -259,31 +259,18 @@ impl Line {
for glyph in &run.glyphs {
let glyph_origin = origin + baseline_offset + glyph.position;
if glyph_origin.x() + max_glyph_width < visible_bounds.origin().x() {
continue;
}
if glyph_origin.x() > visible_bounds.upper_right().x() {
break;
}
let mut finished_underline = None;
if glyph.index >= run_end {
if let Some((run_len, run_color, run_underline_color)) = style_runs.next() {
if let Some((underline_origin, underline_color)) = underline {
if let Some((_, underline_color)) = underline {
if *run_underline_color != Some(underline_color) {
cx.scene.push_underline(scene::Quad {
bounds: RectF::from_points(
underline_origin,
glyph_origin + vec2f(0., 1.),
),
background: Some(underline_color),
border: Default::default(),
corner_radius: 0.,
});
underline = None;
finished_underline = underline.take();
}
}
if let Some(run_underline_color) = run_underline_color {
underline.get_or_insert((glyph_origin, *run_underline_color));
}
@ -293,20 +280,23 @@ impl Line {
} else {
run_end = self.layout.len;
color = Color::black();
if let Some((underline_origin, underline_color)) = underline.take() {
cx.scene.push_underline(scene::Quad {
bounds: RectF::from_points(
underline_origin,
glyph_origin + vec2f(0., 1.),
),
background: Some(underline_color),
border: Default::default(),
corner_radius: 0.,
});
}
finished_underline = underline.take();
}
}
if glyph_origin.x() + max_glyph_width < visible_bounds.origin().x() {
continue;
}
if let Some((underline_origin, underline_color)) = finished_underline {
cx.scene.push_underline(scene::Quad {
bounds: RectF::from_points(underline_origin, glyph_origin + vec2f(0., 1.)),
background: Some(underline_color),
border: Default::default(),
corner_radius: 0.,
});
}
cx.scene.push_glyph(scene::Glyph {
font_id: run.font_id,
font_size: self.layout.font_size,