more
[dcpomatic.git] / src / wx / dcp_panel.cc
index 914068b113321bac45cee520310fd3cd703d0ccf..2ce2813d4249fae270641110dd6adbe9037bbdf6 100644 (file)
 #include "lib/text_content.h"
 #include "lib/util.h"
 #include "lib/video_content.h"
-#include "lib/warnings.h"
 #include <dcp/locale_convert.h>
-DCPOMATIC_DISABLE_WARNINGS
+#include <dcp/warnings.h>
+LIBDCP_DISABLE_WARNINGS
 #include <wx/gbsizer.h>
 #include <wx/notebook.h>
 #include <wx/spinctrl.h>
 #include <wx/wx.h>
-DCPOMATIC_ENABLE_WARNINGS
+LIBDCP_ENABLE_WARNINGS
 #include <boost/lexical_cast.hpp>
 
 
@@ -125,9 +125,6 @@ DCPPanel::DCPPanel (wxNotebook* n, shared_ptr<Film> film, weak_ptr<FilmViewer> v
        _notebook = new wxNotebook (_panel, wxID_ANY);
        _sizer->Add (_notebook, 1, wxEXPAND | wxTOP, 6);
 
-       _notebook->AddPage (make_video_panel (), _("Video"), false);
-       _notebook->AddPage (make_audio_panel (), _("Audio"), false);
-
        _name->Bind                  (wxEVT_TEXT,     boost::bind(&DCPPanel::name_changed, this));
        _use_isdcf_name->Bind        (wxEVT_CHECKBOX, boost::bind(&DCPPanel::use_isdcf_name_toggled, this));
        _copy_isdcf_name_button->Bind(wxEVT_BUTTON,   boost::bind(&DCPPanel::copy_isdcf_name_button_clicked, this));
@@ -468,7 +465,6 @@ DCPPanel::film_changed (Film::Property p)
                break;
        case Film::Property::CONTENT:
                setup_dcp_name ();
-               setup_sensitivity ();
                break;
        case Film::Property::AUDIO_LANGUAGE:
        {
@@ -476,9 +472,13 @@ DCPPanel::film_changed (Film::Property p)
                checked_set (_enable_audio_language, static_cast<bool>(al));
                checked_set (_audio_language, al ? std_to_wx(al->to_string()) : wxT(""));
                setup_dcp_name ();
-               setup_sensitivity ();
                break;
        }
+       case Film::Property::AUDIO_FRAME_RATE:
+               if (_audio_sample_rate) {
+                       checked_set (_audio_sample_rate, _film->audio_frame_rate() == 48000 ? 0 : 1);
+               }
+               break;
        case Film::Property::CONTENT_VERSIONS:
        case Film::Property::VERSION_NUMBER:
        case Film::Property::RELEASE_TERRITORY:
@@ -515,7 +515,6 @@ DCPPanel::film_content_changed (int property)
            property == DCPContentProperty::REFERENCE_AUDIO ||
            property == DCPContentProperty::REFERENCE_TEXT) {
                setup_dcp_name ();
-               setup_sensitivity ();
        }
 }
 
@@ -624,6 +623,7 @@ DCPPanel::set_film (shared_ptr<Film> film)
        film_changed (Film::Property::REEL_LENGTH);
        film_changed (Film::Property::REENCODE_J2K);
        film_changed (Film::Property::AUDIO_LANGUAGE);
+       film_changed (Film::Property::AUDIO_FRAME_RATE);
 
        set_general_sensitivity(static_cast<bool>(_film));
 }
