29#include <TGUI/String.hpp>
30#include <TGUI/Vertex.hpp>
32#if !TGUI_EXPERIMENTAL_USE_STD_MODULE
38#if TGUI_HAS_RENDERER_BACKEND_SFML_GRAPHICS && !TGUI_DISABLE_SFML_CONVERSIONS
39 #include <SFML/Graphics/Color.hpp>
44TGUI_MODULE_EXPORT
namespace tgui
53 TGUI_API Color constructColorFromString(
const String&
string);
57TGUI_MODULE_EXPORT
namespace tgui
67#if TGUI_COMPILED_WITH_CPP_VER >= 17
100#if TGUI_HAS_RENDERER_BACKEND_SFML_GRAPHICS && !TGUI_DISABLE_SFML_CONVERSIONS
106 constexpr Color(
const sf::Color& color) :
124 constexpr Color(std::uint8_t red, std::uint8_t green, std::uint8_t blue, std::uint8_t alpha = 255) :
134#if defined (_MSC_VER)
135# pragma warning(push)
136# pragma warning(disable: 26495)
146 Color{priv::constructColorFromString(string)}
149#if defined (_MSC_VER)
171 TGUI_NODISCARD
constexpr bool isSet()
const
176#if TGUI_HAS_RENDERER_BACKEND_SFML_GRAPHICS && !TGUI_DISABLE_SFML_CONVERSIONS
182 operator sf::Color()
const
184 return {m_red, m_green, m_blue, m_alpha};
204 TGUI_NODISCARD
constexpr std::uint8_t
getRed()
const
215 TGUI_NODISCARD
constexpr std::uint8_t
getGreen()
const
226 TGUI_NODISCARD
constexpr std::uint8_t
getBlue()
const
237 TGUI_NODISCARD
constexpr std::uint8_t
getAlpha()
const
248 return (m_isSet == rhs.m_isSet)
249 && (m_red == rhs.m_red)
250 && (m_green == rhs.m_green)
251 && (m_blue == rhs.m_blue)
252 && (m_alpha == rhs.m_alpha);
261 return !(*
this == right);
278 static const std::array<std::pair<StringView, Color>, 9> colorNamesMap;
284 bool m_isSet =
false;
285 std::uint8_t m_red = 0;
286 std::uint8_t m_green = 0;
287 std::uint8_t m_blue = 0;
288 std::uint8_t m_alpha = 0;
294#if TGUI_COMPILED_WITH_CPP_VER >= 17
296 inline constexpr const Color
Color::White {255, 255, 255};
297 inline constexpr const Color
Color::Red {255, 0, 0};
299 inline constexpr const Color
Color::Blue { 0, 0, 255};
302 inline constexpr const Color
Color::Cyan { 0, 255, 255};
305 inline constexpr const std::array<std::pair<StringView, Color>, 9> Color::colorNamesMap
340 TGUI_NODISCARD TGUI_API Color constructColorFromString(
const String&
string);
Wrapper for colors.
Definition Color.hpp:72
static TGUI_NODISCARD constexpr Color applyOpacity(const Color &color, float alpha)
Returns the color with its alpha channel multiplied with the alpha parameter.
Definition Color.hpp:78
static const Color Transparent
Transparent (black) predefined color.
Definition Color.hpp:276
TGUI_NODISCARD constexpr bool isSet() const
Checks if a color was set.
Definition Color.hpp:171
TGUI_NODISCARD constexpr bool operator!=(const Color &right) const
Compares the color with another one.
Definition Color.hpp:259
constexpr Color(const sf::Color &color)
Creates the object from an sf::Color.
Definition Color.hpp:106
TGUI_NODISCARD constexpr std::uint8_t getAlpha() const
Returns the alpha component of the color.
Definition Color.hpp:237
static const Color Black
Black predefined color.
Definition Color.hpp:268
static const Color Green
Green predefined color.
Definition Color.hpp:271
TGUI_NODISCARD constexpr std::uint8_t getRed() const
Returns the red component of the color.
Definition Color.hpp:204
constexpr Color()
Creates the object without a color.
Definition Color.hpp:91
TGUI_NODISCARD constexpr std::uint8_t getBlue() const
Returns the blue component of the color.
Definition Color.hpp:226
static const Color White
White predefined color.
Definition Color.hpp:269
Color(const char *string)
Creates the object from a string.
Definition Color.hpp:160
TGUI_NODISCARD constexpr bool operator==(const Color &rhs) const
Compares the color with another one.
Definition Color.hpp:246
static const Color Cyan
Cyan predefined color.
Definition Color.hpp:275
static const Color Magenta
Magenta predefined color.
Definition Color.hpp:274
static const Color Yellow
Yellow predefined color.
Definition Color.hpp:273
static const Color Red
Red predefined color.
Definition Color.hpp:270
static const Color Blue
Blue predefined color.
Definition Color.hpp:272
constexpr Color(std::uint8_t red, std::uint8_t green, std::uint8_t blue, std::uint8_t alpha=255)
Creates the object from an the RGB or RGBA values.
Definition Color.hpp:124
TGUI_NODISCARD constexpr std::uint8_t getGreen() const
Returns the green component of the color.
Definition Color.hpp:215
Color(const String &string)
Creates the object from a string.
Definition Color.hpp:145
Wrapper class to store strings.
Definition String.hpp:101
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:39