WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit f74b7c7

Browse files
authored
Paint mouse cursor in kittest snapshot images (#7721)
Very simple triangle shape, but helps understand why a widget has a hovered effect
1 parent dc0acd2 commit f74b7c7

32 files changed

+84
-63
lines changed
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading

crates/egui_kittest/src/lib.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,28 @@ impl<'a, State> Harness<'a, State> {
657657
/// Returns an error if the rendering fails.
658658
#[cfg(any(feature = "wgpu", feature = "snapshot"))]
659659
pub fn render(&mut self) -> Result<image::RgbaImage, String> {
660-
self.renderer.render(&self.ctx, &self.output)
660+
let mut output = self.output.clone();
661+
662+
if let Some(mouse_pos) = self.ctx.input(|i| i.pointer.hover_pos()) {
663+
// Paint a mouse cursor:
664+
let triangle = vec![
665+
mouse_pos,
666+
mouse_pos + egui::vec2(16.0, 8.0),
667+
mouse_pos + egui::vec2(8.0, 16.0),
668+
];
669+
670+
output.shapes.push(ClippedShape {
671+
clip_rect: self.ctx.content_rect(),
672+
shape: egui::epaint::PathShape::convex_polygon(
673+
triangle,
674+
Color32::WHITE,
675+
egui::Stroke::new(1.0, Color32::BLACK),
676+
)
677+
.into(),
678+
});
679+
}
680+
681+
self.renderer.render(&self.ctx, &output)
661682
}
662683

663684
/// Get the root viewport output
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading

0 commit comments

Comments
 (0)