Rework third-party themes (#3254)

This PR reworks the way we define our third-party themes to make them
work as overlays on top of a base theme.

We introduce the concept of a `UserThemeFamily` that contains
`UserTheme`s. Rather than being an entire theme definition on their own,
a `UserTheme` just contains optional overrides for the values in a
`Theme`.

When resolving a `UserTheme`, we apply it on top of the base theme. Any
values not overridden in the `UserTheme` will fall back to the `Theme`
defaults.

Right now we are just using `UserTheme` to model third-party themes that
we distribute with the Zed binary. However, this same structure can also
be used to import arbitrary user themes (such as from a theme registry,
or even a theme blob from the settings file).

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2023-11-07 17:40:07 +01:00 committed by GitHub
parent 9582a6f317
commit 0d95410634
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 1389 additions and 6000 deletions

View file

@ -0,0 +1,25 @@
use refineable::Refineable;
use serde::Deserialize;
use crate::{Appearance, ThemeColors, ThemeColorsRefinement};
#[derive(Deserialize)]
pub struct UserThemeFamily {
pub name: String,
pub author: String,
pub themes: Vec<UserTheme>,
}
#[derive(Deserialize)]
pub struct UserTheme {
pub name: String,
pub appearance: Appearance,
pub styles: UserThemeStylesRefinement,
}
#[derive(Refineable, Clone)]
#[refineable(deserialize)]
pub struct UserThemeStyles {
#[refineable]
pub colors: ThemeColors,
}