HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
theme.hpp
1// Copyright Take Vos 2020-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
5#pragma once
6
7#include "theme_mode.hpp"
8#include "../text/semantic_text_style.hpp"
9#include "../text/text_style.hpp"
10#include "../utility.hpp"
11#include "../datum.hpp"
12#include "../color/color.hpp"
13#include "../geometry/extent.hpp"
14#include "../subsystem.hpp"
15#include <array>
16#include <filesystem>
17#include <string>
18#include <vector>
19
20namespace hi::inline v1 {
21class font_book;
22
23class theme {
24public:
25 operating_system operating_system = operating_system::windows;
26
29 float dpi = 72;
30
33 float scale = 1.0f;
34
37 float margin = 4.5f;
38
41 float border_width = 1.0f;
42
45 float rounding_radius = 4.0f;
46
49 float size = 11.0f;
50
53 float large_size = 18.5f;
54
57 float icon_size = 7.5f;
58
61 float large_icon_size = 22.5f;
62
65 float label_icon_size = 15.0f;
66
69 float cap_height = 8.6f;
70
71 std::string name;
72 theme_mode mode = theme_mode::light;
73
74 theme() noexcept = default;
75 theme(theme const&) noexcept = default;
76 theme(theme&&) noexcept = default;
77 theme& operator=(theme const&) noexcept = default;
78 theme& operator=(theme&&) noexcept = default;
79
82 theme(hi::font_book const& font_book, std::filesystem::path const& url);
83
94 [[nodiscard]] theme transform(float dpi) const noexcept;
95
96 [[nodiscard]] hi::color color(hi::semantic_color original_color, ssize_t nesting_level = 0) const noexcept;
97 [[nodiscard]] hi::color color(hi::color original_color, ssize_t nesting_level = 0) const noexcept;
98 [[nodiscard]] hi::text_style text_style(semantic_text_style theme_color) const noexcept;
99 [[nodiscard]] hi::text_style text_style(hi::text_style original_style) const noexcept;
100
101private:
102 std::array<std::vector<hi::color>, semantic_color_metadata.size()> _colors;
103 std::array<hi::text_style, semantic_text_style_metadata.size()> _text_styles;
104
105 [[nodiscard]] float parse_float(datum const& data, char const *object_name);
106 [[nodiscard]] bool parse_bool(datum const& data, char const *object_name);
107 [[nodiscard]] std::string parse_string(datum const& data, char const *object_name);
108 [[nodiscard]] hi::color parse_color_value(datum const& data);
109 [[nodiscard]] hi::color parse_color(datum const& data, char const *object_name);
110 [[nodiscard]] std::vector<hi::color> parse_color_list(datum const& data, char const *object_name);
111 [[nodiscard]] hi::text_style parse_text_style_value(hi::font_book const& font_book, datum const& data);
112 [[nodiscard]] font_weight parse_font_weight(datum const& data, char const *object_name);
113 [[nodiscard]] hi::text_style parse_text_style(hi::font_book const& font_book, datum const& data, char const *object_name);
114 void parse(hi::font_book const& font_book, datum const& data);
115
116 [[nodiscard]] friend std::string to_string(theme const& rhs) noexcept
117 {
118 return std::format("{}:{}", rhs.name, rhs.mode);
119 }
120
121 friend std::ostream& operator<<(std::ostream& lhs, theme const& rhs)
122 {
123 return lhs << to_string(rhs);
124 }
125};
126
127} // namespace hi::inline v1
Utilities used by the HikoGUI library itself.
STL namespace.
DOXYGEN BUG.
Definition algorithm.hpp:15
font_weight
Definition font_weight.hpp:17
The HikoGUI namespace.
Definition ascii.hpp:19
This is a RGBA floating point color.
Definition color.hpp:39
A dynamic data type.
Definition datum.hpp:224
Definition theme.hpp:23
font_book keeps track of multiple fonts.
Definition font_book.hpp:31
Definition text_style.hpp:175