diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index 6fc11515fe..bde5b84bbc 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -148,7 +148,7 @@ pub fn toolbar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { let sel = slot.contains(&app.ui.tool); let tip = if tool.key() == '\0' { tl!(tool.label()).to_string() } else { format!("{} ({})", tl!(tool.label()), tool.key()) }; - let resp = icons::button(ui, icons::tool_icon(tool), bx, sel, &tip); + let resp = icons::button_with_icon_size(ui, icons::tool_icon(tool), bx, toolbar_icon_size(bx, t.pro), sel, &tip); if slot.len() > 1 { paint_toolbar_flyout_indicator(ui, &t, &resp); } @@ -309,6 +309,12 @@ pub fn toolbar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { ); } +/// Glyph size of a toolbar tool button. Pro fills two thirds of the button, close to Photoshop's +/// toolbar glyphs (#2665); the other themes keep the general icon-button proportion. +fn toolbar_icon_size(box_size: f32, pro: bool) -> f32 { + (box_size * if pro { 2.0 / 3.0 } else { 0.52 }).round() +} + /// Paints a triangle on the bottom right corner of an icon button to indicate that a toolbar item has a submenu. pub fn paint_toolbar_flyout_indicator(ui: &mut egui::Ui, tokens: &Tokens, resp: &egui::Response) { let r = resp.rect; @@ -4268,6 +4274,15 @@ mod type_flyout_tests { assert_eq!(*hand, [Tool::Hand, Tool::RotateView]); assert_eq!(Tool::RotateView.key(), 'R'); } + + #[test] + fn pro_toolbar_glyphs_fill_two_thirds_of_the_button() { + // #2665: Photoshop-style themes draw tool glyphs larger than other icon buttons. + assert_eq!(toolbar_icon_size(30.0, true), 20.0); + assert_eq!(toolbar_icon_size(36.0, false), (36.0f32 * 0.52).round(), "other themes keep the icon-button size"); + // The glyph stays inside the button with room for the flyout triangle's corner. + assert!(toolbar_icon_size(30.0, true) <= 30.0 - 2.0 * 4.0); + } } #[cfg(test)]