[android] Fix predefined colors again

Signed-off-by: Andrei Shkrob <github@shkrob.dev>
This commit is contained in:
Andrei Shkrob
2025-08-18 19:45:02 +02:00
committed by Konstantin Pastbin
parent 4052f0481e
commit ac453e36ac
2 changed files with 18 additions and 3 deletions

View File

@@ -66,6 +66,21 @@ static_assert(kOrderedPredefinedColors.size() == static_cast<size_t>(PredefinedC
"kOrderedPredefinedColors size must match PredefinedColor::Count");
static_assert(base::HasUniqueElements(kOrderedPredefinedColors), "All values must be unique");
/**
* @brief Maps PredefinedColor to its index in kOrderedPredefinedColors.
*
* @code
* kOrderedPredefinedColors[kColorIndexMap[base::E2I(PredefinedColor::Red)]] == PredefinedColor::Red
* @endcode
*/
std::array constexpr kColorIndexMap = [] consteval
{
std::array<int, static_cast<std::size_t>(PredefinedColor::Count)> map{};
for (std::size_t i = 0; i < kOrderedPredefinedColors.size(); ++i)
map[static_cast<std::size_t>(kOrderedPredefinedColors[i])] = static_cast<int>(i);
return map;
}();
inline std::string DebugPrint(PredefinedColor color)
{
switch (color)