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 "theme_color.hpp"
9#include "theme_text_style.hpp"
10#include "../required.hpp"
11#include "../text/text_style.hpp"
12#include "../URL.hpp"
13#include "../datum.hpp"
14#include "../color/color.hpp"
15#include "../geometry/extent.hpp"
16#include "../subsystem.hpp"
17#include <array>
18
19namespace hi::inline v1 {
20class font_book;
21
22class theme {
23public:
24 operating_system operating_system = operating_system::windows;
25
28 float dpi = 72;
29
32 float scale = 1.0f;
33
36 float margin = 4.5f;
37
40 float border_width = 1.0f;
41
44 float rounding_radius = 4.0f;
45
48 float size = 11.0f;
49
52 float large_size = 18.5f;
53
56 float icon_size = 7.5f;
57
60 float large_icon_size = 22.5f;
61
64 float label_icon_size = 15.0f;
65
66 std::string name;
67 theme_mode mode = theme_mode::light;
68
69 theme() noexcept = default;
70 theme(theme const &) noexcept = default;
71 theme(theme &&) noexcept = default;
72 theme &operator=(theme const &) noexcept = default;
73 theme &operator=(theme &&) noexcept = default;
74
77 theme(hi::font_book const &font_book, URL const &url);
78
89 [[nodiscard]] theme transform(float dpi) const noexcept;
90
91 [[nodiscard]] hi::color color(theme_color theme_color, ssize_t nesting_level = 0) const noexcept;
92 [[nodiscard]] hi::text_style const &text_style(theme_text_style theme_color) const noexcept;
93
94private:
95 std::array<std::vector<hi::color>, num_theme_colors> _colors;
96 std::array<hi::text_style, num_theme_text_styles> _text_styles;
97
98 [[nodiscard]] float parse_float(datum const &data, char const *object_name);
99 [[nodiscard]] bool parse_bool(datum const &data, char const *object_name);
100 [[nodiscard]] std::string parse_string(datum const &data, char const *object_name);
101 [[nodiscard]] hi::color parse_color_value(datum const &data);
102 [[nodiscard]] hi::color parse_color(datum const &data, char const *object_name);
103 [[nodiscard]] std::vector<hi::color> parse_color_list(datum const &data, char const *object_name);
104 [[nodiscard]] hi::text_style parse_text_style_value(hi::font_book const &font_book, datum const &data);
105 [[nodiscard]] font_weight parse_font_weight(datum const &data, char const *object_name);
106 [[nodiscard]] hi::text_style parse_text_style(hi::font_book const &font_book, datum const &data, char const *object_name);
107 void parse(hi::font_book const &font_book, datum const &data);
108
109 [[nodiscard]] friend std::string to_string(theme const &rhs) noexcept
110 {
111 return std::format("{}:{}", rhs.name, rhs.mode);
112 }
113
114 friend std::ostream &operator<<(std::ostream &lhs, theme const &rhs)
115 {
116 return lhs << to_string(rhs);
117 }
118};
119
120} // namespace hi::inline v1
This file includes required definitions.
STL namespace.
This is a RGBA floating point color.
Definition color.hpp:37
A dynamic data type.
Definition datum.hpp:209
Definition theme.hpp:22
font_book keeps track of multiple fonts.
Definition font_book.hpp:30
Definition text_style.hpp:18
Definition URL.hpp:47