Add `Spacing::menu_width` (#3973)

Let users pick default menu width
This commit is contained in:
Emil Ernerfeldt 2024-02-05 11:53:24 +01:00 committed by GitHub
parent 7a6d80cc8c
commit a5f3881d59
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View File

@ -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

View File

@ -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,
@ -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,
@ -1458,6 +1462,7 @@ impl Spacing {
icon_width_inner,
icon_spacing,
tooltip_width,
menu_width,
indent_ends_with_horizontal_line,
combo_height,
scroll,
@ -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",