mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-02 00:49:33 +02:00
Add spectrogram preference migration from old 'Grayscale' checkbox to new 'Color Scheme' choice
This commit is contained in:
parent
e135bcf16f
commit
e9f0590c28
@ -445,7 +445,7 @@ bool SetTrackVisualsCommand::ApplyInner(const CommandContext & context, Track *
|
|||||||
wt->GetSpectrogramSettings().spectralSelection = bSpectralSelect;
|
wt->GetSpectrogramSettings().spectralSelection = bSpectralSelect;
|
||||||
}
|
}
|
||||||
if (wt && bHasSpecColorScheme) {
|
if (wt && bHasSpecColorScheme) {
|
||||||
wt->GetSpectrogramSettings().colorScheme = mSpecColorScheme;
|
wt->GetSpectrogramSettings().colorScheme = (SpectrogramSettings::ColorScheme)mSpecColorScheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -176,6 +176,26 @@ const EnumValueSymbols &SpectrogramSettings::GetColorSchemeNames()
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SpectrogramSettings::ColorSchemeEnumSetting::Migrate(wxString &value)
|
||||||
|
{
|
||||||
|
// Migrate old grayscale option to Color scheme choice
|
||||||
|
bool isGrayscale = (gPrefs->Read(wxT("/Spectrum/Grayscale"), 0L) != 0);
|
||||||
|
if (isGrayscale && !gPrefs->Read(wxT("/Spectrum/ColorScheme"), &value)) {
|
||||||
|
value = GetColorSchemeNames().at(csInvGrayscale).Internal();
|
||||||
|
Write(value);
|
||||||
|
gPrefs->Flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SpectrogramSettings::ColorSchemeEnumSetting SpectrogramSettings::colorSchemeSetting{
|
||||||
|
wxT("/Spectrum/ColorScheme"),
|
||||||
|
GetColorSchemeNames(),
|
||||||
|
csColorNew, // default to Color(New)
|
||||||
|
{ csColorNew, csColorTheme, csGrayscale, csInvGrayscale },
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
//static
|
//static
|
||||||
const TranslatableStrings &SpectrogramSettings::GetAlgorithmNames()
|
const TranslatableStrings &SpectrogramSettings::GetAlgorithmNames()
|
||||||
{
|
{
|
||||||
@ -249,7 +269,9 @@ bool SpectrogramSettings::Validate(bool quiet)
|
|||||||
ScaleType(std::max(0,
|
ScaleType(std::max(0,
|
||||||
std::min((int)(SpectrogramSettings::stNumScaleTypes) - 1,
|
std::min((int)(SpectrogramSettings::stNumScaleTypes) - 1,
|
||||||
(int)(scaleType))));
|
(int)(scaleType))));
|
||||||
colorScheme = std::max(0, std::min(csNumColorScheme-1, colorScheme));
|
colorScheme = ColorScheme(
|
||||||
|
std::max(0, std::min<int>(csNumColorScheme-1, colorScheme))
|
||||||
|
);
|
||||||
algorithm = Algorithm(
|
algorithm = Algorithm(
|
||||||
std::max(0, std::min((int)(algNumAlgorithms) - 1, (int)(algorithm)))
|
std::max(0, std::min((int)(algNumAlgorithms) - 1, (int)(algorithm)))
|
||||||
);
|
);
|
||||||
@ -277,7 +299,7 @@ void SpectrogramSettings::LoadPrefs()
|
|||||||
|
|
||||||
gPrefs->Read(wxT("/Spectrum/WindowType"), &windowType, eWinFuncHann);
|
gPrefs->Read(wxT("/Spectrum/WindowType"), &windowType, eWinFuncHann);
|
||||||
|
|
||||||
colorScheme = ColorScheme(gPrefs->Read(wxT("/Spectrum/ColorScheme"), 0L));
|
colorScheme = colorSchemeSetting.ReadEnum();
|
||||||
|
|
||||||
scaleType = ScaleType(gPrefs->Read(wxT("/Spectrum/ScaleType"), 0L));
|
scaleType = ScaleType(gPrefs->Read(wxT("/Spectrum/ScaleType"), 0L));
|
||||||
|
|
||||||
@ -325,7 +347,7 @@ void SpectrogramSettings::SavePrefs()
|
|||||||
|
|
||||||
gPrefs->Write(wxT("/Spectrum/WindowType"), windowType);
|
gPrefs->Write(wxT("/Spectrum/WindowType"), windowType);
|
||||||
|
|
||||||
gPrefs->Write(wxT("/Spectrum/ColorScheme"), (int) colorScheme);
|
colorSchemeSetting.WriteEnum(colorScheme);
|
||||||
|
|
||||||
gPrefs->Write(wxT("/Spectrum/ScaleType"), (int) scaleType);
|
gPrefs->Write(wxT("/Spectrum/ScaleType"), (int) scaleType);
|
||||||
|
|
||||||
@ -385,9 +407,7 @@ void SpectrogramSettings::UpdatePrefs()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (colorScheme == defaults().colorScheme) {
|
if (colorScheme == defaults().colorScheme) {
|
||||||
int temp;
|
colorScheme = colorSchemeSetting.ReadEnum();
|
||||||
gPrefs->Read(wxT("/Spectrum/ColorScheme"), &temp, 0L);
|
|
||||||
colorScheme = ColorScheme(temp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scaleType == defaults().scaleType) {
|
if (scaleType == defaults().scaleType) {
|
||||||
|
@ -129,8 +129,7 @@ public:
|
|||||||
size_t GetFFTLength() const; // window size (times zero padding, if STFT)
|
size_t GetFFTLength() const; // window size (times zero padding, if STFT)
|
||||||
size_t NBins() const;
|
size_t NBins() const;
|
||||||
|
|
||||||
typedef int ColorScheme;
|
enum ColorScheme : int {
|
||||||
enum ColorSchemeValues : int {
|
|
||||||
// Keep in correspondence with AColor::colorSchemes, AColor::gradient_pre
|
// Keep in correspondence with AColor::colorSchemes, AColor::gradient_pre
|
||||||
csColorNew = 0,
|
csColorNew = 0,
|
||||||
csColorTheme,
|
csColorTheme,
|
||||||
@ -141,6 +140,12 @@ public:
|
|||||||
};
|
};
|
||||||
ColorScheme colorScheme;
|
ColorScheme colorScheme;
|
||||||
|
|
||||||
|
class ColorSchemeEnumSetting : public EnumSetting< ColorScheme > {
|
||||||
|
using EnumSetting< ColorScheme >::EnumSetting;
|
||||||
|
void Migrate(wxString &value) override;
|
||||||
|
};
|
||||||
|
static ColorSchemeEnumSetting colorSchemeSetting;
|
||||||
|
|
||||||
ScaleType scaleType;
|
ScaleType scaleType;
|
||||||
|
|
||||||
#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
|
#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
|
||||||
|
@ -225,7 +225,7 @@ void SpectrumPrefs::PopulateOrExchange(ShuttleGui & S)
|
|||||||
8);
|
8);
|
||||||
|
|
||||||
S.Id(ID_COLOR_SCHEME).TieChoice(XXO("Color Sche&me:"),
|
S.Id(ID_COLOR_SCHEME).TieChoice(XXO("Color Sche&me:"),
|
||||||
mTempSettings.colorScheme,
|
(int&)mTempSettings.colorScheme,
|
||||||
Msgids( SpectrogramSettings::GetColorSchemeNames() ) );
|
Msgids( SpectrogramSettings::GetColorSchemeNames() ) );
|
||||||
}
|
}
|
||||||
S.EndMultiColumn();
|
S.EndMultiColumn();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user