10#include "utility/module.hpp"
12#include "l10n/module.hpp"
13#include "unicode/gstring.hpp"
14#include "image/module.hpp"
15#include "font/module.hpp"
21namespace hi::inline
v1 {
31class text :
public std::variant<std::monostate, std::string, gstring, translate> {
38 [[nodiscard]]
constexpr friend bool to_bool(
text const& rhs)
noexcept
40 return not std::holds_alternative<std::monostate>(rhs);
52 [](std::monostate
const &) {
return gstring{}; },
54 [](
gstring const &x) {
return x; },
78class icon :
public std::variant<std::monostate, elusive_icon, hikogui_icon, glyph_ids, pixmap<sfloat_rgba16>>
80 using std::variant<std::monostate, elusive_icon, hikogui_icon,
glyph_ids, pixmap<sfloat_rgba16>>::variant;
84 [[nodiscard]]
constexpr friend bool to_bool(
icon const& rhs)
noexcept
86 return not std::holds_alternative<std::monostate>(rhs);
92template<
typename CharT>
93struct std::formatter<
hi::text, CharT> : std::formatter<std::string_view, CharT> {
94 auto format(hi::text
const& t,
auto& fc)
96 return std::formatter<std::string_view, CharT>::format(
to_string(t), fc);
100namespace hi::inline
v1 {
127 constexpr label(std::convertible_to<hi::icon>
auto&&
icon, std::convertible_to<hi::text>
auto&&
text) noexcept :
146 constexpr label(
label const& other)
noexcept =
default;
147 constexpr label& operator=(
label const& other)
noexcept =
default;
148 constexpr label(
label&& other)
noexcept =
default;
149 constexpr label& operator=(
label&& other)
noexcept =
default;
151 [[nodiscard]]
constexpr bool empty() const noexcept
153 return not(to_bool(
icon) or to_bool(
text));
156 constexpr explicit operator bool() const noexcept
171 template<fixed_
string>
172 [[nodiscard]]
auto& get(
label&)
const noexcept;
175 [[nodiscard]]
auto& get<
"text">(
label& rhs)
const noexcept
181 [[nodiscard]]
auto& get<
"icon">(
label& rhs)
const noexcept
189template<
typename CharT>
190struct std::formatter<
hi::label, CharT> : std::formatter<hi::text, CharT> {
191 auto format(hi::label
const& t,
auto& fc)
193 return std::formatter<hi::text, CharT>::format(t.text, fc);
#define hi_forward(x)
Forward a value, based on the decltype of the value.
Definition utility.hpp:29
DOXYGEN BUG.
Definition algorithm.hpp:13
constexpr gstring to_gstring(std::u32string_view rhs, unicode_normalize_config config=unicode_normalize_config::NFC()) noexcept
Convert a UTF-32 string-view to a grapheme-string.
Definition gstring.hpp:158
geometry/margins.hpp
Definition cache.hpp:11
A set of glyph-ids of a font which composites into a single glyph.
Definition glyph_ids.hpp:135
A localizable message.
Definition translate.hpp:155
A variant of text.
Definition label.hpp:31
constexpr friend gstring to_gstring(hi::text const &rhs) noexcept
Convert the text into a gstring.
Definition label.hpp:47
constexpr friend bool to_bool(text const &rhs) noexcept
Check if text contains a string.
Definition label.hpp:38
constexpr friend std::string to_string(hi::text const &rhs) noexcept
Convert the text into a std::string.
Definition label.hpp:63
A variant of icon.
Definition label.hpp:79
constexpr friend bool to_bool(icon const &rhs) noexcept
Check if icon contains an image.
Definition label.hpp:84
A label consisting of localizable text and an icon.
Definition label.hpp:112
hi::icon icon
The icon.
Definition label.hpp:116
constexpr friend bool operator==(label const &lhs, label const &rhs) noexcept=default
Compare if both labels are equal.
constexpr label(std::convertible_to< hi::icon > auto &&icon) noexcept
Construct a new label from an icon.
Definition label.hpp:140
constexpr label(std::convertible_to< hi::icon > auto &&icon, std::convertible_to< hi::text > auto &&text) noexcept
Construct a new label from an icon and text.
Definition label.hpp:127
hi::text text
Localizable text.
Definition label.hpp:121
constexpr label() noexcept
Construct a empty label.
Definition label.hpp:144
constexpr label(std::convertible_to< hi::text > auto &&text) noexcept
Construct a new label from text.
Definition label.hpp:135
This selector allows access to member variable by name.
Definition type_traits.hpp:642
Helper type to turn a set of lambdas into a single overloaded type to pass to std::visit().
Definition type_traits.hpp:671