8000 `egui_kittest`: Add `HarnessBuilder::theme` by emilk · Pull Request #7289 · emilk/egui · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

egui_kittest: Add HarnessBuilder::theme #7289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
8000
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions crates/egui_kittest/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::marker::PhantomData;
pub struct HarnessBuilder<State = ()> {
pub(crate) screen_rect: Rect,
pub(crate) pixels_per_point: f32,
pub(crate) theme: egui::Theme,
pub(crate) max_steps: u64,
pub(crate) step_dt: f32,
pub(crate) state: PhantomData<State>,
Expand All @@ -19,6 +20,7 @@ impl<State> Default for HarnessBuilder<State> {
Self {
screen_rect: Rect::from_min_size(Pos2::ZERO, Vec2::new(800.0, 600.0)),
pixels_per_point: 1.0,
theme: egui::Theme::Dark,
state: PhantomData,
renderer: Box::new(LazyRenderer::default()),
max_steps: 4,
Expand All @@ -45,6 +47,13 @@ impl<State> HarnessBuilder<State> {
self
}

/// Set the desired theme (dark or light).
#[inline]
pub fn with_theme(mut self, theme: egui::Theme) -> Self {
self.theme = theme;
self
}

/// Set the maximum number of steps to run when calling [`Harness::run`].
///
/// Default is 4.
Expand Down
2 changes: 2 additions & 0 deletions crates/egui_kittest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,15 @@ impl<'a, State> Harness<'a, State> {
let HarnessBuilder {
screen_rect,
pixels_per_point,
theme,
max_steps,
step_dt,
state: _,
mut renderer,
wait_for_pending_images,
} = builder;
let ctx = ctx.unwrap_or_default();
ctx.set_theme(theme);
ctx.enable_accesskit();
// Disable cursor blinking so it doesn't interfere with snapshots
ctx.all_styles_mut(|style| style.visuals.text_cursor.blink = false);
Expand Down
Loading
0