HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
theme_mode.hpp
1// Copyright Take Vos 2020.
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 "../required.hpp"
8#include "../assert.hpp"
9#include <string>
10#include <ostream>
11
12namespace tt {
13
14enum class theme_mode { light, dark };
15
16[[nodiscard]] constexpr char const *to_const_string(theme_mode rhs) noexcept
17{
18 switch (rhs) {
19 case theme_mode::light: return "light";
20 case theme_mode::dark: return "dark";
21 default: tt_no_default();
22 }
23}
24
25[[nodiscard]] inline std::string to_string(theme_mode rhs) noexcept
26{
27 return to_const_string(rhs);
28}
29
30inline std::ostream &operator<<(std::ostream &lhs, theme_mode rhs)
31{
32 return lhs << to_const_string(rhs);
33}
34
35theme_mode read_os_theme_mode() noexcept;
36
37} // namespace tt
38
39namespace std {
40
41template<typename CharT>
42struct std::formatter<tt::theme_mode, CharT> : std::formatter<char const *, CharT> {
43 auto format(tt::theme_mode const &t, auto &fc)
44 {
45 return std::formatter<char const *, CharT>::format(tt::to_const_string(t), fc);
46 }
47};
48
49} // namespace std
STL namespace.
T to_string(T... args)