Is there some kind of system or best-practice to avoid collisions with existing colourID’s? When I look in the header files, there are a lot of enums that define existing colours (Slider::backgroundID etc.). How can we make sure that if we define our own, that they don’t collide with existing ones?
Any tips&tricks? Something we’ve overlooked?
I’ve always just grepped for the value…
I guess now with C++11 constexprs it’d be possible to come up with a fancier system that used compile-time hashes of strings or something instead.
std::map with Identifiers (So you can use the string as Info for a GUI Editor)
can you show an example of what you mean for us newbs? @chkn
In other words: there is no system. It’s all completely arbitrary and if you have a collision and unintentionally overwrite another colour, then that is just the way it is.
So I noticed that all colourIDs start with 0x100nnnnn. So I guess using 0x200nnnnn for our own colours is safe then?
To reply to myself: yes, it is safe to use 0x200nnnnn for your own colours.
Here’s an xml file of all the Color IDs + component names and comments, if anyone wants it. It may not be perfect or complete, but it’s got most of the things in there.
Compile time hashing is great if you can live with the one in a billion chance that you accidentally use the same ID as something else.