28#include <TGUI/String.hpp>
29#include <TGUI/Vertex.hpp>
33#if TGUI_HAS_RENDERER_BACKEND_SFML_GRAPHICS && !TGUI_DISABLE_SFML_CONVERSIONS
34 #include <SFML/Graphics/Color.hpp>
45 TGUI_API Color constructColorFromString(
const String&
string);
56#if defined(TGUI_SYSTEM_WINDOWS)
88#if TGUI_HAS_RENDERER_BACKEND_SFML_GRAPHICS && !TGUI_DISABLE_SFML_CONVERSIONS
94 constexpr Color(
const sf::Color& color) :
112 constexpr Color(std::uint8_t red, std::uint8_t green, std::uint8_t blue, std::uint8_t alpha = 255) :
122 #pragma warning(push)
123 #pragma warning(disable : 26495)
133 Color{priv::constructColorFromString(string)}
157 [[nodiscard]]
constexpr bool isSet()
const
162#if TGUI_HAS_RENDERER_BACKEND_SFML_GRAPHICS && !TGUI_DISABLE_SFML_CONVERSIONS
168 operator sf::Color()
const
170 return {m_red, m_green, m_blue, m_alpha};
189 [[nodiscard]]
constexpr std::uint8_t
getRed()
const
199 [[nodiscard]]
constexpr std::uint8_t
getGreen()
const
209 [[nodiscard]]
constexpr std::uint8_t
getBlue()
const
219 [[nodiscard]]
constexpr std::uint8_t
getAlpha()
const
229 return (m_isSet == rhs.m_isSet) && (m_red == rhs.m_red) && (m_green == rhs.m_green) && (m_blue == rhs.m_blue)
230 && (m_alpha == rhs.m_alpha);
238 return !(*
this == right);
254 static const std::array<std::pair<StringView, Color>, 9> colorNamesMap;
259 bool m_isSet =
false;
260 std::uint8_t m_red = 0;
261 std::uint8_t m_green = 0;
262 std::uint8_t m_blue = 0;
263 std::uint8_t m_alpha = 0;
278 inline constexpr std::array<std::pair<StringView, Color>, 9> Color::colorNamesMap{
307 [[nodiscard]] TGUI_API Color constructColorFromString(
const String&
string);
Wrapper for colors.
Definition Color.hpp:63
constexpr std::uint8_t getAlpha() const
Returns the alpha component of the color.
Definition Color.hpp:219
static const Color Red
Red predefined color.
Definition Color.hpp:246
static const Color Transparent
Transparent (black) predefined color.
Definition Color.hpp:252
static const Color Blue
Blue predefined color.
Definition Color.hpp:248
constexpr Color(const sf::Color &color)
Creates the object from an sf::Color.
Definition Color.hpp:94
constexpr std::uint8_t getGreen() const
Returns the green component of the color.
Definition Color.hpp:199
static constexpr Color applyOpacity(const Color &color, float alpha)
Returns the color with its alpha channel multiplied with the alpha parameter.
Definition Color.hpp:68
static const Color Yellow
Yellow predefined color.
Definition Color.hpp:249
static const Color Green
Green predefined color.
Definition Color.hpp:247
static const Color Black
Black predefined color.
Definition Color.hpp:244
constexpr Color()
Creates the object without a color.
Definition Color.hpp:79
constexpr std::uint8_t getBlue() const
Returns the blue component of the color.
Definition Color.hpp:209
static const Color White
White predefined color.
Definition Color.hpp:245
constexpr bool operator!=(const Color &right) const
Compares the color with another one.
Definition Color.hpp:236
Color(const char *string)
Creates the object from a string.
Definition Color.hpp:147
constexpr std::uint8_t getRed() const
Returns the red component of the color.
Definition Color.hpp:189
constexpr bool isSet() const
Checks if a color was set.
Definition Color.hpp:157
constexpr bool operator==(const Color &rhs) const
Compares the color with another one.
Definition Color.hpp:227
static const Color Magenta
Magenta predefined color.
Definition Color.hpp:250
static const Color Cyan
Cyan predefined color.
Definition Color.hpp:251
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:112
Color(const String &string)
Creates the object from a string.
Definition Color.hpp:132
Wrapper class to store strings.
Definition String.hpp:94
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:37