diff --git a/egui/src/context.rs b/egui/src/context.rs index 41bfc6ea..e938c140 100644 --- a/egui/src/context.rs +++ b/egui/src/context.rs @@ -76,7 +76,12 @@ impl Clone for Context { impl Context { pub fn new() -> Arc { - Arc::new(Self::default()) + Arc::new(Self { + // Start with painting an extra frame to compensate for some widgets + // that take two frames before they "settle": + repaint_requests: AtomicU32::new(1), + ..Self::default() + }) } /// How much space is still available after panels has been added. diff --git a/egui/src/demos/app.rs b/egui/src/demos/app.rs index 548689fb..a4a47c74 100644 --- a/egui/src/demos/app.rs +++ b/egui/src/demos/app.rs @@ -60,6 +60,7 @@ impl Default for FrameHistory { } impl FrameHistory { + // Called first pub fn on_new_frame(&mut self, now: f64, previus_frame_time: Option) { let previus_frame_time = previus_frame_time.unwrap_or_default(); if let Some(latest) = self.frame_times.latest_mut() { @@ -74,7 +75,7 @@ impl FrameHistory { fn ui(&mut self, ui: &mut Ui) { ui.label(format!( - "Total frames painted: {}", + "Total frames painted (including this one): {}", self.frame_times.total_count() ));