mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-02 14:51:15 +00:00
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:
parent
f7517f403c
commit
be75cb2b21
3 changed files with 58 additions and 11 deletions
33
api/sixtyfps-cpp/include/sixtyfps_color.h
Normal file
33
api/sixtyfps-cpp/include/sixtyfps_color.h
Normal 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;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue