5#include <unordered_map>
17 static_cast<uint8_t
>((hex >> 16) & 0xFF),
18 static_cast<uint8_t
>((hex >> 8) & 0xFF),
19 static_cast<uint8_t
>(hex & 0xFF));
24 static_cast<uint8_t
>((hex >> 24) & 0xFF),
25 static_cast<uint8_t
>((hex >> 16) & 0xFF),
26 static_cast<uint8_t
>((hex >> 8) & 0xFF),
27 static_cast<uint8_t
>(hex & 0xFF));
34 std::unordered_map<std::string, Color>
colors;
36 std::unordered_map<std::string, std::string>
strings;
39 std::optional<Color>
color(
const std::string& name)
const;
42 std::optional<float>
dimension(
const std::string& name)
const;
45 std::optional<std::string>
string_token(
const std::string& name)
const;
67 static std::string
migrate_json(
const std::string& json,
int from_version);
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
@ path
Definition anchor_strategy.hpp:42
Color color_from_hex(uint32_t hex)
Definition theme.hpp:15
canvas::Color Color
Definition theme.hpp:12
Color color_from_hex_alpha(uint32_t hex)
Definition theme.hpp:22
static constexpr Color rgba8(uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)
Construct from 8-bit channels [0,255] — convenience for legacy/hex code.
Definition canvas.hpp:61
std::unordered_map< std::string, std::string > strings
Definition theme.hpp:36
bool save_to_file(const std::string &path) const
Save theme to a JSON file. Returns true on success.
void fill_from(const Theme &base)
Merge with a base theme to fill in any missing tokens.
void apply_overrides(const Theme &overrides)
static Theme from_json(const std::string &json)
static std::string migrate_json(const std::string &json, int from_version)
std::unordered_map< std::string, Color > colors
Definition theme.hpp:34
static constexpr int kSchemaVersion
Definition theme.hpp:57
static int schema_version_of(const std::string &json)
static const std::vector< std::string > & required_color_tokens()
List of required color tokens that every complete theme must define.
std::optional< Color > color(const std::string &name) const
std::optional< float > dimension(const std::string &name) const
std::vector< std::string > missing_tokens() const
Check if this theme has all required tokens. Returns list of missing token names.
std::string to_json() const
std::unordered_map< std::string, float > dimensions
Definition theme.hpp:35
bool is_complete() const
Returns true if this theme defines all required tokens.
std::optional< std::string > string_token(const std::string &name) const
static Theme load_from_file(const std::string &path)
Load theme from a JSON file. Returns empty Theme on failure.