mirror of
https://github.com/emilk/egui.git
synced 2026-06-27 07:03:14 -04:00
Add debug option to paint rectangles around text primitives
This commit is contained in:
@@ -883,6 +883,7 @@ impl paint::TessellationOptions {
|
||||
anti_alias,
|
||||
coarse_tessellation_culling,
|
||||
debug_paint_clip_rects,
|
||||
debug_paint_text_rects,
|
||||
debug_ignore_clip_rects,
|
||||
} = self;
|
||||
ui.checkbox(anti_alias, "Antialias");
|
||||
@@ -890,7 +891,8 @@ impl paint::TessellationOptions {
|
||||
coarse_tessellation_culling,
|
||||
"Do coarse culling in the tessellator",
|
||||
);
|
||||
ui.checkbox(debug_paint_clip_rects, "Paint clip rectangles (debug)");
|
||||
ui.checkbox(debug_ignore_clip_rects, "Ignore clip rectangles (debug)");
|
||||
ui.checkbox(debug_paint_clip_rects, "Paint clip rectangles (debug)");
|
||||
ui.checkbox(debug_paint_text_rects, "Paint text bounds (debug)");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -458,6 +458,8 @@ pub struct TessellationOptions {
|
||||
pub coarse_tessellation_culling: bool,
|
||||
/// Output the clip rectangles to be painted?
|
||||
pub debug_paint_clip_rects: bool,
|
||||
/// Output the text-containing rectangles
|
||||
pub debug_paint_text_rects: bool,
|
||||
/// If true, no clipping will be done
|
||||
pub debug_ignore_clip_rects: bool,
|
||||
}
|
||||
@@ -468,6 +470,7 @@ impl Default for TessellationOptions {
|
||||
aa_size: 1.0,
|
||||
anti_alias: true,
|
||||
coarse_tessellation_culling: true,
|
||||
debug_paint_text_rects: false,
|
||||
debug_paint_clip_rects: false,
|
||||
debug_ignore_clip_rects: false,
|
||||
}
|
||||
@@ -789,6 +792,17 @@ impl Tessellator {
|
||||
text_style,
|
||||
color,
|
||||
} => {
|
||||
if options.debug_paint_text_rects {
|
||||
self.tessellate_rect(
|
||||
&PaintRect {
|
||||
rect: Rect::from_min_size(pos, galley.size).expand(0.5),
|
||||
corner_radius: 2.0,
|
||||
fill: Default::default(),
|
||||
stroke: (0.5, color).into(),
|
||||
},
|
||||
out,
|
||||
);
|
||||
}
|
||||
self.tessellate_text(fonts, pos, &galley, text_style, color, out);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user