more
[dcpomatic.git] / src / wx / dcp_panel.cc
index 54db2632fcc86c4a40aef69cb5646a152978ab70..2ce2813d4249fae270641110dd6adbe9037bbdf6 100644 (file)
 #include "smpte_metadata_dialog.h"
 #include "static_text.h"
 #include "wx_util.h"
-#include "lib/ratio.h"
+#include "lib/audio_content.h"
+#include "lib/audio_processor.h"
 #include "lib/config.h"
+#include "lib/dcp_content.h"
 #include "lib/dcp_content_type.h"
-#include "lib/util.h"
-#include "lib/film.h"
 #include "lib/ffmpeg_content.h"
-#include "lib/audio_processor.h"
-#include "lib/video_content.h"
+#include "lib/film.h"
+#include "lib/ratio.h"
 #include "lib/text_content.h"
-#include "lib/dcp_content.h"
-#include "lib/audio_content.h"
+#include "lib/util.h"
+#include "lib/video_content.h"
 #include <dcp/locale_convert.h>
-#include <wx/wx.h>
-#include <wx/notebook.h>
+#include <dcp/warnings.h>
+LIBDCP_DISABLE_WARNINGS
 #include <wx/gbsizer.h>
+#include <wx/notebook.h>
 #include <wx/spinctrl.h>
+#include <wx/wx.h>
+LIBDCP_ENABLE_WARNINGS
 #include <boost/lexical_cast.hpp>
-#include <iostream>
 
 
-using std::cout;
 using std::list;
-using std::string;
-using std::vector;
-using std::pair;
-using std::max;
 using std::make_pair;
-using boost::lexical_cast;
+using std::max;
+using std::pair;
 using std::shared_ptr;
+using std::string;
+using std::vector;
 using std::weak_ptr;
+using boost::lexical_cast;
 #if BOOST_VERSION >= 106100
 using namespace boost::placeholders;
 #endif
@@ -124,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));
@@ -179,7 +177,7 @@ DCPPanel::add_to_grid ()
        {
                auto s = new wxBoxSizer (wxHORIZONTAL);
                s->Add (_copy_isdcf_name_button, 0, wxLEFT, DCPOMATIC_SIZER_X_GAP);
-               _grid->Add (s, wxGBPosition(r, 1), wxDefaultSpan, wxEXPAND);
+               _grid->Add (s, wxGBPosition(r, 1), wxDefaultSpan, wxEXPAND | wxBOTTOM, DCPOMATIC_CHECKBOX_BOTTOM_PAD);
        }
        ++r;
 
@@ -188,9 +186,9 @@ DCPPanel::add_to_grid ()
 
        {
                auto s = new wxBoxSizer (wxHORIZONTAL);
-               s->Add (_enable_audio_language, 0, wxALIGN_CENTER_VERTICAL);
-               s->Add (_audio_language, 1, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, DCPOMATIC_SIZER_GAP);
-               s->Add (_edit_audio_language, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, DCPOMATIC_SIZER_GAP);
+               s->Add (_enable_audio_language, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, DCPOMATIC_SIZER_GAP);
+               s->Add (_audio_language, 1, wxALIGN_CENTER_VERTICAL | wxBOTTOM, DCPOMATIC_CHECKBOX_BOTTOM_PAD);
+               s->Add (_edit_audio_language, 0, wxALIGN_CENTER_VERTICAL | wxBOTTOM, DCPOMATIC_CHECKBOX_BOTTOM_PAD);
                _grid->Add (s, wxGBPosition(r, 0), wxGBSpan(1, 2), wxEXPAND | wxALIGN_CENTER_VERTICAL);
        }
        ++r;
@@ -467,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:
        {
@@ -475,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:
@@ -506,14 +507,14 @@ DCPPanel::film_content_changed (int property)
            property == TextContentProperty::BURN ||
            property == TextContentProperty::LANGUAGE ||
            property == TextContentProperty::LANGUAGE_IS_ADDITIONAL ||
-           property == VideoContentProperty::SCALE ||
+           property == VideoContentProperty::CUSTOM_RATIO ||
+           property == VideoContentProperty::CUSTOM_SIZE ||
            property == VideoContentProperty::BURNT_SUBTITLE_LANGUAGE ||
            property == VideoContentProperty::CROP ||
            property == DCPContentProperty::REFERENCE_VIDEO ||
            property == DCPContentProperty::REFERENCE_AUDIO ||
            property == DCPContentProperty::REFERENCE_TEXT) {
                setup_dcp_name ();
-               setup_sensitivity ();
        }
 }
 
@@ -622,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));
 }
@@ -631,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 ()
 {
@@ -890,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 ();
@@ -897,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;
@@ -915,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;
@@ -997,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));
@@ -1017,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);
+       }
+}
+