Merge pull request 'Media icons: 3:1 against the button colour macOS actually paints' (#28) from media-icon-contrast into main
build-test-release / windows (push) Successful in 5m32s
build-test-release / release (push) Successful in 13m30s

This commit was merged in pull request #28.
This commit is contained in:
2026-11-04 13:31:17 -07:00
+7 -2
View File
@@ -1091,8 +1091,13 @@ pub fn build(frame: Widget) -> App {
// Play / pause / stop as coloured media icons (green / amber / red). Vivid
// fixed colours read well on both light and dark themes.
// The icon colours are kept to at least 3:1 against this theme's button
// face (the fixed hues alone were about 2:1 on light buttons).
let face = [wx_rs::system_color(3)];
// face (the fixed hues alone were about 2:1 on light buttons). Native
// buttons do not all paint the system button-face colour (macOS draws
// #ebebeb on a white window), so also check the window colour and a shade
// 20 steps toward the opposite end.
let win = wx_rs::system_color(0);
let shade = if luminance(win) < 128.0 { 20 } else { -20 };
let face = [wx_rs::system_color(3), win, nudge(win, shade)];
let icon = |c| readable_at(c, &face, MIN_ICON_CONTRAST);
let play_btn = Widget::media_button(panel, ID_PLAY, 0, icon((56, 190, 108)));
ctl.add(play_btn, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_ALL, 2);