HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
src
ttauri
icon.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 "URL.hpp"
8
#include "pixel_map.hpp"
9
#include "rapid/sfloat_rgba16.hpp"
10
#include "text/font_glyph_ids.hpp"
11
#include "text/elusive_icon.hpp"
12
#include "text/ttauri_icon.hpp"
13
#include <variant>
14
15
namespace
tt {
16
19
class
icon
{
20
public
:
21
icon
(
URL
const
&url);
22
icon
(
pixel_map<sfloat_rgba16>
&&image)
noexcept
;
23
icon
(
font_glyph_ids
const
&glyph)
noexcept
;
24
icon
(elusive_icon
const
&
icon
)
noexcept
;
25
icon
(ttauri_icon
const
&
icon
)
noexcept
;
26
27
constexpr
icon
() noexcept : _image(std::monostate{}) {}
28
29
icon
(
icon
const
&)
noexcept
=
default
;
30
icon
(
icon
&&)
noexcept
=
default
;
31
icon
&operator=(
icon
const
&)
noexcept
=
default
;
32
icon
&operator=(
icon
&&)
noexcept
=
default
;
33
34
[[nodiscard]]
explicit
operator
bool ()
const
noexcept
35
{
36
return
!std::holds_alternative<std::monostate>(_image);
37
}
38
39
[[nodiscard]]
friend
bool
operator==(
icon
const
&lhs,
icon
const
&rhs)
noexcept
40
{
41
return
lhs._image == rhs._image;
42
}
43
44
template
<
typename
T>
45
[[nodiscard]]
friend
bool
holds_alternative(
tt::icon
const
&
icon
)
noexcept
46
{
47
return
std::holds_alternative<T>(
icon
._image);
48
}
49
50
template
<
typename
T>
51
[[nodiscard]]
friend
T
const
&get(
tt::icon
const
&
icon
)
noexcept
52
{
53
return
std::get<T>(
icon
._image);
54
}
55
56
template
<
typename
T>
57
[[nodiscard]]
friend
T &get(
tt::icon
&
icon
)
noexcept
58
{
59
return
std::get<T>(_image);
60
}
61
62
private
:
63
using
image_type = std::variant<std::monostate, elusive_icon, ttauri_icon, font_glyph_ids, pixel_map<sfloat_rgba16>>;
64
65
image_type _image;
66
67
friend
class
stencil;
68
};
69
70
71
}
tt::pixel_map
A 2D canvas of pixels.
Definition
pixel_map.hpp:101
tt::icon
An image, in different formats.
Definition
icon.hpp:19
tt::font_glyph_ids
Definition
font_glyph_ids.hpp:80
tt::URL
Definition
URL.hpp:47
Generated on Mon Apr 22 2024 12:53:34 for HikoGUI by
1.10.0