Skip to content
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
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions crates/egui/src/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@ impl std::ops::DerefMut for BarState {
}

fn set_menu_style(style: &mut Style) {
style.spacing.button_padding = vec2(2.0, 0.0);
style.visuals.widgets.active.bg_stroke = Stroke::NONE;
style.visuals.widgets.hovered.bg_stroke = Stroke::NONE;
style.visuals.widgets.inactive.weak_bg_fill = Color32::TRANSPARENT;
style.visuals.widgets.inactive.bg_stroke = Stroke::NONE;
if style.compact_menu_style {
style.spacing.button_padding = vec2(2.0, 0.0);
style.visuals.widgets.active.bg_stroke = Stroke::NONE;
style.visuals.widgets.hovered.bg_stroke = Stroke::NONE;
style.visuals.widgets.inactive.weak_bg_fill = Color32::TRANSPARENT;
style.visuals.widgets.inactive.bg_stroke = Stroke::NONE;
}
}

/// The menu bar goes well in a [`crate::TopBottomPanel::top`],
Expand Down
7 changes: 7 additions & 0 deletions crates/egui/src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,9 @@ pub struct Style {

/// The animation that should be used when scrolling a [`crate::ScrollArea`] using e.g. [`Ui::scroll_to_rect`].
pub scroll_animation: ScrollAnimation,

/// Use a more compact style for menus.
pub compact_menu_style: bool,
}

#[test]
Expand Down Expand Up @@ -1277,6 +1280,7 @@ impl Default for Style {
url_in_tooltip: false,
always_scroll_the_only_direction: false,
scroll_animation: ScrollAnimation::default(),
compact_menu_style: true,
}
}
}
Expand Down Expand Up @@ -1578,6 +1582,7 @@ impl Style {
url_in_tooltip,
always_scroll_the_only_direction,
scroll_animation,
compact_menu_style,
} = self;

crate::Grid::new("_options").show(ui, |ui| {
Expand Down Expand Up @@ -1683,6 +1688,8 @@ impl Style {
#[cfg(debug_assertions)]
ui.collapsing("🐛 Debug", |ui| debug.ui(ui));

ui.checkbox(compact_menu_style, "Compact menu style");

ui.checkbox(explanation_tooltips, "Explanation tooltips")
.on_hover_text(
"Show explanatory text when hovering DragValue:s and other egui widgets",
Expand Down
Loading