1 #include "colorpalette.h" 2 nextColor(mixxx::RgbColor color) const3mixxx::RgbColor ColorPalette::nextColor(mixxx::RgbColor color) const { 4 // Return first color if color not in palette ((-1 + 1) % size) 5 return at((indexOf(color) + 1) % size()); 6 } 7 nextColor(mixxx::RgbColor::optional_t color) const8mixxx::RgbColor::optional_t ColorPalette::nextColor(mixxx::RgbColor::optional_t color) const { 9 if (color) { 10 // If color is the last element in the palette, return no color 11 if (indexOf(*color) == size() - 1) { 12 return std::nullopt; 13 } 14 return nextColor(*color); 15 } 16 return at(0); 17 } 18 previousColor(mixxx::RgbColor color) const19mixxx::RgbColor ColorPalette::previousColor(mixxx::RgbColor color) const { 20 int iIndex = indexOf(color); 21 if (iIndex < 0) { 22 // Return last color if color not in palette 23 iIndex = size() - 1; 24 } else { 25 iIndex = (iIndex + size() - 1) % size(); 26 } 27 return at(iIndex); 28 } 29 previousColor(mixxx::RgbColor::optional_t color) const30mixxx::RgbColor::optional_t ColorPalette::previousColor(mixxx::RgbColor::optional_t color) const { 31 if (color) { 32 // If color is the first element in the palette, return no color 33 if (indexOf(*color) == 0) { 34 return std::nullopt; 35 } 36 return previousColor(*color); 37 } 38 return at(size() - 1); 39 } 40 colorForHotcueIndex(unsigned int hotcueIndex) const41mixxx::RgbColor ColorPalette::colorForHotcueIndex(unsigned int hotcueIndex) const { 42 int colorIndex; 43 if (m_colorIndicesByHotcue.isEmpty()) { 44 colorIndex = hotcueIndex; 45 } else { 46 colorIndex = m_colorIndicesByHotcue.at(hotcueIndex % m_colorIndicesByHotcue.size()); 47 } 48 return at(colorIndex % size()); 49 } 50