@@ -633,54 +633,8 @@ void
 DCPPanel::set_general_sensitivity (bool s)
 {
        _generally_sensitive = s;
-       setup_sensitivity ();
-}
-
-
-void
-DCPPanel::setup_sensitivity ()
-{
-       _name->Enable                   (_generally_sensitive);
-       _use_isdcf_name->Enable         (_generally_sensitive);
-       _dcp_content_type->Enable       (_generally_sensitive);
-       _copy_isdcf_name_button->Enable (_generally_sensitive);
-       _enable_audio_language->Enable  (_generally_sensitive);
-       _audio_language->Enable         (_enable_audio_language->GetValue());
-       _edit_audio_language->Enable    (_enable_audio_language->GetValue());
-       _encrypted->Enable              (_generally_sensitive);
-       _reel_type->Enable              (_generally_sensitive && _film && !_film->references_dcp_video() && !_film->references_dcp_audio());
-       _reel_length->Enable            (_generally_sensitive && _film && _film->reel_type() == ReelType::BY_LENGTH);
-       _markers->Enable                (_generally_sensitive && _film && !_film->interop());
-       _metadata->Enable               (_generally_sensitive);
-       _frame_rate_choice->Enable      (_generally_sensitive && _film && !_film->references_dcp_video() && !_film->contains_atmos_content());
-       _frame_rate_spin->Enable        (_generally_sensitive && _film && !_film->references_dcp_video() && !_film->contains_atmos_content());
-       _audio_channels->Enable         (_generally_sensitive && _film && !_film->references_dcp_audio() && !_film->contains_atmos_content());
-       _audio_processor->Enable        (_generally_sensitive && _film && !_film->references_dcp_audio());
-       _j2k_bandwidth->Enable          (_generally_sensitive && _film && !_film->references_dcp_video());
-       _container->Enable              (_generally_sensitive && _film && !_film->references_dcp_video());
-       _best_frame_rate->Enable (
-               _generally_sensitive &&
-               _film &&
-               _film->best_video_frame_rate () != _film->video_frame_rate() &&
-               !_film->references_dcp_video() &&
-               !_film->contains_atmos_content()
-               );
-       _resolution->Enable             (_generally_sensitive && _film && !_film->references_dcp_video());
-       _three_d->Enable                (_generally_sensitive && _film && !_film->references_dcp_video());
-
-       _standard->Enable (
-               _generally_sensitive &&
-               _film &&
-               !_film->references_dcp_video() &&
-               !_film->references_dcp_audio() &&
-               !_film->contains_atmos_content()
-               );
-
-       _reencode_j2k->Enable           (_generally_sensitive && _film);
-       _show_audio->Enable             (_generally_sensitive && _film);
 }
 
-
 void
 DCPPanel::use_isdcf_name_toggled ()
 {
@@ -892,6 +846,11 @@ DCPPanel::make_audio_panel ()
        _audio_channels = new wxChoice (panel, wxID_ANY);
        setup_audio_channels_choice (_audio_channels, minimum_allowed_audio_channels ());
 
+       if (Config::instance()->allow_96khz_audio()) {
+               _audio_sample_rate_label = create_label (panel, _("Sample rate"), true);
+               _audio_sample_rate = new wxChoice (panel, wxID_ANY);
+       }
+
        _processor_label = create_label (panel, _("Processor"), true);
        _audio_processor = new wxChoice (panel, wxID_ANY);
        add_audio_processors ();
@@ -899,9 +858,17 @@ DCPPanel::make_audio_panel ()
        _show_audio = new Button (panel, _("Show graph of audio levels..."));
 
        _audio_channels->Bind (wxEVT_CHOICE, boost::bind (&DCPPanel::audio_channels_changed, this));
+       if (_audio_sample_rate) {
+               _audio_sample_rate->Bind (wxEVT_CHOICE, boost::bind(&DCPPanel::audio_sample_rate_changed, this));
+       }
        _audio_processor->Bind (wxEVT_CHOICE, boost::bind (&DCPPanel::audio_processor_changed, this));
        _show_audio->Bind (wxEVT_BUTTON, boost::bind (&DCPPanel::show_audio_clicked, this));
 
+       if (_audio_sample_rate) {
+               _audio_sample_rate->Append (_("48kHz"));
+               _audio_sample_rate->Append (_("96kHz"));
+       }
+
        add_audio_panel_to_grid ();
 
        return panel;
@@ -917,6 +884,12 @@ DCPPanel::add_audio_panel_to_grid ()
        _audio_grid->Add (_audio_channels, wxGBPosition (r, 1));
        ++r;
 
+       if (_audio_sample_rate_label && _audio_sample_rate) {
+               add_label_to_sizer (_audio_grid, _audio_sample_rate_label, true, wxGBPosition(r, 0));
+               _audio_grid->Add (_audio_sample_rate, wxGBPosition(r, 1));
+               ++r;
+       }
+
        add_label_to_sizer (_audio_grid, _processor_label, true, wxGBPosition (r, 0));
        _audio_grid->Add (_audio_processor, wxGBPosition (r, 1));
        ++r;
@@ -999,7 +972,6 @@ DCPPanel::add_audio_processors ()
 void
 DCPPanel::enable_audio_language_toggled ()
 {
-       setup_sensitivity ();
        if (_enable_audio_language->GetValue()) {
                auto al = wx_to_std (_audio_language->GetLabel());
                _film->set_audio_language (al.empty() ? dcp::LanguageTag("en-US") : dcp::LanguageTag(al));
@@ -1019,3 +991,12 @@ DCPPanel::edit_audio_language_clicked ()
        d->Destroy ();
 }
 
+
+void
+DCPPanel::audio_sample_rate_changed ()
+{
+       if (_audio_sample_rate) {
+               _film->set_audio_frame_rate (_audio_sample_rate->GetSelection() == 0 ? 48000 : 96000);
+       }
+}
+