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#include <string_view>
15#include <format>
16
17hi_export_module(hikogui.color.semantic_color);
18
19hi_export namespace hi {
20inline namespace v1 {
21
25enum class semantic_color : unsigned char {
26 blue,
27 green,
28 indigo,
29 orange,
30 pink,
31 purple,
32 red,
33 teal,
34 yellow,
35
36 gray,
37 gray2,
38 gray3,
39 gray4,
40 gray5,
41 gray6,
42
43 foreground,
44 border,
45 fill,
46 accent,
47 text_select,
48 primary_cursor,
49 secondary_cursor,
50};
51
52// clang-format off
53constexpr auto semantic_color_metadata = enum_metadata{
54 semantic_color::blue, "blue",
55 semantic_color::green, "green",
56 semantic_color::indigo, "indigo",
57 semantic_color::orange, "orange",
58 semantic_color::pink, "pink",
59 semantic_color::purple, "purple",
60 semantic_color::red, "red",
61 semantic_color::teal, "teal",
62 semantic_color::yellow, "yellow",
63 semantic_color::gray, "gray",
64 semantic_color::gray2, "gray2",
65 semantic_color::gray3, "gray3",
66 semantic_color::gray4, "gray4",
67 semantic_color::gray5, "gray5",
68 semantic_color::gray6, "gray6",
69 semantic_color::foreground, "foreground",
70 semantic_color::border, "border",
71 semantic_color::fill, "fill",
72 semantic_color::accent, "accent",
73 semantic_color::text_select, "text-select",
74 semantic_color::primary_cursor, "primary-cursor",
75 semantic_color::secondary_cursor, "secondary-cursor",
76};
77
78// clang-format on
79
84[[nodiscard]] inline std::string_view to_string(semantic_color rhs) noexcept
85{
86 return semantic_color_metadata[rhs];
87}
88
89
94[[nodiscard]] inline semantic_color semantic_color_from_string(std::string_view str)
95{
96 return semantic_color_metadata[str];
97}
98
99}} // namespace hi::inline v1
100
101// XXX #617 MSVC bug does not handle partial specialization in modules.
102hi_export template<>
103struct std::formatter<hi::semantic_color, char> : std::formatter<std::string_view, char> {
104 auto format(hi::semantic_color const &t, auto &fc) const
105 {
106 return std::formatter<std::string_view, char>::format(hi::semantic_color_metadata[t], fc);
107 }
108};
109
semantic_color semantic_color_from_string(std::string_view str)
Convert a string to a semantic color.
Definition semantic_color.hpp:94
semantic_color
Semantic colors.
Definition semantic_color.hpp:25
The HikoGUI namespace.
Definition array_generic.hpp:20
DOXYGEN BUG.
Definition algorithm_misc.hpp:20