29 return {xml.begin(), xml.end()};
33 if (std::holds_alternative<NoColor>(paint)) {
34 if (std::strcmp(mime_type,
mimeTEXT) == 0)
35 return {
'n',
'o',
'n',
'e'};
37 return std::vector<char>(8);
41 auto &color = std::get<Color>(paint);
42 if (std::strcmp(mime_type,
mimeTEXT) == 0) {
43 auto const str = color.toString();
44 return {str.begin(), str.end()};
45 }
else if (std::strcmp(mime_type,
mimeX_COLOR) == 0) {
47 auto const rgb = color.toRGBA();
63 throw ColorError(
"Data is the wrong size for color mime type");
68 if (std::strcmp(mime_type,
mimeTEXT) == 0) {
72 if (
auto color = Color::parse(str)) {
constexpr uint32_t SP_RGBA32_R_U(uint32_t v)
constexpr uint32_t SP_RGBA32_G_U(uint32_t v)
constexpr uint32_t SP_RGBA32_U_COMPOSE(uint32_t r, uint32_t g, uint32_t b, uint32_t a)
constexpr uint32_t SP_RGBA32_A_U(uint32_t v)
constexpr uint32_t SP_RGBA32_B_U(uint32_t v)
A set of useful color modifying functions which do not fit as generic methods on the color class itse...
constexpr auto mimeX_COLOR
std::vector< char > getMIMEData(Paint const &paint, char const *mime_type)
Convert a paint into a draggable object.
std::variant< NoColor, Color > Paint
constexpr auto mimeOSWB_COLOR
Paint xml_string_to_paint(std::string const &xmls, SPDocument *doc)
Parse an xml document into a color.
Paint fromMIMEData(std::span< char const > data, char const *mime_type)
Convert a dropped object into a color, if possible.
std::string paint_to_xml_string(Paint const &paint)
Turn a color into a color xml document, used for drag and drop.