Fix failing C++ build tests

Making color a real property type broke the build of tests that compare
color properties. Fix this and the incorrect decoding of
strings in the cast to colors, by providing a proper public C++ color
wrapper type.
This commit is contained in:
Simon Hausmann 2020-06-27 16:09:59 +02:00
parent f7517f403c
commit be75cb2b21
3 changed files with 58 additions and 11 deletions

View file

@ -0,0 +1,33 @@
#pragma once
#include "sixtyfps_color_internal.h"
#include <stdint.h>
namespace sixtyfps {
class Color
{
public:
Color() { inner.red = inner.green = inner.blue = inner.alpha = 0; }
explicit Color(uint32_t argb_encoded)
{
inner.red = (argb_encoded >> 16) & 0xff;
inner.green = (argb_encoded >> 8) & 0xff;
inner.blue = argb_encoded & 0xff;
inner.alpha = (argb_encoded >> 24) & 0xff;
}
friend bool operator==(const Color &lhs, const Color &rhs)
{
return lhs.inner.red == rhs.inner.red && lhs.inner.green == rhs.inner.green
&& lhs.inner.blue == rhs.inner.blue && lhs.inner.alpha == rhs.inner.alpha;
}
friend bool operator!=(const Color &lhs, const Color &rhs) { return !(lhs == rhs); }
private:
internal::types::Color inner;
};
}