From 6888bad050534968b56074e02a817c0b837b64a8 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Wed, 11 Jan 2023 14:03:38 -0800 Subject: [PATCH] Use union in CTextColor Former-commit-id: b49d6096c70f5495f4465fa6bb314e25b732d8ab --- include/Kyoto/Text/CTextColor.hpp | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/include/Kyoto/Text/CTextColor.hpp b/include/Kyoto/Text/CTextColor.hpp index 87255906..4c5ed2d0 100644 --- a/include/Kyoto/Text/CTextColor.hpp +++ b/include/Kyoto/Text/CTextColor.hpp @@ -3,15 +3,38 @@ #include +#ifdef __MWERKS__ +#pragma cpp_extensions on +#endif + class CTextColor { public: 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: - uchar mR; - uchar mG; - uchar mB; - uchar mA; + union { + struct { + uchar mR; + uchar mG; + uchar mB; + uchar mA; + }; + uint mRgba; + }; }; +#ifdef __MWERKS__ +#pragma cpp_extensions off +#endif + #endif // _CTEXTCOLOR