fix(ui): unify Spectrum menu spacing and hover contrast (#2323)

* fix(ui): unify Spectrum popup padding and hover contrast (#2187)

* fix(ui): unify Spectrum popup padding and hover contrast (#2187)

* fix(ui): unify Spectrum popup padding and hover contrast (#2187)

* fix(ui): unify Spectrum popup padding and hover contrast (#2187)

* fix(ui): unify Spectrum popup padding and hover contrast (#2187)

* fix(ui): remove unused menu token after sharing popup style

* test(ui): cover Spectrum popup hover contrast and theme isolation

* cargo fmt

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Brandon Thomas <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
This commit is contained in:
authored and GitHub committed 2026-10-10 14:00:56 -04:00
1 parent fa33712dd3
commit cebdbb21ea
5 files changed
+45 -10

No files matched your search

+1
View File
@@ -143,6 +143,7 @@ pub fn status_bar_pro(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
icons::paint(ui, r, "chevron-right", 11.0, t.text_dim);
let resp = resp.on_hover_text(tl!("Show"));
egui::Popup::menu(&resp).show(|ui| {
crate::widgets::style_spectrum_popup_menu(ui);
ui.set_min_width(200.0);
for (key, label) in STATUS_INFO {
let on = app.ui.chrome.status_info == *key;
+1
View File
@@ -468,6 +468,7 @@ pub fn show(app: &mut PhotocraftApp, ui: &mut egui::Ui, shown: &[Group], mut bod
ui.ctx().set_cursor_icon(egui::CursorIcon::Grabbing);
}
egui::Popup::menu(&resp.menu).show(|ui| {
crate::widgets::style_spectrum_popup_menu(ui);
ui.set_min_width(170.0);
if tabs.get(sel) == Some(&"Layers") {
crate::layer_row_ui::panel_menu(app, ui);
+2 -10
View File
@@ -1227,7 +1227,6 @@ fn render_level(ui: &mut egui::Ui, items: &[&MenuItem], depth: usize, clicked: &
const MENU_SEPARATOR: f32 = 9.0;
fn render_level_rows(ui: &mut egui::Ui, items: &[&MenuItem], depth: usize, clicked: &mut Option<String>, nav: &mut crate::menu_nav::Nav) {
let t = crate::theme::Tokens::get(ui.ctx());
let lang = crate::i18n::current();
// Items never wrap: the menu widens to its longest label plus shortcut (translations can be
// longer than the English).
@@ -1235,15 +1234,8 @@ fn render_level_rows(ui: &mut egui::Ui, items: &[&MenuItem], depth: usize, click
// Rows touch, as in native menus: the dialog spacing between them made long menus a fifth
// taller than they need to be (#402).
ui.spacing_mut().item_spacing.y = 0.0;
if t.pro {
// Spectrum/macOS menus: blue highlight row with white text.
let v = &mut ui.style_mut().visuals;
v.widgets.hovered.weak_bg_fill = t.accent;
v.widgets.hovered.bg_fill = t.accent;
v.widgets.hovered.fg_stroke = egui::Stroke::new(1.0, egui::Color32::WHITE);
v.widgets.hovered.corner_radius = egui::CornerRadius::same(3);
ui.spacing_mut().button_padding = egui::vec2(10.0, 4.0);
}
// Secondary menus use the exact same Spectrum hover contrast and spacing.
crate::widgets::style_spectrum_popup_menu(ui);
// Walk in Photoshop order: leaves and separators at this depth; a submenu appears at the position
// of its first child.
let mut shown_subs: Vec<&str> = Vec::new();
+1
View File
@@ -2407,6 +2407,7 @@ fn layer_row(
}
// Right-click context menu.
resp.context_menu(|ui| {
crate::widgets::style_spectrum_popup_menu(ui);
// Right-clicking inside a multi-selection keeps it and acts on every selected layer.
let on_set = row.multi && selected;
if crate::layer_menu_ui::show(app, ui, l, on_set, actions)
+40
View File
@@ -8,6 +8,23 @@ use crate::theme::{self, Tokens};
mod color_count;
pub use color_count::color_count_row;
/// Match the Spectrum application-menu padding and blue/white hover state in
/// secondary menus (status bar, dock hamburger, layer context menus; #2187).
/// 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());
if !t.pro {
return;
}
ui.spacing_mut().button_padding = vec2(10.0, 4.0);
let v = &mut ui.style_mut().visuals;
v.widgets.hovered.weak_bg_fill = t.accent;
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);
}
/// An accent insertion line on one edge of `r` while a drag hovers it (vertical: on its left or,
/// `after`, right edge; else on its top or bottom).
pub fn drop_line(ui: &Ui, r: Rect, after: bool, vertical: bool, t: &Tokens) {
@@ -1145,6 +1162,29 @@ fn clean(text: &str) -> String {
#[cfg(test)]
mod tests {
use egui::{Key, Modifiers};
#[test]
fn spectrum_popup_style_matches_main_menu_and_preserves_studio() {
for kind in [crate::theme::ThemeKind::Pro, crate::theme::ThemeKind::ProMedium, crate::theme::ThemeKind::Studio, crate::theme::ThemeKind::StudioLight] {
let ctx = egui::Context::default();
crate::theme::apply(&ctx, kind);
let tokens = crate::theme::Tokens::for_kind(kind);
let mut out = ctx.run_ui(Default::default(), |ui| {
let original_padding = ui.spacing().button_padding;
let original_hover = ui.visuals().widgets.hovered.fg_stroke;
super::style_spectrum_popup_menu(ui);
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);
assert_eq!(ui.visuals().widgets.hovered.fg_stroke.color, egui::Color32::WHITE);
} else {
assert_eq!(ui.spacing().button_padding, original_padding);
assert_eq!(ui.visuals().widgets.hovered.fg_stroke, original_hover);
}
});
out.textures_delta.clear();
}
}
use egui_kittest::{Harness, kittest::Queryable};
/// Sets up a test with one value field. Its state is its value and how many times it changed.