Public Functions
| VTheme() | |
| VTheme(const int & name, const nlohmann::ordered_json & value) | |
| const int & | name() |
| const int & | publisher() |
| const int & | type() |
| int | display_id() |
| const int * | value(const int & attr) |
| std::string | color(const int & attr) |
| const int & | canonical_defaults() |
Detailed Description
Color theme loaded from one theme .json file, holding its palette and
the publisher that tells it apart from other themes with the same name.
VPlatform::init() loads a VTheme from each file
in the themes folder, and
VPlatform::add_theme_json() loads one
that the user imports. VApp::themes() lists them by
display_id(), which is also the id that an app saves to remember the
user's theme choice.
A theme file holds one theme under its name. The _meta object fills
publisher() and type(), and every other key is a palette value, read
with value() or color():
{
"Sunset": {
"_meta": { "publisher": "example", "type": "dark" },
"Foreground": "#ffe8d6",
"Gradient.Start": 0,
"Gradient.Start Color": "#ff9e57",
"Gradient.End": 1,
"Gradient.End Color": "#d96c4f",
"Primary": "#332027",
"Secondary": "#291a20",
"Tertiary": "#4a2b33"
}
}
The palette keys are the attribute names of the Theme layer, which
styles link to as Theme/Primary and so on. When a theme becomes active,
its values replace those attributes, and an attribute that the theme
leaves out takes its value from canonical_defaults().
A gradient can also be one "Gradient" array of two "position:color"
stops, like ["0:#ff9e57", "1:#d96c4f"]. It loads as the four
Gradient.* values above, so value("Gradient") returns nullptr.
Member Function Documentation
VTheme()
No description available.
VTheme(const int & name, const nlohmann::ordered_json & value)
Loads the theme from value, the object under name in a theme file.
A value that isn't a JSON object loads as a theme with only a name.
const int & name()
No description available.
const int & publisher()
Returns the publisher, like "example", or "" when _meta has none.
const int & type()
Returns "dark" or "light", whichever the palette reads as, or "" when
_meta has no type.
int display_id()
Returns the id that tells this theme apart, like "Sunset (example)".
The id is the name with the publisher in parentheses. Without a
publisher, the _meta object's uuid takes its place, and without
either, the id is the name alone.
const int * value(const int & attr)
Returns the palette value for attr, like "Primary", or nullptr
when this theme leaves it out.
std::string color(const int & attr)
Returns the palette color for attr, like "#332027", or "" when this
theme leaves it out or its value isn't a string.
const int & canonical_defaults()
Returns each attribute of the Theme layer with its default value,
like { "Primary", "#36393f" }, in the order that
styles/mounts/vtheme.lyr declares them.
These defaults match the ones in vtheme.lyr, so a change to one
needs the same change in the other.