Fix painting when underlines and quads appeared after a wrap boundary
This commit is contained in:
parent
f227c3284d
commit
047cfe5108
1 changed files with 21 additions and 15 deletions
|
@ -40,7 +40,6 @@ impl ShapedLine {
|
||||||
&self.layout,
|
&self.layout,
|
||||||
line_height,
|
line_height,
|
||||||
&self.decoration_runs,
|
&self.decoration_runs,
|
||||||
None,
|
|
||||||
&[],
|
&[],
|
||||||
cx,
|
cx,
|
||||||
)?;
|
)?;
|
||||||
|
@ -74,7 +73,6 @@ impl WrappedLine {
|
||||||
&self.layout.unwrapped_layout,
|
&self.layout.unwrapped_layout,
|
||||||
line_height,
|
line_height,
|
||||||
&self.decoration_runs,
|
&self.decoration_runs,
|
||||||
self.wrap_width,
|
|
||||||
&self.wrap_boundaries,
|
&self.wrap_boundaries,
|
||||||
cx,
|
cx,
|
||||||
)?;
|
)?;
|
||||||
|
@ -88,7 +86,6 @@ fn paint_line(
|
||||||
layout: &LineLayout,
|
layout: &LineLayout,
|
||||||
line_height: Pixels,
|
line_height: Pixels,
|
||||||
decoration_runs: &[DecorationRun],
|
decoration_runs: &[DecorationRun],
|
||||||
wrap_width: Option<Pixels>,
|
|
||||||
wrap_boundaries: &[WrapBoundary],
|
wrap_boundaries: &[WrapBoundary],
|
||||||
cx: &mut WindowContext<'_>,
|
cx: &mut WindowContext<'_>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
@ -113,24 +110,28 @@ fn paint_line(
|
||||||
|
|
||||||
if wraps.peek() == Some(&&WrapBoundary { run_ix, glyph_ix }) {
|
if wraps.peek() == Some(&&WrapBoundary { run_ix, glyph_ix }) {
|
||||||
wraps.next();
|
wraps.next();
|
||||||
if let Some((background_origin, background_color)) = current_background.take() {
|
if let Some((background_origin, background_color)) = current_background.as_mut() {
|
||||||
cx.paint_quad(
|
cx.paint_quad(
|
||||||
Bounds {
|
Bounds {
|
||||||
origin: background_origin,
|
origin: *background_origin,
|
||||||
size: size(glyph_origin.x - background_origin.x, line_height),
|
size: size(glyph_origin.x - background_origin.x, line_height),
|
||||||
},
|
},
|
||||||
Corners::default(),
|
Corners::default(),
|
||||||
background_color,
|
*background_color,
|
||||||
Edges::default(),
|
Edges::default(),
|
||||||
transparent_black(),
|
transparent_black(),
|
||||||
);
|
);
|
||||||
|
background_origin.x = origin.x;
|
||||||
|
background_origin.y += line_height;
|
||||||
}
|
}
|
||||||
if let Some((underline_origin, underline_style)) = current_underline.take() {
|
if let Some((underline_origin, underline_style)) = current_underline.as_mut() {
|
||||||
cx.paint_underline(
|
cx.paint_underline(
|
||||||
underline_origin,
|
*underline_origin,
|
||||||
glyph_origin.x - underline_origin.x,
|
glyph_origin.x - underline_origin.x,
|
||||||
&underline_style,
|
underline_style,
|
||||||
);
|
);
|
||||||
|
underline_origin.x = origin.x;
|
||||||
|
underline_origin.y += line_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
glyph_origin.x = origin.x;
|
glyph_origin.x = origin.x;
|
||||||
|
@ -149,7 +150,7 @@ fn paint_line(
|
||||||
}
|
}
|
||||||
if let Some(run_background) = style_run.background_color {
|
if let Some(run_background) = style_run.background_color {
|
||||||
current_background
|
current_background
|
||||||
.get_or_insert((point(glyph_origin.x, origin.y), run_background));
|
.get_or_insert((point(glyph_origin.x, glyph_origin.y), run_background));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some((_, underline_style)) = &mut current_underline {
|
if let Some((_, underline_style)) = &mut current_underline {
|
||||||
|
@ -161,7 +162,7 @@ fn paint_line(
|
||||||
current_underline.get_or_insert((
|
current_underline.get_or_insert((
|
||||||
point(
|
point(
|
||||||
glyph_origin.x,
|
glyph_origin.x,
|
||||||
origin.y + baseline_offset.y + (layout.descent * 0.618),
|
glyph_origin.y + baseline_offset.y + (layout.descent * 0.618),
|
||||||
),
|
),
|
||||||
UnderlineStyle {
|
UnderlineStyle {
|
||||||
color: Some(run_underline.color.unwrap_or(style_run.color)),
|
color: Some(run_underline.color.unwrap_or(style_run.color)),
|
||||||
|
@ -228,12 +229,18 @@ fn paint_line(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut last_line_end_x = origin.x + layout.width;
|
||||||
|
if let Some(boundary) = wrap_boundaries.last() {
|
||||||
|
let run = &layout.runs[boundary.run_ix];
|
||||||
|
let glyph = &run.glyphs[boundary.glyph_ix];
|
||||||
|
last_line_end_x -= glyph.position.x;
|
||||||
|
}
|
||||||
|
|
||||||
if let Some((background_origin, background_color)) = current_background.take() {
|
if let Some((background_origin, background_color)) = current_background.take() {
|
||||||
let line_end_x = origin.x + wrap_width.unwrap_or(Pixels::MAX).min(layout.width);
|
|
||||||
cx.paint_quad(
|
cx.paint_quad(
|
||||||
Bounds {
|
Bounds {
|
||||||
origin: background_origin,
|
origin: background_origin,
|
||||||
size: size(line_end_x - background_origin.x, line_height),
|
size: size(last_line_end_x - background_origin.x, line_height),
|
||||||
},
|
},
|
||||||
Corners::default(),
|
Corners::default(),
|
||||||
background_color,
|
background_color,
|
||||||
|
@ -243,10 +250,9 @@ fn paint_line(
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some((underline_start, underline_style)) = current_underline.take() {
|
if let Some((underline_start, underline_style)) = current_underline.take() {
|
||||||
let line_end_x = origin.x + wrap_width.unwrap_or(Pixels::MAX).min(layout.width);
|
|
||||||
cx.paint_underline(
|
cx.paint_underline(
|
||||||
underline_start,
|
underline_start,
|
||||||
line_end_x - underline_start.x,
|
last_line_end_x - underline_start.x,
|
||||||
&underline_style,
|
&underline_style,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue