HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Label.hpp
1
2#pragma once
3
4#include "TTauri/Foundation/URL.hpp"
5#include "TTauri/Cells/Image.hpp"
6#include <fmt/format.h>
7#include <string>
8#include <ostream>
9
10namespace tt {
11
12class Label {
13 std::string _text;
14 Image _icon;
15
16public:
17 Label(std::string text, Image &&icon = Image{}) noexcept :
18 _text(text), _icon(std::move(icon)) {}
19
20 Label(Image &&icon) noexcept :
21 _text(), _icon(std::move(icon)) {}
22
23 Label(Label const &other) noexcept:
24 _text(other._text), _icon(other._icon) {}
25
26 Label(Label &&) noexcept = default;
27
28 Label &operator=(Label const &other) {
29 _text = other._text;
30 _icon = other._icon;
31 return *this;
32 }
33
34 Label &operator=(Label &&) noexcept = default;
35
38 [[nodiscard]] std::string text() const noexcept {
39 return _text;
40 }
41
44 [[nodiscard]] Image const &icon() const noexcept {
45 return _icon;
46 }
47
48 [[nodiscard]] friend std::string to_string(Label const &rhs) noexcept {
49 return fmt::format("label:{}", rhs._text);
50 }
51
52 friend std::ostream &operator<<(std::ostream &lhs, Label const &rhs) {
53 return lhs << to_string(rhs);
54 }
55};
56
57}
An image, in different formats.
Definition Image.hpp:18
Definition Label.hpp:12
Image const & icon() const noexcept
Get the text translated in the current locale.
Definition Label.hpp:44
std::string text() const noexcept
Get the text translated in the current locale.
Definition Label.hpp:38
T move(T... args)