From 3bb1f590d711472e404646d3aa479bee090784d3 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Wed, 8 Dec 2010 08:09:11 +0000 Subject: [PATCH] Sabotage the once lovely friendship between FrameMain and AudioBox and use an option listener instead Originally committed to SVN as r4906. --- aegisub/src/audio_box.h | 4 ---- aegisub/src/audio_display.cpp | 10 ++-------- aegisub/src/audio_display.h | 14 ++++++-------- aegisub/src/frame_main_events.cpp | 2 -- 4 files changed, 8 insertions(+), 22 deletions(-) diff --git a/aegisub/src/audio_box.h b/aegisub/src/audio_box.h index 15d068bb3..363f8e73e 100644 --- a/aegisub/src/audio_box.h +++ b/aegisub/src/audio_box.h @@ -74,10 +74,6 @@ class ToggleBitmap; /// @class AudioBox /// @brief Panel with audio playback and timing controls, also containing an AudioDisplay class AudioBox : public wxPanel { - /// @todo Get rid of this ASAP, currently required for FrameMain to be able to notify - /// audio display about renderer having changed. - friend class FrameMain; - /// The audio display in the box AudioDisplay *audioDisplay; diff --git a/aegisub/src/audio_display.cpp b/aegisub/src/audio_display.cpp index aac9bfc9c..acadb2fe8 100644 --- a/aegisub/src/audio_display.cpp +++ b/aegisub/src/audio_display.cpp @@ -35,9 +35,6 @@ /// @ingroup audio_ui /// - -/////////// -// Headers #include "config.h" #ifndef AGI_PRE @@ -63,11 +60,6 @@ #include "main.h" #include "utils.h" - -#undef min -#undef max - - class AudioDisplayScrollbar : public AudioDisplayInteractionObject { static const int height = 10; @@ -557,6 +549,8 @@ AudioDisplay::AudioDisplay(wxWindow *parent, AudioController *controller) controller->AddAudioListener(this); controller->AddTimingListener(this); + OPT_SUB("Audio/Spectrum", &AudioDisplay::ReloadRenderingSettings, this); + audio_renderer->SetAmplitudeScale(scale_amplitude); SetZoomLevel(0); diff --git a/aegisub/src/audio_display.h b/aegisub/src/audio_display.h index 3e97885b8..086560c37 100644 --- a/aegisub/src/audio_display.h +++ b/aegisub/src/audio_display.h @@ -140,7 +140,7 @@ private: void SetDraggedObject(AudioDisplayInteractionObject *new_obj); - /// Leftmost pixel in the vitual audio image being displayed + /// Leftmost pixel in the virtual audio image being displayed int scroll_left; /// Total width of the audio in pixels @@ -182,6 +182,11 @@ private: /// Previous audio selection for optimising redraw when selection changes AudioController::SampleRange old_selection; + /// @brief Reload all rendering settings from Options and reset caches + /// + /// This can be called if some rendering quality settings have been changed + /// in Options and need to be reloaded to take effect. + void ReloadRenderingSettings(); /// wxWidgets paint event void OnPaint(wxPaintEvent &event); @@ -304,13 +309,6 @@ public: float GetAmplitudeScale() const; - /// @brief Reload all rendering settings from Options and reset caches - /// - /// This can be called if some rendering quality settings have been changed in Options - /// and need to be reloaded to take effect. - void ReloadRenderingSettings(); - - /// @brief Get a sample index from an X coordinate relative to current scroll int64_t SamplesFromRelativeX(int x) const { return (scroll_left + x) * pixel_samples; } /// @brief Get a sample index from an absolute X coordinate diff --git a/aegisub/src/frame_main_events.cpp b/aegisub/src/frame_main_events.cpp index 64d119706..964d13a56 100644 --- a/aegisub/src/frame_main_events.cpp +++ b/aegisub/src/frame_main_events.cpp @@ -681,8 +681,6 @@ void FrameMain::OnCloseAudio (wxCommandEvent&) { /// @param event wxWidgets event object void FrameMain::OnAudioDisplayMode (wxCommandEvent &event) { OPT_SET("Audio/Spectrum")->SetBool(event.GetId() == Menu_Audio_Spectrum); - /// @todo Remove this reload call when the audio display starts listening for option changes - audioBox->audioDisplay->ReloadRenderingSettings(); } #ifdef _DEBUG