24 TBColor() : b(0), g(0), r(0), a(255) {}
25 TBColor(uint8_t r_, uint8_t g_, uint8_t b_, uint8_t a_ = 255) : b(b_), g(g_), r(r_), a(a_) {}
26 TBColor(uint32_t bgra_) : bgra(bgra_) {}
29 struct { uint8_t b, g, r, a; };
33 void Set(
const TBColor &color) { *
this = color; }
42 operator uint32_t ()
const {
return bgra; }
84 const std::map<TBStr, TBColor>
GetColorMap()
const {
return _id2color; }
90 std::map<TBStr, TBColor> _id2color;
91 std::map<TBColor, TBStr> _color2id;
bool Define(const TBStr &cid, TBColor color)
Define a color, if not already defined.
Definition: tb_color.cpp:56
void Load(TBNode *n, TBSkin *skin)
Load a list of colors from a node.
Definition: tb_color.cpp:45
TBSkin contains a list of TBSkinElement.
Definition: tb_skin.h:287
void ReDefine(const TBStr &cid, TBColor color)
(Re)Define a color, no matter what.
Definition: tb_color.cpp:67
void Clear()
Clear the list of colors.
Definition: tb_color.cpp:74
TBStr GetColorID(const TBColor &color) const
Return the id of the given color, or 0.
Definition: tb_color.cpp:87
TBColor GetColor(const TBStr &cid) const
Return the color with the given id.
Definition: tb_color.cpp:80
bool IsDefined(const TBStr &cid)
Is the color defined?
Definition: tb_color.h:60
bool IsDefined(const TBColor &color)
Is the color defined?
Definition: tb_color.h:63
TBColorManager contains a map of global color names.
Definition: tb_color.h:49
void SetFromString(const TBStr &str)
Set the color from string in any of the following formats: "#rrggbbaa", "#rrggbb", "#rgba", "#rgb".
Definition: tb_color.cpp:15
TBStr is a simple string class.
Definition: tb_str.h:62
TBNode is a tree node with a string name and a value (TBValue).
Definition: tb_node_tree.h:30
void Dump(const TBStr &filename)
Dump the current color map.
Definition: tb_color.cpp:94
TBColor contains a 32bit color.
Definition: tb_color.h:21
const std::map< TBStr, TBColor > GetColorMap() const
Return the cid of the given color, or 0.
Definition: tb_color.h:84
void GetString(TBStr &str) const
Write color to string with format #rrggbbaa.
Definition: tb_color.cpp:38