10#include <QStringBuilder>
48 return CIcons::StandardIconError16;
74 double c =
red() * 1.0;
75 return c / colorRange();
84 double c =
green() * 1.0;
85 return c / colorRange();
94 double c =
blue() * 1.0;
95 return c / colorRange();
107 return withHash ? u
'#' % h : h;
116 return static_cast<int>(
toQColor().
rgb() & qRgba(255, 255, 255, 0));
174 return (rd * rd + bd * bd + gd * gd) / 3.0;
217 case IndexBlue: m_b = variant.
toInt();
break;
218 case IndexRed: m_r = variant.
toInt();
break;
219 case IndexGreen: m_g = variant.
toInt();
break;
229 return this->
compare(compareValue);
237 case IndexWebHex:
return this->
compare(compareValue);
238 default: Q_ASSERT_X(
false, Q_FUNC_INFO,
"Missing compare");
break;
258 double CRgbColor::colorRange()
const
264 if (m_b < 256 && m_g < 256 && m_r < 256)
268 if (m_b < 4096 && m_g < 4096 && m_r < 4096)
IconIndex
Index for each icon, allows to send them via DBus, efficiently store them, etc.
Non-owning reference to a CPropertyIndex with a subset of its features.
CastType frontCasted() const
First element casted to given type, usually the PropertIndex enum.
bool isMyself() const
Myself index, used with nesting.
QString blueHex(int digits=2) const
Blue as hex.
ColumnIndex
Properties by index.
double normalizedBlue() const
Blue 0..1.
QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const
Property by index.
QString hex(bool withHash=false) const
Hex value.
void setInvalid()
Mark as invalid.
QPixmap toPixmap() const
Icon as pixmap.
QColor toQColor() const
To QColor.
bool setQColor(const QColor &color)
Set by QColor.
QString convertToQString(bool i18n=false) const
Cast as QString.
int packed() const
Value packed in 24 bit integer.
static CRgbColor fromPacked(int rgb)
Construct from packed 24 bit integer value.
double normalizedRed() const
Red 0..1.
double colorDistance(const CRgbColor &color) const
Color distance [0..1] http://stackoverflow.com/questions/4754506/color-similarity-distance-in-rgba-co...
void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant)
Set property by index.
void setByString(const QString &color, bool isName=false)
Hex or color name.
int comparePropertyByIndex(CPropertyIndexRef index, const CRgbColor &compareValue) const
Compare for index.
double normalizedGreen() const
Green 0..1.
QString redHex(int digits=2) const
Red as hex.
CRgbColor()=default
Constructor.
int compare(const CRgbColor &color) const
Compare with other color.
QString greenHex(int digits=2) const
Green as hex.
CIcons::IconIndex toIcon() const
Representing icon.
bool isValid() const
Valid?
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
int compare(T a, T b)
Compare arithmetic values.
Free functions in swift::misc.
SWIFT_MISC_EXPORT QString intToHex(int value, int digits=2)
Int to hex value.
QColor fromString(QAnyStringView name)
bool isValid() const const
void drawRect(const QRect &rectangle)
void setBackground(const QBrush &brush)
void setBrush(QBrush &&brush)
bool isEmpty() const const
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
QString trimmed() const const
QVariant fromValue(T &&value)
int toInt(bool *ok) const const
QString toString() const const
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.