From beb45202812dd2a2714d744060bcbcc8166f6c48 Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 02:58:54 +0000 Subject: [PATCH] ui: size a split button's chevron half from the control height --- crates/ui/src/menu.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/ui/src/menu.rs b/crates/ui/src/menu.rs index 6adb20e61..5fb53bdc4 100644 --- a/crates/ui/src/menu.rs +++ b/crates/ui/src/menu.rs @@ -109,8 +109,9 @@ pub fn overflow(ui: &mut Ui, items: &[MenuItem], labels: &MenuLabels) -> Option< items_of(&hit, items) } -/// Width of a split button's chevron half. -const CHEVRON_WIDTH: f32 = 24.0; +/// Width of a split button's chevron half, as a share of the control height, so it follows +/// density. +const CHEVRON_WIDTH_PER_HEIGHT: f32 = 0.8; /// A primary action with a chevron beside it. /// @@ -158,7 +159,8 @@ pub fn split_named(ui: &mut Ui, primary: &str, name: &str, items: &[MenuItem], l .scope(|ui| { ui.spacing_mut().button_padding.x = 0.0; let corner = if backwards { outer } else { inner }; - ui.add(egui::Button::new("").min_size(egui::vec2(CHEVRON_WIDTH, 0.0)).corner_radius(corner)) + let width = ui.spacing().interact_size.y * CHEVRON_WIDTH_PER_HEIGHT; + ui.add(egui::Button::new("").min_size(egui::vec2(width, 0.0)).corner_radius(corner)) }) .inner; // `chevron` paints 9 points in from the rect's right edge; centre it.