Get color scheme names from the config rather than hardcoding it

Originally committed to SVN as r5948.
This commit is contained in:
Thomas Goyne 2011-11-30 21:04:09 +00:00
parent 598a85c6cd
commit 9cb7b23345
5 changed files with 33 additions and 24 deletions

View file

@ -763,7 +763,7 @@ void AudioDisplay::ReloadRenderingSettings()
{ {
if (OPT_GET("Audio/Spectrum")->GetBool()) 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(); int64_t spectrum_quality = OPT_GET("Audio/Renderer/Spectrum/Quality")->GetInt();
#ifdef WITH_FFTW #ifdef WITH_FFTW
@ -784,7 +784,7 @@ void AudioDisplay::ReloadRenderingSettings()
} }
else 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()); 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->AddSelectionChangedListener(&AudioDisplay::OnSelectionChanged, this));
connections.push_back(controller->AddStyleRangesChangedListener(&AudioDisplay::OnStyleRangesChanged, this)); connections.push_back(controller->AddStyleRangesChangedListener(&AudioDisplay::OnStyleRangesChanged, this));
connections.push_back(OPT_SUB("Audio/Spectrum", &AudioDisplay::ReloadRenderingSettings, 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 else

View file

@ -43,7 +43,6 @@
#include "fft.h" #include "fft.h"
#endif #endif
#include "include/aegisub/audio_provider.h" #include "include/aegisub/audio_provider.h"
#include "main.h"
#include "utils.h" #include "utils.h"
#include <libaegisub/log.h> #include <libaegisub/log.h>
@ -105,10 +104,10 @@ public:
}; };
AudioSpectrumRenderer::AudioSpectrumRenderer() AudioSpectrumRenderer::AudioSpectrumRenderer(std::string const& color_scheme_name)
: colors_normal(new AudioColorScheme(12, "Icy Blue", AudioStyle_Normal)) : colors_normal(new AudioColorScheme(12, color_scheme_name, AudioStyle_Normal))
, colors_selected(new AudioColorScheme(12, "Icy Blue", AudioStyle_Selected)) , colors_selected(new AudioColorScheme(12, color_scheme_name, AudioStyle_Selected))
, colors_inactive(new AudioColorScheme(12, "Icy Blue", AudioStyle_Inactive)) , colors_inactive(new AudioColorScheme(12, color_scheme_name, AudioStyle_Inactive))
, derivation_size(8) , derivation_size(8)
, derivation_dist(8) , derivation_dist(8)
#ifdef WITH_FFTW #ifdef WITH_FFTW

View file

@ -121,7 +121,8 @@ class AudioSpectrumRenderer : public AudioRendererBitmapProvider {
public: public:
/// @brief Constructor /// @brief Constructor
AudioSpectrumRenderer(); /// @param color_scheme_name Name of the color scheme to use
AudioSpectrumRenderer(std::string const& color_scheme_name);
/// @brief Destructor /// @brief Destructor
~AudioSpectrumRenderer(); ~AudioSpectrumRenderer();

View file

@ -36,24 +36,23 @@
#include "config.h" #include "config.h"
#include "audio_renderer_waveform.h"
#ifndef AGI_PRE #ifndef AGI_PRE
#include <algorithm> #include <algorithm>
#include <wx/dcmemory.h> #include <wx/dcmemory.h>
#endif #endif
#include "block_cache.h"
#include "include/aegisub/audio_provider.h"
#include "audio_colorscheme.h" #include "audio_colorscheme.h"
#include "audio_renderer.h" #include "block_cache.h"
#include "audio_renderer_waveform.h"
#include "colorspace.h" #include "colorspace.h"
#include "include/aegisub/audio_provider.h"
AudioWaveformRenderer::AudioWaveformRenderer() AudioWaveformRenderer::AudioWaveformRenderer(std::string const& color_scheme_name)
: AudioRendererBitmapProvider() : colors_normal(new AudioColorScheme(6, color_scheme_name, AudioStyle_Normal))
, colors_normal(6, "Icy Blue", AudioStyle_Normal) , colors_selected(new AudioColorScheme(6, color_scheme_name, AudioStyle_Selected))
, colors_selected(6, "Icy Blue", AudioStyle_Selected) , colors_inactive(new AudioColorScheme(6, color_scheme_name, AudioStyle_Inactive))
, colors_inactive(6, "Icy Blue", AudioStyle_Inactive)
, audio_buffer(0) , audio_buffer(0)
{ {
} }
@ -169,8 +168,8 @@ const AudioColorScheme *AudioWaveformRenderer::GetColorScheme(AudioRenderingStyl
{ {
switch (style) switch (style)
{ {
case AudioStyle_Selected: return &colors_selected; case AudioStyle_Selected: return colors_selected.get();
case AudioStyle_Inactive: return &colors_inactive; case AudioStyle_Inactive: return colors_inactive.get();
default: return &colors_normal; default: return colors_normal.get();
} }
} }

View file

@ -39,15 +39,21 @@
#include <stdint.h> #include <stdint.h>
#endif #endif
#include <libaegisub/scoped_ptr.h>
class AudioColorScheme;
#include "audio_renderer.h"
class AudioWaveformRenderer : public AudioRendererBitmapProvider { class AudioWaveformRenderer : public AudioRendererBitmapProvider {
/// Colour table used for regular rendering /// Colour table used for regular rendering
AudioColorScheme colors_normal; agi::scoped_ptr<AudioColorScheme> colors_normal;
/// Colour table used for rendering the audio selection /// Colour table used for rendering the audio selection
AudioColorScheme colors_selected; agi::scoped_ptr<AudioColorScheme> colors_selected;
/// Colour table used for rendering inactive lines /// Colour table used for rendering inactive lines
AudioColorScheme colors_inactive; agi::scoped_ptr<AudioColorScheme> colors_inactive;
/// Pre-allocated buffer for audio fetched from provider /// Pre-allocated buffer for audio fetched from provider
char *audio_buffer; char *audio_buffer;
@ -60,7 +66,8 @@ class AudioWaveformRenderer : public AudioRendererBitmapProvider {
public: public:
/// @brief Constructor /// @brief Constructor
AudioWaveformRenderer(); /// @param color_scheme_name Name of the color scheme to use
AudioWaveformRenderer(std::string const& color_scheme_name);
/// @brief Destructor /// @brief Destructor
~AudioWaveformRenderer(); ~AudioWaveformRenderer();