Make color pickers not change selected color as much

As described in #5844, sometimes the color kept changing when activating a color picker.

By rounding the color components before packing them into an unsigned, the color only changes very little and only at most once when activating a color picker.
This commit is contained in:
Robert Müller 2023-01-13 21:39:06 +01:00
parent a9207a931f
commit 25b487703f

View file

@ -111,7 +111,7 @@ public:
unsigned Pack(bool Alpha = true)
{
return (Alpha ? ((unsigned)(a * 255.0f) << 24) : 0) + ((unsigned)(x * 255.0f) << 16) + ((unsigned)(y * 255.0f) << 8) + (unsigned)(z * 255.0f);
return (Alpha ? ((unsigned)round_to_int(a * 255.0f) << 24) : 0) + ((unsigned)round_to_int(x * 255.0f) << 16) + ((unsigned)round_to_int(y * 255.0f) << 8) + (unsigned)round_to_int(z * 255.0f);
}
DerivedT WithAlpha(float alpha)