Skip to content

Commit

Permalink
Make colorFromConfig a normal member function
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer committed May 15, 2023
1 parent 2851f5b commit af2f087
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/engine/controls/cuecontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,16 @@ void CueControl::quantizeChanged(double v) {
}
}

mixxx::RgbColor CueControl::colorFromConfig(const ConfigKey& configKey) {
auto hotcueColorPalette =
m_colorPaletteSettings.getHotcueColorPalette();
int colorIndex = m_pConfig->getValue(configKey, -1);
if (colorIndex < 0 || colorIndex >= hotcueColorPalette.size()) {
return hotcueColorPalette.defaultColor();
}
return hotcueColorPalette.at(colorIndex);
};

void CueControl::hotcueSet(HotcueControl* pControl, double value, HotcueSetMode mode) {
//qDebug() << "CueControl::hotcueSet" << value;

Expand Down Expand Up @@ -897,28 +907,17 @@ void CueControl::hotcueSet(HotcueControl* pControl, double value, HotcueSetMode
int hotcueIndex = pControl->getHotcueIndex();

mixxx::RgbColor color = mixxx::PredefinedColorPalettes::kDefaultCueColor;
auto hotcueColorPalette =
m_colorPaletteSettings.getHotcueColorPalette();

auto colorFromConfig = [this, &hotcueColorPalette](const ConfigKey& configKey) {
int colorIndex = m_pConfig->getValue(configKey, -1);
if (colorIndex < 0 || colorIndex >= hotcueColorPalette.size()) {
return hotcueColorPalette.defaultColor();
}
return hotcueColorPalette.at(colorIndex);
};

if (cueType == mixxx::CueType::Loop) {
ConfigKey autoLoopColorsKey("[Controls]", "auto_loop_colors");
if (getConfig()->getValue(autoLoopColorsKey, false)) {
color = hotcueColorPalette.colorForHotcueIndex(hotcueIndex);
color = m_colorPaletteSettings.getHotcueColorPalette().colorForHotcueIndex(hotcueIndex);
} else {
color = colorFromConfig(ConfigKey("[Controls]", "LoopDefaultColorIndex"));
}
} else {
ConfigKey autoHotcueColorsKey("[Controls]", "auto_hotcue_colors");
if (getConfig()->getValue(autoHotcueColorsKey, false)) {
color = hotcueColorPalette.colorForHotcueIndex(hotcueIndex);
color = m_colorPaletteSettings.getHotcueColorPalette().colorForHotcueIndex(hotcueIndex);
} else {
color = colorFromConfig(ConfigKey("[Controls]", "HotcueDefaultColorIndex"));
}
Expand Down
1 change: 1 addition & 0 deletions src/engine/controls/cuecontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ class CueControl : public EngineControl {
void seekOnLoad(mixxx::audio::FramePos seekOnLoadPosition);
void setHotcueFocusIndex(int hotcueIndex);
int getHotcueFocusIndex() const;
mixxx::RgbColor colorFromConfig(const ConfigKey& configKey);

UserSettingsPointer m_pConfig;
ColorPaletteSettings m_colorPaletteSettings;
Expand Down

0 comments on commit af2f087

Please sign in to comment.