diff --git a/crates/egui/src/theme/default_style.rs b/crates/egui/src/theme/default_style.rs index 4842f415d..2680297b4 100644 --- a/crates/egui/src/theme/default_style.rs +++ b/crates/egui/src/theme/default_style.rs @@ -143,12 +143,12 @@ impl StyleProvider for DefaultStyle { impl StyleProvider for DefaultStyle { fn style(&mut self, modifiers: &StyleArgs<'_>) -> SeparatorStyle { - let StyleArgs { ctx, .. } = modifiers; - let ws: BaseStyle = ctx.get_widget_style(modifiers); + let StyleArgs { style, .. } = modifiers; SeparatorStyle { spacing: 6.0, - stroke: ws.frame.stroke, + // A separator is never interactive, so its stroke doesn't depend on the widget state: + stroke: style.visuals.widgets.noninteractive.bg_stroke, } } } diff --git a/crates/egui/src/theme/mod.rs b/crates/egui/src/theme/mod.rs index 59641acc4..fbd253a1e 100644 --- a/crates/egui/src/theme/mod.rs +++ b/crates/egui/src/theme/mod.rs @@ -8,7 +8,7 @@ pub use self::{style_provider::StyleProvider, themes::Themes}; use crate::{ Ui, - widget_style::{Classes, StyleArgs, WidgetStyle}, + widget_style::{Classes, StyleArgs, WidgetState, WidgetStyle}, }; impl Ui { @@ -19,11 +19,16 @@ impl Ui { id: crate::Id, classes: &Classes, ) -> S { - // Fetch the current state of the widget - let state = self - .read_response(id) - .map(|r| r.widget_state()) - .unwrap_or_default(); + // Fetch the state of the widget, as it was in the previous pass + let state = if let Some(response) = self.read_response(id) { + response.widget_state() + } else { + // We don't know the state of the widget yet, so we would style it wrong. + // Discard this pass and style it correctly in the next one. + self.ctx() + .request_discard("Widget style depends on a widget response we don't have yet"); + WidgetState::default() + }; self.get_widget_style::(&StyleArgs { classes,