From 9cb7b233459acb060545907dccb4aa468f8f1d2a Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Wed, 30 Nov 2011 21:04:09 +0000 Subject: [PATCH] Get color scheme names from the config rather than hardcoding it Originally committed to SVN as r5948. --- aegisub/src/audio_display.cpp | 7 +++++-- aegisub/src/audio_renderer_spectrum.cpp | 9 ++++----- aegisub/src/audio_renderer_spectrum.h | 3 ++- aegisub/src/audio_renderer_waveform.cpp | 23 +++++++++++------------ aegisub/src/audio_renderer_waveform.h | 15 +++++++++++---- 5 files changed, 33 insertions(+), 24 deletions(-) diff --git a/aegisub/src/audio_display.cpp b/aegisub/src/audio_display.cpp index a9bcf9e5f..cfa2bbfd5 100644 --- a/aegisub/src/audio_display.cpp +++ b/aegisub/src/audio_display.cpp @@ -763,7 +763,7 @@ void AudioDisplay::ReloadRenderingSettings() { if (OPT_GET("Audio/Spectrum")->GetBool()) { - AudioSpectrumRenderer *audio_spectrum_renderer = new AudioSpectrumRenderer; + AudioSpectrumRenderer *audio_spectrum_renderer = new AudioSpectrumRenderer(OPT_GET("Colour/Audio Display/Spectrum")->GetString()); int64_t spectrum_quality = OPT_GET("Audio/Renderer/Spectrum/Quality")->GetInt(); #ifdef WITH_FFTW @@ -784,7 +784,7 @@ void AudioDisplay::ReloadRenderingSettings() } else { - audio_renderer_provider.reset(new AudioWaveformRenderer); + audio_renderer_provider.reset(new AudioWaveformRenderer(OPT_GET("Colour/Audio Display/Waveform")->GetString())); } audio_renderer->SetRenderer(audio_renderer_provider.get()); @@ -1199,6 +1199,9 @@ void AudioDisplay::OnAudioOpen(AudioProvider *provider) connections.push_back(controller->AddSelectionChangedListener(&AudioDisplay::OnSelectionChanged, this)); connections.push_back(controller->AddStyleRangesChangedListener(&AudioDisplay::OnStyleRangesChanged, this)); connections.push_back(OPT_SUB("Audio/Spectrum", &AudioDisplay::ReloadRenderingSettings, this)); + connections.push_back(OPT_SUB("Colour/Audio Display/Spectrum", &AudioDisplay::ReloadRenderingSettings, this)); + connections.push_back(OPT_SUB("Colour/Audio Display/Waveform", &AudioDisplay::ReloadRenderingSettings, this)); + connections.push_back(OPT_SUB("Audio/Renderer/Spectrum/Quality", &AudioDisplay::ReloadRenderingSettings, this)); } } else diff --git a/aegisub/src/audio_renderer_spectrum.cpp b/aegisub/src/audio_renderer_spectrum.cpp index 86cc50236..a2d3bc9a6 100644 --- a/aegisub/src/audio_renderer_spectrum.cpp +++ b/aegisub/src/audio_renderer_spectrum.cpp @@ -43,7 +43,6 @@ #include "fft.h" #endif #include "include/aegisub/audio_provider.h" -#include "main.h" #include "utils.h" #include @@ -105,10 +104,10 @@ public: }; -AudioSpectrumRenderer::AudioSpectrumRenderer() -: colors_normal(new AudioColorScheme(12, "Icy Blue", AudioStyle_Normal)) -, colors_selected(new AudioColorScheme(12, "Icy Blue", AudioStyle_Selected)) -, colors_inactive(new AudioColorScheme(12, "Icy Blue", AudioStyle_Inactive)) +AudioSpectrumRenderer::AudioSpectrumRenderer(std::string const& color_scheme_name) +: colors_normal(new AudioColorScheme(12, color_scheme_name, AudioStyle_Normal)) +, colors_selected(new AudioColorScheme(12, color_scheme_name, AudioStyle_Selected)) +, colors_inactive(new AudioColorScheme(12, color_scheme_name, AudioStyle_Inactive)) , derivation_size(8) , derivation_dist(8) #ifdef WITH_FFTW diff --git a/aegisub/src/audio_renderer_spectrum.h b/aegisub/src/audio_renderer_spectrum.h index 93bfd3b5a..054ca4134 100644 --- a/aegisub/src/audio_renderer_spectrum.h +++ b/aegisub/src/audio_renderer_spectrum.h @@ -121,7 +121,8 @@ class AudioSpectrumRenderer : public AudioRendererBitmapProvider { public: /// @brief Constructor - AudioSpectrumRenderer(); + /// @param color_scheme_name Name of the color scheme to use + AudioSpectrumRenderer(std::string const& color_scheme_name); /// @brief Destructor ~AudioSpectrumRenderer(); diff --git a/aegisub/src/audio_renderer_waveform.cpp b/aegisub/src/audio_renderer_waveform.cpp index 91a31fe7f..78e4a6e9f 100644 --- a/aegisub/src/audio_renderer_waveform.cpp +++ b/aegisub/src/audio_renderer_waveform.cpp @@ -36,24 +36,23 @@ #include "config.h" +#include "audio_renderer_waveform.h" + #ifndef AGI_PRE #include #include #endif -#include "block_cache.h" -#include "include/aegisub/audio_provider.h" #include "audio_colorscheme.h" -#include "audio_renderer.h" -#include "audio_renderer_waveform.h" +#include "block_cache.h" #include "colorspace.h" +#include "include/aegisub/audio_provider.h" -AudioWaveformRenderer::AudioWaveformRenderer() -: AudioRendererBitmapProvider() -, colors_normal(6, "Icy Blue", AudioStyle_Normal) -, colors_selected(6, "Icy Blue", AudioStyle_Selected) -, colors_inactive(6, "Icy Blue", AudioStyle_Inactive) +AudioWaveformRenderer::AudioWaveformRenderer(std::string const& color_scheme_name) +: colors_normal(new AudioColorScheme(6, color_scheme_name, AudioStyle_Normal)) +, colors_selected(new AudioColorScheme(6, color_scheme_name, AudioStyle_Selected)) +, colors_inactive(new AudioColorScheme(6, color_scheme_name, AudioStyle_Inactive)) , audio_buffer(0) { } @@ -169,8 +168,8 @@ const AudioColorScheme *AudioWaveformRenderer::GetColorScheme(AudioRenderingStyl { switch (style) { - case AudioStyle_Selected: return &colors_selected; - case AudioStyle_Inactive: return &colors_inactive; - default: return &colors_normal; + case AudioStyle_Selected: return colors_selected.get(); + case AudioStyle_Inactive: return colors_inactive.get(); + default: return colors_normal.get(); } } diff --git a/aegisub/src/audio_renderer_waveform.h b/aegisub/src/audio_renderer_waveform.h index 6d91ce533..81e1f69ba 100644 --- a/aegisub/src/audio_renderer_waveform.h +++ b/aegisub/src/audio_renderer_waveform.h @@ -39,15 +39,21 @@ #include #endif +#include + +class AudioColorScheme; + +#include "audio_renderer.h" + class AudioWaveformRenderer : public AudioRendererBitmapProvider { /// Colour table used for regular rendering - AudioColorScheme colors_normal; + agi::scoped_ptr colors_normal; /// Colour table used for rendering the audio selection - AudioColorScheme colors_selected; + agi::scoped_ptr colors_selected; /// Colour table used for rendering inactive lines - AudioColorScheme colors_inactive; + agi::scoped_ptr colors_inactive; /// Pre-allocated buffer for audio fetched from provider char *audio_buffer; @@ -60,7 +66,8 @@ class AudioWaveformRenderer : public AudioRendererBitmapProvider { public: /// @brief Constructor - AudioWaveformRenderer(); + /// @param color_scheme_name Name of the color scheme to use + AudioWaveformRenderer(std::string const& color_scheme_name); /// @brief Destructor ~AudioWaveformRenderer();