Set the audio volume from the slider when audio is opened

Originally committed to SVN as r6711.
This commit is contained in:
Thomas Goyne 2012-04-21 15:13:46 +00:00
parent 3c31c1a17a
commit 0a64763f2f
2 changed files with 13 additions and 4 deletions

View file

@ -81,6 +81,7 @@ AudioBox::AudioBox(wxWindow *parent, agi::Context *context)
: wxSashWindow(parent, -1, wxDefaultPosition, wxDefaultSize, wxSW_3D | wxCLIP_CHILDREN) : wxSashWindow(parent, -1, wxDefaultPosition, wxDefaultSize, wxSW_3D | wxCLIP_CHILDREN)
, controller(context->audioController) , controller(context->audioController)
, context(context) , context(context)
, audio_open_connection(controller->AddAudioOpenListener(&AudioBox::OnAudioOpen, this))
, panel(new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxBORDER_RAISED)) , panel(new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxBORDER_RAISED))
, audioDisplay(new AudioDisplay(panel, context->audioController, context)) , audioDisplay(new AudioDisplay(panel, context->audioController, context))
, HorizontalZoom(new wxSlider(panel, Audio_Horizontal_Zoom, OPT_GET("Audio/Zoom/Horizontal")->GetInt(), -50, 30, wxDefaultPosition, wxSize(-1, 20), wxSL_VERTICAL|wxSL_BOTH)) , HorizontalZoom(new wxSlider(panel, Audio_Horizontal_Zoom, OPT_GET("Audio/Zoom/Horizontal")->GetInt(), -50, 30, wxDefaultPosition, wxSize(-1, 20), wxSL_VERTICAL|wxSL_BOTH))
@ -139,7 +140,6 @@ AudioBox::AudioBox(wxWindow *parent, agi::Context *context)
audioDisplay->SetZoomLevel(-HorizontalZoom->GetValue()); audioDisplay->SetZoomLevel(-HorizontalZoom->GetValue());
audioDisplay->SetAmplitudeScale(pow(mid(1, VerticalZoom->GetValue(), 100) / 50.0, 3)); audioDisplay->SetAmplitudeScale(pow(mid(1, VerticalZoom->GetValue(), 100) / 50.0, 3));
controller->SetVolume(pow(mid(1, VolumeBar->GetValue(), 100) / 50.0, 3));
} }
AudioBox::~AudioBox() { } AudioBox::~AudioBox() { }
@ -230,6 +230,10 @@ void AudioBox::OnVerticalLink(agi::OptionValue const& opt) {
VolumeBar->Enable(!opt.GetBool()); VolumeBar->Enable(!opt.GetBool());
} }
void AudioBox::OnAudioOpen() {
controller->SetVolume(pow(mid(1, VolumeBar->GetValue(), 100) / 50.0, 3));
}
void AudioBox::ShowKaraokeBar(bool show) { void AudioBox::ShowKaraokeBar(bool show) {
wxSizer *panel_sizer = panel->GetSizer(); wxSizer *panel_sizer = panel->GetSizer();
if (panel_sizer->IsShown(context->karaoke) == show) return; if (panel_sizer->IsShown(context->karaoke) == show) return;

View file

@ -38,6 +38,8 @@
#include <wx/sashwin.h> #include <wx/sashwin.h>
#endif #endif
#include <libaegisub/signal.h>
namespace agi { namespace agi {
struct Context; struct Context;
class OptionValue; class OptionValue;
@ -62,6 +64,8 @@ class AudioBox : public wxSashWindow {
/// Project context this operates on /// Project context this operates on
agi::Context *context; agi::Context *context;
agi::signal::Connection audio_open_connection;
/// Panel containing the children /// Panel containing the children
wxPanel *panel; wxPanel *panel;
@ -81,12 +85,13 @@ class AudioBox : public wxSashWindow {
// Mouse wheel zoom accumulator // Mouse wheel zoom accumulator
int mouse_zoom_accum; int mouse_zoom_accum;
void OnAudioOpen();
void OnHorizontalZoom(wxScrollEvent &event); void OnHorizontalZoom(wxScrollEvent &event);
void OnMouseWheel(wxMouseEvent &evt);
void OnSashDrag(wxSashEvent &event);
void OnVerticalLink(agi::OptionValue const& opt);
void OnVerticalZoom(wxScrollEvent &event); void OnVerticalZoom(wxScrollEvent &event);
void OnVolume(wxScrollEvent &event); void OnVolume(wxScrollEvent &event);
void OnVerticalLink(agi::OptionValue const& opt);
void OnSashDrag(wxSashEvent &event);
void OnMouseWheel(wxMouseEvent &evt);
public: public:
AudioBox(wxWindow *parent, agi::Context *context); AudioBox(wxWindow *parent, agi::Context *context);