Re-add show audio button and analyse just that content when it is clicked.
[dcpomatic.git] / src / wx / audio_panel.cc
index c31d5b57502b12d9ae67d5fb31a9d2d144e039bd..46d7a22541e916adf792cf0d51b1670886b81b9f 100644 (file)
@@ -25,6 +25,7 @@
 #include "wx_util.h"
 #include "gain_calculator_dialog.h"
 #include "content_panel.h"
+#include "audio_dialog.h"
 #include <wx/spinctrl.h>
 #include <boost/lexical_cast.hpp>
 #include <boost/foreach.hpp>
@@ -40,12 +41,17 @@ using boost::shared_ptr;
 
 AudioPanel::AudioPanel (ContentPanel* p)
        : ContentSubPanel (p, _("Audio"))
+       , _audio_dialog (0)
 {
        wxGridBagSizer* grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
        _sizer->Add (grid, 0, wxALL, 8);
 
        int r = 0;
 
+       _show = new wxButton (this, wxID_ANY, _("Show Audio..."));
+       grid->Add (_show, wxGBPosition (r, 0));
+       ++r;
+
        add_label_to_grid_bag_sizer (grid, this, _("Gain"), true, wxGBPosition (r, 0));
        _gain = new ContentSpinCtrlDouble<AudioContent> (
                this,
@@ -92,11 +98,19 @@ AudioPanel::AudioPanel (ContentPanel* p)
        _gain->wrapped()->SetIncrement (0.5);
        _delay->wrapped()->SetRange (-1000, 1000);
 
-       _gain_calculate_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED,  boost::bind (&AudioPanel::gain_calculate_button_clicked, this));
+       _show->Bind                  (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&AudioPanel::show_clicked, this));
+       _gain_calculate_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&AudioPanel::gain_calculate_button_clicked, this));
 
        _mapping_connection = _mapping->Changed.connect (boost::bind (&AudioPanel::mapping_changed, this, _1));
 }
 
+AudioPanel::~AudioPanel ()
+{
+       if (_audio_dialog) {
+               _audio_dialog->Destroy ();
+               _audio_dialog = 0;
+       }
+}
 
 void
 AudioPanel::film_changed (Film::Property property)
@@ -190,3 +204,20 @@ AudioPanel::content_selection_changed ()
 
        film_content_changed (AudioContentProperty::AUDIO_STREAMS);
 }
+
+void
+AudioPanel::show_clicked ()
+{
+       if (_audio_dialog) {
+               _audio_dialog->Destroy ();
+               _audio_dialog = 0;
+       }
+
+       AudioContentList ac = _parent->selected_audio ();
+       if (ac.size() != 1) {
+               return;
+       }
+
+       _audio_dialog = new AudioDialog (this, _parent->film (), ac.front ());
+       _audio_dialog->Show ();
+}