Add dark mode support via appearance-aware colour palettes (RFC 0007)#24
Merged
Conversation
Adds first-class light/dark appearance support so frontends can follow the OS appearance without each hardcoding light->dark palette name pairs. The background colour is the primary legibility fix across palettes. Engine / data: - color.dtd: new optional `appearance` (light|dark) and `companion` attributes on the <colors> palette element. - ColorPalette: Appearance enum + AppearanceValue/CompanionName members; GetUIPreviewColors() now falls back to the parent's preview so inheritance-only dark companions show their parent's swatches. - ColorIO: parses appearance/companion (and skips them as colour values). C API (dasher.h / CAPI.cpp): - dasher_get_palette_appearance(): 0=unspecified, 1=light, 2=dark. - dasher_find_companion_palette(): bidirectional lookup (legacy palettes without metadata are still paired via reverse scan). - dasher_set_appearance(): switches to the current palette's matching companion; no-op if already matching; returns -1 and leaves the palette unchanged when no companion exists (respects explicit user choice). Data: dark companions for all eight light palettes (Default, European/Asian Original, European/Asian for Colourblind, Rainbow, Thai, TurboLUT, Vowels, Vowels2). Each inherits its parent's node fills and overrides the background (#1E1E1E) plus background-sitting chrome. Yellow on Blue / Yellow on Black / Blue on Dark Green are already dark and unchanged. Tests: appearance classification, bidirectional companion lookup, and set_appearance round-trip + no-companion case. Full suite green (21/21). Follow-up (noted in RFC 0007 unresolved questions): per-palette contrast tuning where individual letter fills are too dark on #1E1E1E. Signed-off-by: will wade <willwade@gmail.com>
6 tasks
willwade
added a commit
that referenced
this pull request
Jun 20, 2026
…sistence leak (#25) Review feedback (PR #24) identified three problems with the v1 stateless "switch to my companion" design: 1. Persistence bug: dasher_set_appearance called dasher_set_palette, which writes the persistent SP_COLOUR_ID, so the user's explicit palette choice was clobbered by every auto-switch and lost across restarts. 2. No System/Light/Dark mode concept — every frontend had to reinvent the mode toggle. 3. 1:1 companion pairing locked users into (Rainbow <-> Rainbow Dark) with no way to mix e.g. Rainbow light + TurboLUT Dark. This reworks the model to own appearance state at the C API layer (not in the engine Parameters system — appearance is a shell/canvas concern): - dasher_get/set_appearance_mode: SYSTEM (default) / LIGHT / DARK. - dasher_get/set_system_appearance: transient OS appearance input (SYSTEM mode). - dasher_get/set_light_palette + dasher_get/set_dark_palette: two independent persisted preferences (enables mixing). - dasher_set_user_palette: sets the current-side pref and defaults the other side to the chosen palette's companion. - Resolution (mode + system + prefs -> SP_COLOUR_ID) lives in DasherCore and runs at create + on every change, so dasher_get_current_palette always reflects the resolved palette. - State persists to <userDir>/appearance_settings.xml (pugixml sidecar); the preferences — not the transient active palette — are the source of truth, so auto-switching can never overwrite the user's choice (bug #1 fixed). - dasher_set_palette now routes through dasher_set_user_palette so existing pickers stay correct within the model. dasher_set_appearance is removed. Kept (not redundant): the palette appearance/companion XML metadata and dasher_get_palette_appearance / dasher_find_companion_palette — still needed for defaulting the dark preference and grouping the picker. Tests: mode-system, forced-mode, independent-prefs, and a persistence regression that asserts the user's light choice survives a dark auto-switch across a restart. Full suite green (21/21); clang-format clean. RFC text in dasher-project/governance#9 revised to match. Signed-off-by: will wade <willwade@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.