HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
theme.hpp
1// Copyright Take Vos 2020-2021.
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 "../required.hpp"
11#include "../URL.hpp"
12#include "../datum.hpp"
13#include "../color/color.hpp"
14#include "../geometry/extent.hpp"
15#include "../subsystem.hpp"
16#include <array>
17
18namespace hi::inline v1 {
19class font_book;
20
21class theme {
22public:
23 operating_system operating_system = operating_system::windows;
24
27 float dpi = 72;
28
31 float scale = 1.0f;
32
35 float margin = 4.5f;
36
39 float border_width = 1.0f;
40
43 float rounding_radius = 4.0f;
44
47 float size = 11.0f;
48
51 float large_size = 18.5f;
52
55 float icon_size = 7.5f;
56
59 float large_icon_size = 22.5f;
60
63 float label_icon_size = 15.0f;
64
67 float cap_height = 8.6f;
68
69 std::string name;
70 theme_mode mode = theme_mode::light;
71
72 theme() noexcept = default;
73 theme(theme const&) noexcept = default;
74 theme(theme&&) noexcept = default;
75 theme& operator=(theme const&) noexcept = default;
76 theme& operator=(theme&&) noexcept = default;
77
80 theme(hi::font_book const& font_book, URL const& url);
81
92 [[nodiscard]] theme transform(float dpi) const noexcept;
93
94 [[nodiscard]] hi::color color(hi::semantic_color original_color, ssize_t nesting_level = 0) const noexcept;
95 [[nodiscard]] hi::color color(hi::color original_color, ssize_t nesting_level = 0) const noexcept;
96 [[nodiscard]] hi::text_style text_style(semantic_text_style theme_color) const noexcept;
97 [[nodiscard]] hi::text_style text_style(hi::text_style original_style) const noexcept;
98
99private:
100 std::array<std::vector<hi::color>, semantic_color_metadata.size()> _colors;
101 std::array<hi::text_style, semantic_text_style_metadata.size()> _text_styles;
102
103 [[nodiscard]] float parse_float(datum const& data, char const *object_name);
104 [[nodiscard]] bool parse_bool(datum const& data, char const *object_name);
105 [[nodiscard]] std::string parse_string(datum const& data, char const *object_name);
106 [[nodiscard]] hi::color parse_color_value(datum const& data);
107 [[nodiscard]] hi::color parse_color(datum const& data, char const *object_name);
108 [[nodiscard]] std::vector<hi::color> parse_color_list(datum const& data, char const *object_name);
109 [[nodiscard]] hi::text_style parse_text_style_value(hi::font_book const& font_book, datum const& data);
110 [[nodiscard]] font_weight parse_font_weight(datum const& data, char const *object_name);
111 [[nodiscard]] hi::text_style parse_text_style(hi::font_book const& font_book, datum const& data, char const *object_name);
112 void parse(hi::font_book const& font_book, datum const& data);
113
114 [[nodiscard]] friend std::string to_string(theme const& rhs) noexcept
115 {
116 return std::format("{}:{}", rhs.name, rhs.mode);
117 }
118
119 friend std::ostream& operator<<(std::ostream& lhs, theme const& rhs)
120 {
121 return lhs << to_string(rhs);
122 }
123};
124
125} // namespace hi::inline v1
This file includes required definitions.
STL namespace.
This is a RGBA floating point color.
Definition color.hpp:39
A dynamic data type.
Definition datum.hpp:225
Definition theme.hpp:21
font_book keeps track of multiple fonts.
Definition font_book.hpp:30
Definition text_style.hpp:175
Definition URL.hpp:47