![]() |
Vault
4.1
|
VColorPair holds a foreground and background color as a single object for ease of management and use in the other APIs. More...
#include <vcolor.h>
Public Member Functions | |
VColorPair (const VColor &bg) | |
VColorPair (const VColor &bg, const VColor &fg) | |
const VColor & | getBg () const |
const VColor & | getFg () const |
const VColor & | getColor (bool isBg) const |
VString | getCSSColor () const |
Static Public Member Functions | |
static VColor | generateContrastingForeground (const VColor &bg) |
Returns white if the specified background is "dark", and black if the specified background is "light". | |
static VColorPair | safeConstructColorPair (const VString &bgCssColor, const VString &fgCssColor) |
This function returns a VColorPair based on the supplied bg/fg colors, which may be empty if not applicable. | |
Friends | |
bool | operator== (const VColorPair &c1, const VColorPair &c2) |
bool | operator!= (const VColorPair &c1, const VColorPair &c2) |
VColorPair holds a foreground and background color as a single object for ease of management and use in the other APIs.
For consistency, we always reference the background as the first element, and the foreground as the second element. Also for consistency and brevity, we abbreviate using "bg" and "fg" everywhere. For efficiency, thoughout the color palette classes we provide flexible APIs that can return a color pair, a particular color, or a fg/bg color as asked for.
Returns white if the specified background is "dark", and black if the specified background is "light".
bg | a background color value |
Definition at line 230 of file vcolor.cpp.
References VColor::getLightness().
VColorPair VColorPair::safeConstructColorPair | ( | const VString & | bgCssColor, |
const VString & | fgCssColor | ||
) | [static] |
This function returns a VColorPair based on the supplied bg/fg colors, which may be empty if not applicable.
This function also catches malformed color values skips them.
bgCssColor | background color as a CSS color string (see VColor); if empty, the result is constructed with white bg color |
fgCssColor | foreground color as a CSS color string (see VColor); if empty, the result is constructed with no fg color (a contrasting color will be generated) |
Definition at line 235 of file vcolor.cpp.
References VString::isNotEmpty(), and VColor::setCSSColor().