mirror of
https://github.com/storytold/photocraft.git
synced 2026-11-14 14:12:44 +00:00
The Pro toolbar drew each tool glyph at 16 px in a 30 px button (the generic icon-button proportion), which reads small and thin next to Photoshop's toolbar. Pro themes now draw tool glyphs at 20 px; the other themes keep the icon-button size. Claude-Session: https://claude.ai/code/session_01CVtZHu998NDhf4Z8QvS5pd Co-authored-by: ngrafton2006 <ngrafton2006@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Brandon Thomas <echelon@gmail.com>
This commit is contained in:
1 file changed
+16
-1
@@ -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)]
|
||||
|
||||
Reference in new issue
Block a user