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"
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 int margin = 5;
38
41 int border_width = 1;
42
45 int rounding_radius = 4;
46
49 int size = 11;
50
53 int large_size = 19;
54
57 int icon_size = 8;
58
61 int large_icon_size = 23;
62
65 int label_icon_size = 15;
66
69 int baseline_adjustment = 9;
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]] long long parse_long_long(datum const& data, char const *object_name);
107 [[nodiscard]] int parse_int(datum const& data, char const *object_name);
108 [[nodiscard]] bool parse_bool(datum const& data, char const *object_name);
109 [[nodiscard]] std::string parse_string(datum const& data, char const *object_name);
110 [[nodiscard]] hi::color parse_color_value(datum const& data);
111 [[nodiscard]] hi::color parse_color(datum const& data, char const *object_name);
112 [[nodiscard]] std::vector<hi::color> parse_color_list(datum const& data, char const *object_name);
113 [[nodiscard]] hi::text_style parse_text_style_value(hi::font_book const& font_book, datum const& data);
114 [[nodiscard]] font_weight parse_font_weight(datum const& data, char const *object_name);
115 [[nodiscard]] hi::text_style parse_text_style(hi::font_book const& font_book, datum const& data, char const *object_name);
116 void parse(hi::font_book const& font_book, datum const& data);
117
118 [[nodiscard]] friend std::string to_string(theme const& rhs) noexcept
119 {
120 return std::format("{}:{}", rhs.name, rhs.mode);
121 }
122
123 friend std::ostream& operator<<(std::ostream& lhs, theme const& rhs)
124 {
125 return lhs << to_string(rhs);
126 }
127};
128
129} // namespace hi::inline v1
Utilities used by the HikoGUI library itself.
Defined the geo::extent, extent2 and extent3 types.
STL namespace.
DOXYGEN BUG.
Definition algorithm.hpp:15
font_weight
Definition font_weight.hpp:17
geometry/margins.hpp
Definition assert.hpp:18
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:176