HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
semantic_color.hpp
Go to the documentation of this file.
1// Copyright Take Vos 2022.
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
9#pragma once
10
11#include "../utility/module.hpp"
12#include <array>
13
14namespace hi {
15inline namespace v1 {
16
20enum class semantic_color : unsigned char {
21 blue,
22 green,
23 indigo,
24 orange,
25 pink,
26 purple,
27 red,
28 teal,
29 yellow,
30
31 gray,
32 gray2,
33 gray3,
34 gray4,
35 gray5,
36 gray6,
37
38 foreground,
39 border,
40 fill,
41 accent,
42 text_select,
43 primary_cursor,
44 secondary_cursor,
45};
46
47// clang-format off
48constexpr auto semantic_color_metadata = enum_metadata{
49 semantic_color::blue, "blue",
50 semantic_color::green, "green",
51 semantic_color::indigo, "indigo",
52 semantic_color::orange, "orange",
53 semantic_color::pink, "pink",
54 semantic_color::purple, "purple",
55 semantic_color::red, "red",
56 semantic_color::teal, "teal",
57 semantic_color::yellow, "yellow",
58 semantic_color::gray, "gray",
59 semantic_color::gray2, "gray2",
60 semantic_color::gray3, "gray3",
61 semantic_color::gray4, "gray4",
62 semantic_color::gray5, "gray5",
63 semantic_color::gray6, "gray6",
64 semantic_color::foreground, "foreground",
65 semantic_color::border, "border",
66 semantic_color::fill, "fill",
67 semantic_color::accent, "accent",
68 semantic_color::text_select, "text-select",
69 semantic_color::primary_cursor, "primary-cursor",
70 semantic_color::secondary_cursor, "secondary-cursor",
71};
72
73// clang-format on
74
79[[nodiscard]] inline std::string_view to_string(semantic_color rhs) noexcept
80{
81 return semantic_color_metadata[rhs];
82}
83
84
89[[nodiscard]] inline semantic_color semantic_color_from_string(std::string_view str)
90{
91 return semantic_color_metadata[str];
92}
93
94}} // namespace hi::inline v1
95
96template<typename CharT>
97struct std::formatter<hi::semantic_color, CharT> : std::formatter<std::string_view, CharT> {
98 auto format(hi::semantic_color const &t, auto &fc)
99 {
100 return std::formatter<std::string_view, CharT>::format(hi::semantic_color_metadata[t], fc);
101 }
102};
103
constexpr std::string to_string(std::u32string_view rhs) noexcept
Conversion from UTF-32 to UTF-8.
Definition to_string.hpp:215
semantic_color semantic_color_from_string(std::string_view str)
Convert a string to a semantic color.
Definition semantic_color.hpp:89
semantic_color
Semantic colors.
Definition semantic_color.hpp:20
DOXYGEN BUG.
Definition algorithm.hpp:13
geometry/margins.hpp
Definition cache.hpp:11