diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-02-25 00:11:49 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-02-25 00:11:49 +0000 |
| commit | 040a227d300033f8a103dc6eb67847286131d9b7 (patch) | |
| tree | 54093eaad6186817d1ee744d3f299f93ea49b475 /src/wx | |
| parent | dcd968d6d64d645816af0efbcd2f928128c95b9f (diff) | |
Some tidying up, add channel selector to Audio dialog.
Diffstat (limited to 'src/wx')
| -rw-r--r-- | src/wx/audio_dialog.cc | 68 | ||||
| -rw-r--r-- | src/wx/audio_dialog.h | 24 | ||||
| -rw-r--r-- | src/wx/audio_plot.cc | 44 | ||||
| -rw-r--r-- | src/wx/audio_plot.h | 5 | ||||
| -rw-r--r-- | src/wx/film_editor.cc | 32 | ||||
| -rw-r--r-- | src/wx/film_editor.h | 3 |
6 files changed, 145 insertions, 31 deletions
diff --git a/src/wx/audio_dialog.cc b/src/wx/audio_dialog.cc index 7f87ee5fd..11efc153c 100644 --- a/src/wx/audio_dialog.cc +++ b/src/wx/audio_dialog.cc @@ -1,27 +1,79 @@ +/* + Copyright (C) 2013 Carl Hetherington <cth@carlh.net> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + #include "audio_dialog.h" #include "audio_plot.h" #include "audio_analysis.h" #include "film.h" +#include "wx_util.h" using boost::shared_ptr; AudioDialog::AudioDialog (wxWindow* parent, boost::shared_ptr<Film> film) : wxDialog (parent, wxID_ANY, _("Audio"), wxDefaultPosition, wxSize (640, 512), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) + , _plot (0) { - wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL); + wxBoxSizer* sizer = new wxBoxSizer (wxHORIZONTAL); + + _plot = new AudioPlot (this); + sizer->Add (_plot, 1); + + wxFlexGridSizer* table = new wxFlexGridSizer (2, 6, 6); + + add_label_to_sizer (table, this, _("Channel")); + _channel = new wxChoice (this, wxID_ANY); + table->Add (_channel, 1, wxEXPAND | wxALL, 6); + + sizer->Add (table); + + set_film (film); + + SetSizer (sizer); + sizer->Layout (); + sizer->SetSizeHints (this); + + _channel->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (AudioDialog::channel_changed), 0, this); +} +void +AudioDialog::set_film (boost::shared_ptr<Film> f) +{ shared_ptr<AudioAnalysis> a; - + try { - a.reset (new AudioAnalysis (film->audio_analysis_path ())); - _plot = new AudioPlot (this, a, 0); - sizer->Add (_plot, 1); + a.reset (new AudioAnalysis (f->audio_analysis_path ())); } catch (...) { + + } + _plot->set_analysis (a); + + _channel->Clear (); + for (int i = 0; i < f->audio_stream()->channels(); ++i) { + _channel->Append (audio_channel_name (i)); } - SetSizer (sizer); - sizer->Layout (); - sizer->SetSizeHints (this); + _channel->SetSelection (0); } +void +AudioDialog::channel_changed (wxCommandEvent &) +{ + _plot->set_channel (_channel->GetSelection ()); +} diff --git a/src/wx/audio_dialog.h b/src/wx/audio_dialog.h index 324a1ec99..1e4563972 100644 --- a/src/wx/audio_dialog.h +++ b/src/wx/audio_dialog.h @@ -1,3 +1,22 @@ +/* + Copyright (C) 2013 Carl Hetherington <cth@carlh.net> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + #include <boost/shared_ptr.hpp> #include <wx/wx.h> @@ -9,6 +28,11 @@ class AudioDialog : public wxDialog public: AudioDialog (wxWindow *, boost::shared_ptr<Film>); + void set_film (boost::shared_ptr<Film>); + private: + void channel_changed (wxCommandEvent &); + AudioPlot* _plot; + wxChoice* _channel; }; diff --git a/src/wx/audio_plot.cc b/src/wx/audio_plot.cc index 4fda3227d..cc2d8f6b4 100644 --- a/src/wx/audio_plot.cc +++ b/src/wx/audio_plot.cc @@ -1,3 +1,22 @@ +/* + Copyright (C) 2013 Carl Hetherington <cth@carlh.net> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + #include <iostream> #include <boost/bind.hpp> #include <wx/graphics.h> @@ -14,10 +33,9 @@ using std::min; using boost::bind; using boost::shared_ptr; -AudioPlot::AudioPlot (wxWindow* parent, shared_ptr<AudioAnalysis> a, int c) +AudioPlot::AudioPlot (wxWindow* parent) : wxPanel (parent) - , _analysis (a) - , _channel (c) + , _channel (0) { Connect (wxID_ANY, wxEVT_PAINT, wxPaintEventHandler (AudioPlot::paint), 0, this); @@ -25,9 +43,29 @@ AudioPlot::AudioPlot (wxWindow* parent, shared_ptr<AudioAnalysis> a, int c) } void +AudioPlot::set_analysis (shared_ptr<AudioAnalysis> a) +{ + _analysis = a; + _channel = 0; + Refresh (); +} + +void +AudioPlot::set_channel (int c) +{ + _channel = c; + Refresh (); +} + +void AudioPlot::paint (wxPaintEvent &) { wxPaintDC dc (this); + + if (!_analysis) { + return; + } + wxGraphicsContext* gc = wxGraphicsContext::Create (dc); if (!gc) { return; diff --git a/src/wx/audio_plot.h b/src/wx/audio_plot.h index 565997f7e..03bd79323 100644 --- a/src/wx/audio_plot.h +++ b/src/wx/audio_plot.h @@ -26,7 +26,10 @@ class AudioAnalysis; class AudioPlot : public wxPanel { public: - AudioPlot (wxWindow *, boost::shared_ptr<AudioAnalysis>, int); + AudioPlot (wxWindow *); + + void set_analysis (boost::shared_ptr<AudioAnalysis>); + void set_channel (int c); private: void paint (wxPaintEvent &); diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index 0a9b6d87c..725f2d1b3 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -63,6 +63,7 @@ FilmEditor::FilmEditor (shared_ptr<Film> f, wxWindow* parent) : wxPanel (parent) , _film (f) , _generally_sensitive (true) + , _audio_dialog (0) { wxBoxSizer* s = new wxBoxSizer (wxVERTICAL); SetSizer (s); @@ -346,22 +347,8 @@ FilmEditor::make_audio_panel () grid->Add (_use_external_audio); grid->AddSpacer (0); - assert (MAX_AUDIO_CHANNELS == 6); - - /* TRANSLATORS: these are the names of audio channels; Lfe (sub) is the low-frequency - enhancement channel (sub-woofer)./ - */ - wxString const channels[] = { - _("Left"), - _("Right"), - _("Centre"), - _("Lfe (sub)"), - _("Left surround"), - _("Right surround"), - }; - for (int i = 0; i < MAX_AUDIO_CHANNELS; ++i) { - add_label_to_sizer (grid, _audio_panel, channels[i]); + add_label_to_sizer (grid, _audio_panel, audio_channel_name (i)); _external_audio[i] = new wxFilePickerCtrl (_audio_panel, wxID_ANY, wxT (""), _("Select Audio File"), wxT ("*.wav")); grid->Add (_external_audio[i], 1, wxEXPAND); } @@ -762,6 +749,10 @@ FilmEditor::set_film (shared_ptr<Film> f) } else { FileChanged (""); } + + if (_audio_dialog) { + _audio_dialog->set_film (_film); + } film_changed (Film::NAME); film_changed (Film::USE_DCI_NAME); @@ -823,6 +814,7 @@ FilmEditor::set_things_sensitive (bool s) _j2k_bandwidth->Enable (s); _audio_gain->Enable (s); _audio_gain_calculate_button->Enable (s); + _show_audio->Enable (s); _audio_delay->Enable (s); _still_duration->Enable (s); @@ -1185,7 +1177,11 @@ FilmEditor::setup_dcp_name () void FilmEditor::show_audio_clicked (wxCommandEvent &) { - AudioDialog* d = new AudioDialog (this, _film); - d->ShowModal (); - d->Destroy (); + if (_audio_dialog) { + _audio_dialog->Destroy (); + _audio_dialog = 0; + } + + _audio_dialog = new AudioDialog (this, _film); + _audio_dialog->Show (); } diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h index bd0300aed..2af747bb0 100644 --- a/src/wx/film_editor.h +++ b/src/wx/film_editor.h @@ -29,8 +29,8 @@ #include "lib/film.h" class wxNotebook; - class Film; +class AudioDialog; /** @class FilmEditor * @brief A wx widget to edit a film's metadata, and perform various functions. @@ -179,4 +179,5 @@ private: std::vector<Format const *> _formats; bool _generally_sensitive; + AudioDialog* _audio_dialog; }; |
