Cleanup: move some methods from util to maths_util.
[dcpomatic.git] / src / wx / audio_panel.cc
index ff710b1d1183e2170e14dd8a211197472d664228..af030e9156af37525aa4ef70cd6fbee23f703758 100644 (file)
@@ -26,7 +26,6 @@
 #include "content_panel.h"
 #include "dcpomatic_button.h"
 #include "gain_calculator_dialog.h"
-#include "language_tag_widget.h"
 #include "static_text.h"
 #include "wx_util.h"
 #include "lib/config.h"
@@ -36,6 +35,7 @@
 #include "lib/job_manager.h"
 #include "lib/dcp_content.h"
 #include "lib/audio_content.h"
+#include "lib/maths_util.h"
 #include <wx/spinctrl.h>
 #include <iostream>
 
@@ -57,6 +57,13 @@ using namespace boost::placeholders;
 AudioPanel::AudioPanel (ContentPanel* p)
        : ContentSubPanel (p, _("Audio"))
        , _audio_dialog (0)
+{
+
+}
+
+
+void
+AudioPanel::create ()
 {
        _reference = new CheckBox (this, _("Use this DCP's audio as OV and make VF"));
        _reference_note = new StaticText (this, wxT(""));
@@ -95,9 +102,6 @@ AudioPanel::AudioPanel (ContentPanel* p)
        /// TRANSLATORS: this is an abbreviation for milliseconds, the unit of time
        _delay_ms_label = create_label (this, _("ms"), false);
 
-       _enable_language = new wxCheckBox (this, wxID_ANY, _("Language"));
-       _language = new LanguageTagWidget (this, _("Language used for the dialogue in this content"), boost::none);
-
        _mapping = new AudioMappingView (this, _("Content"), _("content"), _("DCP"), _("DCP"));
        _sizer->Add (_mapping, 1, wxEXPAND | wxALL, 6);
 
@@ -118,13 +122,13 @@ AudioPanel::AudioPanel (ContentPanel* p)
        _reference->Bind             (wxEVT_CHECKBOX, boost::bind (&AudioPanel::reference_clicked, this));
        _show->Bind                  (wxEVT_BUTTON,   boost::bind (&AudioPanel::show_clicked, this));
        _gain_calculate_button->Bind (wxEVT_BUTTON,   boost::bind (&AudioPanel::gain_calculate_button_clicked, this));
-       _enable_language->Bind       (wxEVT_CHECKBOX, boost::bind (&AudioPanel::enable_language_clicked, this));
-       _language->Changed.connect (boost::bind(&AudioPanel::language_changed, this));
 
        _mapping_connection = _mapping->Changed.connect (boost::bind (&AudioPanel::mapping_changed, this, _1));
        _active_jobs_connection = JobManager::instance()->ActiveJobsChanged.connect (boost::bind (&AudioPanel::active_jobs_changed, this, _1, _2));
 
        add_to_grid ();
+
+       _sizer->Layout ();
 }
 
 void
@@ -159,12 +163,6 @@ AudioPanel::add_to_grid ()
        s->Add (_delay_ms_label, 0, wxALIGN_CENTER_VERTICAL);
        _grid->Add (s, wxGBPosition(r, 1));
        ++r;
-
-       s = new wxBoxSizer (wxHORIZONTAL);
-       s->Add (_enable_language, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, DCPOMATIC_SIZER_GAP);
-       s->Add (_language->sizer(), 1, wxALIGN_CENTER_VERTICAL | wxRIGHT);
-       _grid->Add (s, wxGBPosition(r, 0), wxGBSpan(1, 2), wxEXPAND);
-       ++r;
 }
 
 AudioPanel::~AudioPanel ()
@@ -230,7 +228,7 @@ AudioPanel::film_content_changed (int property)
                }
                setup_description ();
                setup_peak ();
-               _sizer->Layout ();
+               layout ();
        } else if (property == AudioContentProperty::GAIN) {
                setup_peak ();
        } else if (property == DCPContentProperty::REFERENCE_AUDIO) {
@@ -244,14 +242,6 @@ AudioPanel::film_content_changed (int property)
                setup_sensitivity ();
        } else if (property == ContentProperty::VIDEO_FRAME_RATE) {
                setup_description ();
-       } else if (property == AudioContentProperty::LANGUAGE) {
-               if (ac.size() == 1 && ac.front()->audio->language()) {
-                       _enable_language->SetValue (true);
-                       _language->set (ac.front()->audio->language());
-               } else {
-                       _enable_language->SetValue (false);
-                       _language->set (boost::none);
-               }
        }
 }
 
@@ -317,7 +307,6 @@ AudioPanel::content_selection_changed ()
 
        film_content_changed (AudioContentProperty::STREAMS);
        film_content_changed (AudioContentProperty::GAIN);
-       film_content_changed (AudioContentProperty::LANGUAGE);
        film_content_changed (DCPContentProperty::REFERENCE_AUDIO);
 
        setup_sensitivity ();
@@ -353,8 +342,6 @@ AudioPanel::setup_sensitivity ()
        _delay->wrapped()->Enable (!ref);
        _mapping->Enable (!ref && single);
        _description->Enable (!ref && single);
-       _enable_language->Enable (!ref && single);
-       _language->enable (!ref && single && _enable_language->GetValue());
 }
 
 void
@@ -460,24 +447,3 @@ AudioPanel::set_film (shared_ptr<Film>)
        }
 }
 
-
-void
-AudioPanel::enable_language_clicked ()
-{
-       setup_sensitivity ();
-       auto sel = _parent->selected_audio ();
-       if (sel.size() == 1) {
-               sel.front()->audio->set_language (_enable_language->GetValue() ? _language->get() : boost::none);
-       }
-}
-
-
-void
-AudioPanel::language_changed ()
-{
-       auto sel = _parent->selected_audio ();
-       if (sel.size() == 1) {
-               sel.front()->audio->set_language (_language->get());
-       }
-}
-