Repository navigation
themes: an app can contribute its own and name the default - #1216
Open
MichaelBelousov wants to merge 2 commits into
Open
MichaelBelousov wants to merge 2 commits into
MichaelBelousov wants to merge 2 commits into
Conversation
Two options an app built on fizzy passes in its dependency invocation, following `-Dapp-layout`: `-Dapp-theme` is a LazyPath to a file with `pub fn add(gpa, themes: *std.ArrayList(dvui.Theme)) !void`; the editor appends its themes beside the user's, before fizzy's own, so an app's themes sit at the top of the picker. The module wires into the executable's root, the web build's, and the test module, each only when the build was given it (the editor's `has_app_theme` branch is comptime-off otherwise, so the import is never analyzed). `-Dapp-default-theme` names the theme a fresh settings store starts with (`Settings.default_theme`). It is a name, checked against what the editor registers; a name nothing registered logs and falls back to the first entry, as a stored theme that no longer exists does.
Contributor
Author
|
hmmm I actually wanted to do this at runtime... will try again EDIT: done |
`Host.registerTheme(owner, theme)`, called while a plugin registers: the editor appends the theme beside the user's and the app's, replacing an entry of the same name in place (so a reloaded plugin updates its theme instead of duplicating it). The Host keeps its own copy of the name and tracks the plugin, the way demos do, so the themes go with the plugin when it retires. The editor pulls them in `postInit` (its own theme apply ran in `init`, before any plugin existed) and again after a web plugin loads, then re-applies the settings theme, so a registered theme lands shaped and sized like the built-ins.
MichaelBelousov
force-pushed
the
app-themes
branch
from
November 15, 2026 19:59
ea49870 to
14d5dbf
Compare
This branch was successfully deployed
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.
An app built on fizzy could not ship its own themes or choose which one a fresh install starts on: the theme set was fizzy's alone (
Editorregistering Fizzy Dark / Light / Strawberry), andSettings.default_themewas the literal"Fizzy Dark". Graphl's port ran into exactly this (fizzyedit/graphl's report item 11) — it carries its own Graphl Dark / Light.Two ways for an app to contribute, following
-Dapp-layout:At runtime, from a plugin (before the first frame):
Host.registerTheme(theme)— the editor appends the theme beside the user's and the app's, replacing an entry of the same name in place (a reloaded plugin updates its theme instead of duplicating it). The host keeps its own copy of the name and tracks the registering plugin, the way demos do; the editor pulls them inpostInit— the editor's own theme apply ran ininit, before any plugin existed — then re-applies font sizes and the settings theme, so a registered theme lands shaped and sized like the built-ins. Plugin reloads and web-plugin loads pull again.Host.setDefaultTheme(name)— what a fresh settings store starts on. The stored setting now seeds empty ("the app decides") instead of seeding the comptime default, so a runtime default actually takes effect: the stored name is only written when the user picks, and the fallback chain at apply time is the stored name, then the runtime default, thenSettings.default_theme.At build time, for an app without plugins:
-Dapp-theme— aLazyPathto a file withpub fn add(gpa, themes: *std.ArrayList(dvui.Theme)) !void; the editor appends its themes beside the user's. The module wires into the executable's root, the web build, and the test module, each only when the build was given it (the editor'shas_app_themebranch is comptime-off otherwise, so the import is never analyzed).-Dapp-default-theme— the comptime fallbackSettings.default_themeuses when no runtime default was set.Fizzy's own build passes neither and behaves exactly as before. Verified with a smoke-test themes file and
-Dapp-default-themeon the native and web builds, the full suite (with a newHost.registerThemetest mirroringregisterDemo's), fmt, and lint.