mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 06:10:06 -04:00
Paint mouse cursor in kittest snapshot images (#7721)
Very simple triangle shape, but helps understand why a widget has a hovered effect
This commit is contained in:
@@ -657,7 +657,28 @@ impl<'a, State> Harness<'a, State> {
|
||||
/// Returns an error if the rendering fails.
|
||||
#[cfg(any(feature = "wgpu", feature = "snapshot"))]
|
||||
pub fn render(&mut self) -> Result<image::RgbaImage, String> {
|
||||
self.renderer.render(&self.ctx, &self.output)
|
||||
let mut output = self.output.clone();
|
||||
|
||||
if let Some(mouse_pos) = self.ctx.input(|i| i.pointer.hover_pos()) {
|
||||
// Paint a mouse cursor:
|
||||
let triangle = vec![
|
||||
mouse_pos,
|
||||
mouse_pos + egui::vec2(16.0, 8.0),
|
||||
mouse_pos + egui::vec2(8.0, 16.0),
|
||||
];
|
||||
|
||||
output.shapes.push(ClippedShape {
|
||||
clip_rect: self.ctx.content_rect(),
|
||||
shape: egui::epaint::PathShape::convex_polygon(
|
||||
triangle,
|
||||
Color32::WHITE,
|
||||
egui::Stroke::new(1.0, Color32::BLACK),
|
||||
)
|
||||
.into(),
|
||||
});
|
||||
}
|
||||
|
||||
self.renderer.render(&self.ctx, &output)
|
||||
}
|
||||
|
||||
/// Get the root viewport output
|
||||
|
||||
Reference in New Issue
Block a user