HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
theme_color.hpp
1// Copyright Take Vos 2021.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "theme_text_style.hpp"
8#include "../exception.hpp"
9#include <array>
10
11namespace hi::inline v1 {
12
13enum class theme_color : unsigned char {
14 blue,
15 green,
16 indigo,
17 orange,
18 pink,
19 purple,
20 red,
21 teal,
22 yellow,
23
24 gray,
25 gray2,
26 gray3,
27 gray4,
28 gray5,
29 gray6,
30
31 foreground,
32 border,
33 fill,
34 accent,
35 text_select,
36 primary_cursor,
37 secondary_cursor,
38
39 _size
40};
41
42constexpr std::size_t num_theme_colors = static_cast<std::size_t>(theme_color::_size);
43
44constexpr auto saturated_theme_colors = std::array{
45 theme_color::blue,
46 theme_color::green,
47 theme_color::indigo,
48 theme_color::orange,
49 theme_color::pink,
50 theme_color::purple,
51 theme_color::red,
52 theme_color::teal,
53 theme_color::yellow,
54 theme_color::accent};
55
56
57[[nodiscard]] inline theme_color theme_color_from_string(std::string_view str)
58{
59 if (str == "blue") {
60 return theme_color::blue;
61 } else if (str == "green") {
62 return theme_color::green;
63 } else if (str == "indigo") {
64 return theme_color::indigo;
65 } else if (str == "orange") {
66 return theme_color::orange;
67 } else if (str == "pink") {
68 return theme_color::pink;
69 } else if (str == "purple") {
70 return theme_color::purple;
71 } else if (str == "red") {
72 return theme_color::red;
73 } else if (str == "teal") {
74 return theme_color::teal;
75 } else if (str == "yellow") {
76 return theme_color::yellow;
77 } else if (str == "gray") {
78 return theme_color::gray;
79 } else if (str == "gray2") {
80 return theme_color::gray2;
81 } else if (str == "gray3") {
82 return theme_color::gray3;
83 } else if (str == "gray4") {
84 return theme_color::gray4;
85 } else if (str == "gray5") {
86 return theme_color::gray5;
87 } else if (str == "gray6") {
88 return theme_color::gray6;
89 } else if (str == "foreground") {
90 return theme_color::foreground;
91 } else if (str == "border") {
92 return theme_color::border;
93 } else if (str == "fill") {
94 return theme_color::fill;
95 } else if (str == "accent") {
96 return theme_color::accent;
97 } else if (str == "text_select") {
98 return theme_color::text_select;
99 } else if (str == "primary_cursor") {
100 return theme_color::primary_cursor;
101 } else if (str == "secondary_cursor") {
102 return theme_color::secondary_cursor;
103 } else {
104 throw parse_error(std::format("Unknown theme color '{}'", str));
105 }
106}
107
108} // namespace hi::inline v1
T fill(T... args)