Skip to content
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

Add Spacing::menu_width #3973

Merged
merged 1 commit into from
Feb 5, 2024
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
3 changes: 1 addition & 2 deletions crates/egui/src/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ pub(crate) fn menu_ui<'c, R>(
set_menu_style(ui.style_mut());

let frame = Frame::menu(ui.style()).show(ui, |ui| {
const DEFAULT_MENU_WIDTH: f32 = 150.0; // TODO(emilk): add to ui.spacing
ui.set_max_width(DEFAULT_MENU_WIDTH);
ui.set_max_width(ui.spacing().menu_width);
ui.set_menu_state(Some(menu_state_arc.clone()));
ui.with_layout(Layout::top_down_justified(Align::LEFT), add_contents)
.inner
Expand Down
10 changes: 10 additions & 0 deletions crates/egui/src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@ pub struct Spacing {
/// Width of a tooltip (`on_hover_ui`, `on_hover_text` etc).
pub tooltip_width: f32,

/// The default width of a menu.
pub menu_width: f32,

/// End indented regions with a horizontal line
pub indent_ends_with_horizontal_line: bool,

Expand Down Expand Up @@ -1111,6 +1114,7 @@ impl Default for Spacing {
icon_width_inner: 8.0,
icon_spacing: 4.0,
tooltip_width: 600.0,
menu_width: 150.0,
combo_height: 200.0,
scroll: Default::default(),
indent_ends_with_horizontal_line: false,
Expand Down Expand Up @@ -1458,6 +1462,7 @@ impl Spacing {
icon_width_inner,
icon_spacing,
tooltip_width,
menu_width,
indent_ends_with_horizontal_line,
combo_height,
scroll,
Expand Down Expand Up @@ -1516,6 +1521,11 @@ impl Spacing {
ui.label("Tooltip wrap width");
});

ui.horizontal(|ui| {
ui.add(DragValue::new(menu_width).clamp_range(0.0..=1000.0));
ui.label("Default width of a menu");
});

ui.checkbox(
indent_ends_with_horizontal_line,
"End indented regions with a horizontal separator",
Expand Down
Loading