Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Make the space between popup menu rows part of the rows. (#4624)

Vikram Bhaskarand825840bce80
diff --git a/crates/ui-egui/src/widgets.rs b/crates/ui-egui/src/widgets.rs
index a9559dd63..32f5cd457 100644
--- a/crates/ui-egui/src/widgets.rs
+++ b/crates/ui-egui/src/widgets.rs
@@ -17,6 +17,9 @@ pub use type_ahead::list_open as dropdown_list_open;
/// The setting is local to this popup's Ui and leaves other themes unchanged.
pub fn style_spectrum_popup_menu(ui: &mut Ui) {
let t = Tokens::get(ui.ctx());
+ // The 6 pt gap between rows was outside both buttons, so a drag across a menu
+ // dropped the highlight (#4602). Padding stays inside the row, which is the hit target.
+ ui.spacing_mut().item_spacing.y = 0.0;
if !t.pro {
return;
}
@@ -26,7 +29,9 @@ pub fn style_spectrum_popup_menu(ui: &mut Ui) {
v.widgets.hovered.bg_fill = t.accent;
v.widgets.hovered.fg_stroke = Stroke::new(1.0, Color32::WHITE);
v.widgets.hovered.bg_stroke = Stroke::NONE;
- v.widgets.hovered.corner_radius = CornerRadius::same(3);
+ v.widgets.inactive.corner_radius = CornerRadius::ZERO;
+ v.widgets.hovered.corner_radius = CornerRadius::ZERO;
+ v.widgets.active.corner_radius = CornerRadius::ZERO;
}
/// An accent insertion line on one edge of `r` while a drag hovers it (vertical: on its left or,
@@ -1751,6 +1756,7 @@ mod tests {
let original_padding = ui.spacing().button_padding;
let original_hover = ui.visuals().widgets.hovered.fg_stroke;
super::style_spectrum_popup_menu(ui);
+ assert_eq!(ui.spacing().item_spacing.y, 0.0, "{kind:?}: menu rows meet so the gap is selectable");
if tokens.pro {
assert_eq!(ui.spacing().button_padding, egui::vec2(10.0, 4.0));
assert_eq!(ui.visuals().widgets.hovered.bg_fill, tokens.accent);