Checked in real system dark and light mode on macOS (SkyLight theme switch on the M1, restored afterwards), Windows 11 (the app-mode setting, run on the VM's desktop) and Linux (Adwaita and Adwaita:dark), measuring each screenshot's text against its background with the WCAG contrast formula. The app's own colours fell short on every platform. The fixed firmware hues were 2.6 to 3.9:1 (LuxOS gold and ePIC blue on light, Alkane navy, Braiins purple and Bixbit red on dark). The hashrate greens and temperature purples were about 4:1, and the play/pause icons about 2:1 on light buttons. - readable()/readable_at(): nudge a colour toward black (light theme) or white (dark theme), keeping its hue, until it reaches 4.5:1 for text (3:1 for icons) against every given background. - palette(): green/amber/red/accent/label are made readable against the window, the zebra row and the KPI card; Palette::text() guards every computed cell colour (ratio and temperature blends, firmware hues). - Media button icons: at least 3:1 against the theme's button face. - macOS snapshot (wx-rs patch 0011): capture the window's frame view. The content view alone left unpainted areas transparent, which read as a white toolbar strip in dark mode. On screen the area was always the dark window colour. After the change, no app-coloured text is below 4.5:1 in any of the six theme/platform combinations. What the checker still flags is theme chrome (grid lines, GTK header labels, button outlines, the zoom slider) and anti-aliasing on thin fonts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BdKQBRg6YCM1XXQCTnD5GF
65 lines
2.4 KiB
Plaintext
65 lines
2.4 KiB
Plaintext
// osx_native.mm -- alkane-toolkit extension: the few wxOSX/Cocoa calls the
|
|
// bridge needs that wx does not wrap. Compiled on macOS only (see build.rs).
|
|
|
|
#include <wx/wx.h>
|
|
#include <wx/dataview.h>
|
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
// The NSTableView (NSOutlineView) behind a wxDataViewCtrl. wx's handle is the
|
|
// enclosing NSScrollView.
|
|
static NSTableView* TableOf(wxWindow* win) {
|
|
if (!win) return nil;
|
|
id h = (id)win->GetHandle();
|
|
if ([h isKindOfClass:[NSTableView class]]) return (NSTableView*)h;
|
|
if ([h isKindOfClass:[NSScrollView class]]) {
|
|
id doc = [(NSScrollView*)h documentView];
|
|
if ([doc isKindOfClass:[NSTableView class]]) return (NSTableView*)doc;
|
|
}
|
|
return nil;
|
|
}
|
|
|
|
extern "C" {
|
|
|
|
// Native alternating-row backgrounds. AppKit paints them under every cell,
|
|
// custom-drawn ones included, in the theme's own colours (light and dark), so
|
|
// custom renderers never paint row backgrounds on macOS.
|
|
void wxbr_osx_set_alternating_rows(void* win, int on) {
|
|
NSTableView* tv = TableOf((wxWindow*)win);
|
|
if (tv) [tv setUsesAlternatingRowBackgroundColors:(on ? YES : NO)];
|
|
}
|
|
|
|
// Write a PNG of a top-level window's content, rendered by the app itself
|
|
// (no screen-recording permission needed). Used by the self-test with
|
|
// ALKANE_SNAPSHOT=path to check what the table really draws. Returns 1 on
|
|
// success.
|
|
int wxbr_osx_snapshot(void* win, const char* path) {
|
|
wxWindow* w = (wxWindow*)win;
|
|
if (!w || !path) return 0;
|
|
wxTopLevelWindow* tlw = wxDynamicCast(wxGetTopLevelParent(w), wxTopLevelWindow);
|
|
if (!tlw) return 0;
|
|
tlw->Show();
|
|
tlw->Raise();
|
|
// Let the window lay out and paint before capturing it.
|
|
for (int i = 0; i < 30; ++i) {
|
|
wxYield();
|
|
wxMilliSleep(30);
|
|
}
|
|
NSWindow* nsw = (NSWindow*)tlw->GetWXWindow();
|
|
// The content view's superview (the window's frame view) also draws the
|
|
// window background and title bar. The content view alone leaves every
|
|
// area the app's panels do not paint transparent, which read as white.
|
|
NSView* view = [[nsw contentView] superview];
|
|
if (!view) view = [nsw contentView];
|
|
if (!view) return 0;
|
|
NSRect rect = [view bounds];
|
|
NSBitmapImageRep* rep = [view bitmapImageRepForCachingDisplayInRect:rect];
|
|
if (!rep) return 0;
|
|
[view cacheDisplayInRect:rect toBitmapImageRep:rep];
|
|
NSData* png = [rep representationUsingType:NSBitmapImageFileTypePNG properties:@{}];
|
|
if (!png) return 0;
|
|
return [png writeToFile:[NSString stringWithUTF8String:path] atomically:YES] ? 1 : 0;
|
|
}
|
|
|
|
}
|