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 tt {
20class font_book;
21
22class theme {
23public:
24 operating_system operating_system = operating_system::windows;
25
26 float toolbar_height = (operating_system == operating_system::windows) ? 30.0f : 20.0f;
27
30 float toolbar_decoration_button_width = (operating_system == operating_system::windows) ? 30.0f : 20.0f;
31
34 float margin = 6.0f;
35
38 float border_width = 1.0f;
39
42 float rounding_radius = 5.0f;
43
46 float size = 15.0f;
47
50 float large_size = 25.0f;
51
54 float icon_size = 10.0f;
55
58 float large_icon_size = 30.0f;
59
62 float label_icon_size = 20.0f;
63
64
65 std::string name;
66 theme_mode mode;
67
68 theme() noexcept = delete;
69 theme(theme const &) noexcept = delete;
70 theme(theme &&) noexcept = delete;
71 theme &operator=(theme const &) noexcept = delete;
72 theme &operator=(theme &&) noexcept = delete;
73
76 theme(tt::font_book const &font_book, URL const &url);
77
78 [[nodiscard]] tt::color color(theme_color theme_color, ssize_t nesting_level = 0) const noexcept;
79 [[nodiscard]] tt::text_style const &text_style(theme_text_style theme_color) const noexcept;
80
81private:
82 std::array<std::vector<tt::color>, num_theme_colors> _colors;
83 std::array<tt::text_style, num_theme_text_styles> _text_styles;
84
85 [[nodiscard]] float parse_float(datum const &data, char const *object_name);
86 [[nodiscard]] bool parse_bool(datum const &data, char const *object_name);
87 [[nodiscard]] std::string parse_string(datum const &data, char const *object_name);
88 [[nodiscard]] tt::color parse_color_value(datum const &data);
89 [[nodiscard]] tt::color parse_color(datum const &data, char const *object_name);
90 [[nodiscard]] std::vector<tt::color> parse_color_list(datum const &data, char const *object_name);
91 [[nodiscard]] tt::text_style parse_text_style_value(tt::font_book const &font_book, datum const &data);
92 [[nodiscard]] font_weight parse_font_weight(datum const &data, char const *object_name);
93 [[nodiscard]] tt::text_style parse_text_style(tt::font_book const &font_book, datum const &data, char const *object_name);
94 void parse(tt::font_book const &font_book, datum const &data);
95
96 [[nodiscard]] friend std::string to_string(theme const &rhs) noexcept {
97 return std::format("{}:{}", rhs.name, rhs.mode);
98 }
99
100 friend std::ostream &operator<<(std::ostream &lhs, theme const &rhs) {
101 return lhs << to_string(rhs);
102 }
103};
104
105}
STL namespace.
This is a RGBA floating point color.
Definition color.hpp:36
A dynamic data type.
Definition datum.hpp:213
Definition theme.hpp:22
float label_icon_size
Size of icons being inline with a label's text.
Definition theme.hpp:62
float large_icon_size
Size of icons representing the length of am average word of a label's text.
Definition theme.hpp:58
float large_size
The size of large widgets.
Definition theme.hpp:50
float size
The size of small square widgets.
Definition theme.hpp:46
float border_width
The line-width of a border.
Definition theme.hpp:38
float icon_size
Size of icons inside a widget.
Definition theme.hpp:54
float toolbar_decoration_button_width
The width of a close, minimize, maximize, system menu button.
Definition theme.hpp:30
float margin
Distance between widgets and between widgets and the border of the container.
Definition theme.hpp:34
float rounding_radius
The rounding radius of boxes with rounded corners.
Definition theme.hpp:42
font_book keeps track of multiple fonts.
Definition font_book.hpp:30
Definition text_style.hpp:17
Definition URL.hpp:47