Use union in CTextColor

Former-commit-id: b49d6096c7
This commit is contained in:
Phillip Stephens 2023-01-11 14:03:38 -08:00
parent 1b0b3b8b4d
commit 6888bad050
1 changed files with 27 additions and 4 deletions

View File

@ -3,15 +3,38 @@
#include <types.h> #include <types.h>
#ifdef __MWERKS__
#pragma cpp_extensions on
#endif
class CTextColor { class CTextColor {
public: public:
CTextColor(uchar r, uchar g, uchar b, uchar a) : mR(r), mG(g), mB(b), mA(a) {} CTextColor(uchar r, uchar g, uchar b, uchar a) : mR(r), mG(g), mB(b), mA(a) {}
CTextColor(const CTextColor& other) : mR(other.mR), mG(other.mG), mB(other.mB), mA(other.mA) {}
const CTextColor& operator=(const CTextColor& other) {
mR = other.mR;
mG = other.mG;
mB = other.mB;
mA = other.mA;
return *this;
}
private: private:
uchar mR; union {
uchar mG; struct {
uchar mB; uchar mR;
uchar mA; uchar mG;
uchar mB;
uchar mA;
};
uint mRgba;
};
}; };
#ifdef __MWERKS__
#pragma cpp_extensions off
#endif
#endif // _CTEXTCOLOR #endif // _CTEXTCOLOR