solvespace/srf
Daniel Richard G a5176f4545 Replaced RGB-color integers with dedicated data structure
RGB colors were represented using a uint32_t with the red, green and blue
values stuffed into the lower three octets (i.e. 0x00BBGGRR), like
Microsoft's COLORREF. This approach did not lend itself to type safety,
however, so this change replaces it with an RgbColor class that provides
the same infomation plus a handful of useful methods to work with it. (Note
that sizeof(RgbColor) == sizeof(uint32_t), so this change should not lead
to memory bloat.)

Some of the new methods/fields replace what were previously macro calls;
e.g. RED(c) is now c.red, REDf(c) is now c.redF(). The .Equals() method is
now used instead of == to compare colors.

RGB colors still need to be represented as packed integers in file I/O and
preferences, so the methods .FromPackedInt() and .ToPackedInt() are
provided. Also implemented are Cnf{Freeze,Thaw}Color(), type-safe wrappers
around Cnf{Freeze,Thaw}Int() that facilitate I/O with preferences.

(Cnf{Freeze,Thaw}Color() are defined outside of the system-dependent code
to minimize the footprint of the latter; because the same can be done with
Cnf{Freeze,Thaw}Bool(), those are also moved out of the system code with
this commit.)

Color integers were being OR'ed with 0x80000000 in some places for two
distinct purposes: One, to indicate use of a default color in
glxFillMesh(); this has been replaced by use of the .UseDefault() method.
Two, to indicate to TextWindow::Printf() that the format argument of a
"%Bp"/"%Fp" specifier is an RGB color rather than a color "code" from
TextWindow::bgColors[] or TextWindow::fgColors[] (as the specifier can
accept either); instead, we define a new flag "z" (as in "%Bz" or "%Fz") to
indicate an RGBcolor pointer, leaving "%Bp"/"%Fp" to indicate a color code
exclusively.

(This also allows TextWindow::meta[][].bg to be a char instead of an int,
partly compensating for the new .bgRgb field added immediately after.)

In array declarations, RGB colors could previously be specified as 0 (often
in a terminating element). As that no longer works, we define NULL_COLOR,
which serves much the same purpose for RgbColor variables as NULL serves
for pointers.
2013-10-25 01:49:12 -04:00
..
boolean.cpp Use C99 integer types and C++ boolean types/values 2013-10-02 01:45:13 -04:00
curve.cpp Changes in preparation for the release of SolveSpace under the GPL, 2013-07-28 14:08:34 -08:00
merge.cpp Replaced RGB-color integers with dedicated data structure 2013-10-25 01:49:12 -04:00
ratpoly.cpp Miscellaneous adjustments for warnings and code quality 2013-09-19 02:35:56 -04:00
raycast.cpp Quash "variable may be used uninitialized" warnings 2013-08-26 15:36:00 -04:00
surface.cpp Replaced RGB-color integers with dedicated data structure 2013-10-25 01:49:12 -04:00
surface.h Replaced RGB-color integers with dedicated data structure 2013-10-25 01:49:12 -04:00
surfinter.cpp Use C99 integer types and C++ boolean types/values 2013-10-02 01:45:13 -04:00
triangulate.cpp Use C99 integer types and C++ boolean types/values 2013-10-02 01:45:13 -04:00