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/utility.hpp"
12#include "../macros.hpp"
13#include <array>
14
15
16
17namespace hi {
18inline namespace v1 {
19
23enum class semantic_color : unsigned char {
24 blue,
25 green,
26 indigo,
27 orange,
28 pink,
29 purple,
30 red,
31 teal,
32 yellow,
33
34 gray,
35 gray2,
36 gray3,
37 gray4,
38 gray5,
39 gray6,
40
41 foreground,
42 border,
43 fill,
44 accent,
45 text_select,
46 primary_cursor,
47 secondary_cursor,
48};
49
50// clang-format off
51constexpr auto semantic_color_metadata = enum_metadata{
52 semantic_color::blue, "blue",
53 semantic_color::green, "green",
54 semantic_color::indigo, "indigo",
55 semantic_color::orange, "orange",
56 semantic_color::pink, "pink",
57 semantic_color::purple, "purple",
58 semantic_color::red, "red",
59 semantic_color::teal, "teal",
60 semantic_color::yellow, "yellow",
61 semantic_color::gray, "gray",
62 semantic_color::gray2, "gray2",
63 semantic_color::gray3, "gray3",
64 semantic_color::gray4, "gray4",
65 semantic_color::gray5, "gray5",
66 semantic_color::gray6, "gray6",
67 semantic_color::foreground, "foreground",
68 semantic_color::border, "border",
69 semantic_color::fill, "fill",
70 semantic_color::accent, "accent",
71 semantic_color::text_select, "text-select",
72 semantic_color::primary_cursor, "primary-cursor",
73 semantic_color::secondary_cursor, "secondary-cursor",
74};
75
76// clang-format on
77
82[[nodiscard]] inline std::string_view to_string(semantic_color rhs) noexcept
83{
84 return semantic_color_metadata[rhs];
85}
86
87
92[[nodiscard]] inline semantic_color semantic_color_from_string(std::string_view str)
93{
94 return semantic_color_metadata[str];
95}
96
97}} // namespace hi::inline v1
98
99template<typename CharT>
100struct std::formatter<hi::semantic_color, CharT> : std::formatter<std::string_view, CharT> {
101 auto format(hi::semantic_color const &t, auto &fc) const
102 {
103 return std::formatter<std::string_view, CharT>::format(hi::semantic_color_metadata[t], fc);
104 }
105};
106
semantic_color semantic_color_from_string(std::string_view str)
Convert a string to a semantic color.
Definition semantic_color.hpp:92
semantic_color
Semantic colors.
Definition semantic_color.hpp:23
DOXYGEN BUG.
Definition algorithm.hpp:16
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377