-
Notifications
You must be signed in to change notification settings - Fork 2k
[REGRESSION] in visuals scoping: ui.set_visuals affects entire app since v0.34.1 #8074
Description
Describe the bug
After upgrading to egui 0.34.1, I am unable to maintain two different visual styles (e.g., a blue sidebar and a white main panel) within the same frame. Even when wrapping the style changes inside a ui.scope or ui.child_ui, the last call to a visuals-changing function seems to "leak" or override the global context, causing the entire application to adopt the last defined style.
In previous versions, I could successfully isolate these styles.
To Reproduce
I am using a pattern similar to this but separated in different modules mainpanel.rs and menu.rs (called in order menu.rs first and mainpanel.rs as last) in the 0.34.1:
// Sidebar with blue background
egui::Panel::left("side_panel").show_inside(ui, |ui| {
ui.scope(|ui| {
// UiVisuals is a module that provide a built and personalized egui::Visuals Struct
ui.set_visuals(UiVisuals::panel_visuals());
ui.label("This should be on a blue background");
});
});
// Main content with white background
egui::CentralPanel::default().show_inside(ui, |ui| {
ui.scope(|ui| {
ui.set_visuals(UiVisuals::default_visuals());
ui.label("This should be on a white background");
});
});and I was using this method in 0.33.3, although the set visual is outside the designated UI I was still able to isolate the color change to the panel I wanted:
// Sidebar with blue background
// UiVisuals is a module that provide a built and personalized egui::Visuals Struct
ctx.set_visuals(UiVisuals::panel_visuals());
egui::SidePanel::left("side_panel").show(ctx, |ui| {
ui.label("This should be on a blue background");
});
// Main content with white background
ctx.set_visuals(UiVisuals::default_visuals());
egui::CentralPanel::default().show(ctx, |ui| {
ui.label("This should be on a white background");
});Expected behavior
The SidePanel should remain blue and the CentralPanel should remain white. Instead, the entire app (including the sidebar) turns white because the CentralPanel logic runs last.
Environment
egui version: 0.34.1
Platform: WASM
OS: Linux NixOS
Additional context
It seems that ui.style_mut().visuals or ctx.set_visuals() is no longer strictly scoped when called inside panels or scopes, or there is a conflict in how panel_fill is inherited during the layout pass.