10#include "utility/module.hpp"
12#include "i18n/translate.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);
50 [](std::monostate
const &) {
return std::string{}; },
66 [](std::monostate
const &) {
return gstring{}; },
68 [](
gstring const &x) {
return x; },
85class icon :
public std::variant<std::monostate, elusive_icon, hikogui_icon, glyph_ids, pixmap<sfloat_rgba16>>
87 using std::variant<std::monostate, elusive_icon, hikogui_icon,
glyph_ids, pixmap<sfloat_rgba16>>::variant;
91 [[nodiscard]]
constexpr friend bool to_bool(
icon const& rhs)
noexcept
93 return not std::holds_alternative<std::monostate>(rhs);
99template<
typename CharT>
100struct std::formatter<
hi::text, CharT> : std::formatter<std::string_view, CharT> {
101 auto format(hi::text
const& t,
auto& fc)
103 return std::formatter<std::string_view, CharT>::format(
to_string(t), fc);
107namespace hi::inline
v1 {
134 constexpr label(std::convertible_to<hi::icon>
auto&&
icon, std::convertible_to<hi::text>
auto&&
text) noexcept :
153 constexpr label(
label const& other)
noexcept =
default;
154 constexpr label& operator=(
label const& other)
noexcept =
default;
155 constexpr label(
label&& other)
noexcept =
default;
156 constexpr label& operator=(
label&& other)
noexcept =
default;
158 [[nodiscard]]
constexpr bool empty() const noexcept
160 return not(to_bool(
icon) or to_bool(
text));
163 constexpr explicit operator bool() const noexcept
178 template<fixed_
string>
179 [[nodiscard]]
auto& get(
label&)
const noexcept;
182 [[nodiscard]]
auto& get<
"text">(
label& rhs)
const noexcept
188 [[nodiscard]]
auto& get<
"icon">(
label& rhs)
const noexcept
196template<
typename CharT>
197struct std::formatter<
hi::label, CharT> : std::formatter<hi::text, CharT> {
198 auto format(hi::label
const& t,
auto& fc)
200 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
constexpr std::string to_string(std::u32string_view rhs) noexcept
Conversion from UTF-32 to UTF-8.
Definition to_string.hpp:215
DOXYGEN BUG.
Definition algorithm.hpp:13
gstring to_gstring(std::u32string_view rhs, char32_t new_line_char=U'\u2029') noexcept
Convert a UTF-32 string to a grapheme-string.
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:134
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:61
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:45
A variant of icon.
Definition label.hpp:86
constexpr friend bool to_bool(icon const &rhs) noexcept
Check if icon contains an image.
Definition label.hpp:91
A label consisting of localizable text and an icon.
Definition label.hpp:119
hi::icon icon
The icon.
Definition label.hpp:123
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:147
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:134
hi::text text
Localizable text.
Definition label.hpp:128
constexpr label() noexcept
Construct a empty label.
Definition label.hpp:151
constexpr label(std::convertible_to< hi::text > auto &&text) noexcept
Construct a new label from text.
Definition label.hpp:142
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