10#include "../utility/utility.hpp"
11#include "../unicode/unicode.hpp"
12#include "../image/image.hpp"
13#include "../font/font.hpp"
15#include "../macros.hpp"
21hi_export_module(hikogui.l10n.label);
24hi_export
namespace hi::inline
v1 {
35class icon :
public std::variant<std::monostate, elusive_icon, hikogui_icon, font_book::font_glyph_type, pixmap<sfloat_rgba16>>
41 [[nodiscard]]
constexpr friend bool to_bool(
icon const& rhs)
noexcept
43 return not std::holds_alternative<std::monostate>(rhs);
72 template<std::convertible_to<hi::icon> Icon, std::convertible_to<txt> Txt>
73 constexpr label(Icon &&
icon, Txt && text) noexcept :
74 icon(std::forward<Icon>(
icon)), text(std::forward<Txt>(text))
81 template<std::convertible_to<txt> Txt>
82 constexpr label(Txt && text) noexcept :
icon(), text(std::forward<Txt>(text)) {}
87 template<std::convertible_to<hi::icon> Icon>
95 label& operator=(
label const& other)
noexcept =
default;
97 label& operator=(
label&& other)
noexcept =
default;
99 [[nodiscard]]
constexpr bool empty() const noexcept
101 return not(to_bool(
icon) or to_bool(text));
104 constexpr explicit operator bool() const noexcept
119 template<fixed_
string>
120 [[nodiscard]]
auto& get(
label&)
const noexcept;
123 [[nodiscard]]
auto& get<
"text">(
label& rhs)
const noexcept
129 [[nodiscard]]
auto& get<
"icon">(
label& rhs)
const noexcept
139struct std::formatter<
hi::label, char> : std::formatter<std::string_view, char> {
140 auto format(hi::label
const& t,
auto& fc)
const
142 return std::formatter<std::string_view, char>::format(
std::string{t.text}, fc);
The HikoGUI namespace.
Definition array_generic.hpp:20
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
Definition font_book.hpp:34
A variant of icon.
Definition label.hpp:36
constexpr friend bool to_bool(icon const &rhs) noexcept
Check if icon contains an image.
Definition label.hpp:41
A label consisting of localizable text and an icon.
Definition label.hpp:57
constexpr friend bool operator==(label const &, label const &) noexcept=default
Compare if both labels are equal.
hi::icon icon
The icon.
Definition label.hpp:61
constexpr label(Txt &&text) noexcept
Construct a new label from text.
Definition label.hpp:82
constexpr label(Icon &&icon, Txt &&text) noexcept
Construct a new label from an icon and text.
Definition label.hpp:73
txt text
Localizable text.
Definition label.hpp:66
constexpr label() noexcept
Construct a empty label.
Definition label.hpp:92
constexpr label(Icon &&icon) noexcept
Construct a new label from an icon.
Definition label.hpp:88