Fix initial display of things.
[dcpomatic.git] / src / wx / film_editor.cc
index be99c201077e310abf819ff5d6c1311fd2bf6213..7ef18165f25fd70d9f7c8950acb191bf3d7f89eb 100644 (file)
@@ -149,6 +149,11 @@ FilmEditor::make_dcp_panel ()
        }
        ++r;
 
+       add_label_to_grid_bag_sizer (grid, _dcp_panel, _("DCP audio channels"), true, wxGBPosition (r, 0));
+       _dcp_audio_channels = new wxSpinCtrl (_dcp_panel, wxID_ANY);
+       grid->Add (_dcp_audio_channels, wxGBPosition (r, 1));
+       ++r;
+
        {
                add_label_to_grid_bag_sizer (grid, _dcp_panel, _("JPEG2000 bandwidth"), true, wxGBPosition (r, 0));
                wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
@@ -184,6 +189,7 @@ FilmEditor::make_dcp_panel ()
                _dcp_frame_rate->Append (std_to_wx (boost::lexical_cast<string> (*i)));
        }
 
+       _dcp_audio_channels->SetRange (0, MAX_AUDIO_CHANNELS);
        _j2k_bandwidth->SetRange (50, 250);
 }
 
@@ -211,10 +217,10 @@ FilmEditor::connect_to_widgets ()
        _dcp_content_type->Connect       (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED,      wxCommandEventHandler (FilmEditor::dcp_content_type_changed), 0, this);
        _dcp_frame_rate->Connect         (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED,      wxCommandEventHandler (FilmEditor::dcp_frame_rate_changed), 0, this);
        _best_dcp_frame_rate->Connect    (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED,       wxCommandEventHandler (FilmEditor::best_dcp_frame_rate_clicked), 0, this);
+       _dcp_audio_channels->Connect     (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::dcp_audio_channels_changed), 0, this);
        _with_subtitles->Connect         (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED,     wxCommandEventHandler (FilmEditor::with_subtitles_toggled), 0, this);
        _subtitle_offset->Connect        (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::subtitle_offset_changed), 0, this);
        _subtitle_scale->Connect         (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::subtitle_scale_changed), 0, this);
-       _colour_lut->Connect             (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED,      wxCommandEventHandler (FilmEditor::colour_lut_changed), 0, this);
        _j2k_bandwidth->Connect          (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::j2k_bandwidth_changed), 0, this);
        _audio_gain->Connect             (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::audio_gain_changed), 0, this);
        _audio_gain_calculate_button->Connect (
@@ -285,15 +291,6 @@ FilmEditor::make_video_panel ()
        }
        ++r;
 
-       add_label_to_grid_bag_sizer (grid, _video_panel, _("Colour look-up table"), true, wxGBPosition (r, 0));
-       _colour_lut = new wxChoice (_video_panel, wxID_ANY);
-       for (int i = 0; i < 2; ++i) {
-               _colour_lut->Append (std_to_wx (colour_lut_index_to_name (i)));
-       }
-       _colour_lut->SetSelection (0);
-       grid->Add (_colour_lut, wxGBPosition (r, 1), wxDefaultSpan, wxEXPAND);
-       ++r;
-
        _left_crop->SetRange (0, 1024);
        _top_crop->SetRange (0, 1024);
        _right_crop->SetRange (0, 1024);
@@ -445,6 +442,7 @@ FilmEditor::make_subtitle_panel ()
        
        _subtitle_offset->SetRange (-100, 100);
        _subtitle_scale->SetRange (1, 1000);
+       _subtitle_scale->SetValue (100);
 }
 
 void
@@ -546,16 +544,6 @@ FilmEditor::subtitle_scale_changed (wxCommandEvent &)
        c->set_subtitle_scale (_subtitle_scale->GetValue() / 100.0);
 }
 
-void
-FilmEditor::colour_lut_changed (wxCommandEvent &)
-{
-       if (!_film) {
-               return;
-       }
-       
-       _film->set_colour_lut (_colour_lut->GetSelection ());
-}
-
 void
 FilmEditor::j2k_bandwidth_changed (wxCommandEvent &)
 {
@@ -580,6 +568,16 @@ FilmEditor::dcp_frame_rate_changed (wxCommandEvent &)
                );
 }
 
+void
+FilmEditor::dcp_audio_channels_changed (wxCommandEvent &)
+{
+       if (!_film) {
+               return;
+       }
+
+       _film->set_dcp_audio_channels (_dcp_audio_channels->GetValue ());
+}
+
 
 /** Called when the metadata stored in the Film object has changed;
  *  so that we can update the GUI.
@@ -628,9 +626,6 @@ FilmEditor::film_changed (Film::Property p)
                setup_subtitle_control_sensitivity ();
                setup_dcp_name ();
                break;
-       case Film::COLOUR_LUT:
-               checked_set (_colour_lut, _film->colour_lut ());
-               break;
        case Film::J2K_BANDWIDTH:
                checked_set (_j2k_bandwidth, double (_film->j2k_bandwidth()) / 1e6);
                break;
@@ -659,6 +654,10 @@ FilmEditor::film_changed (Film::Property p)
                _best_dcp_frame_rate->Enable (_film->best_dcp_video_frame_rate () != _film->dcp_video_frame_rate ());
                break;
        }
+       case Film::DCP_AUDIO_CHANNELS:
+               _dcp_audio_channels->SetValue (_film->dcp_audio_channels ());
+               _audio_mapping->set_channels (_film->dcp_audio_channels ());
+               break;
        }
 }
 
@@ -863,10 +862,14 @@ FilmEditor::set_film (shared_ptr<Film> f)
        film_changed (Film::CONTAINER);
        film_changed (Film::SCALER);
        film_changed (Film::WITH_SUBTITLES);
-       film_changed (Film::COLOUR_LUT);
        film_changed (Film::J2K_BANDWIDTH);
        film_changed (Film::DCI_METADATA);
        film_changed (Film::DCP_VIDEO_FRAME_RATE);
+       film_changed (Film::DCP_AUDIO_CHANNELS);
+
+       if (!_film->content().empty ()) {
+               set_selection (_film->content().front ());
+       }
 
        wxListEvent ev;
        content_selection_changed (ev);
@@ -892,9 +895,8 @@ FilmEditor::set_things_sensitive (bool s)
        _filters_button->Enable (s);
        _scaler->Enable (s);
        _dcp_content_type->Enable (s);
-       _best_dcp_frame_rate->Enable (s);
        _dcp_frame_rate->Enable (s);
-       _colour_lut->Enable (s);
+       _dcp_audio_channels->Enable (s);
        _j2k_bandwidth->Enable (s);
        _audio_gain->Enable (s);
        _audio_gain_calculate_button->Enable (s);
@@ -907,6 +909,7 @@ FilmEditor::set_things_sensitive (bool s)
        setup_subtitle_control_sensitivity ();
        setup_show_audio_sensitivity ();
        setup_content_sensitivity ();
+       _best_dcp_frame_rate->Enable (s && _film && _film->best_dcp_video_frame_rate () != _film->dcp_video_frame_rate ());
 }
 
 /** Called when the `Edit filters' button has been clicked */
@@ -1192,6 +1195,9 @@ FilmEditor::content_remove_clicked (wxCommandEvent &)
        if (c) {
                _film->remove_content (c);
        }
+
+       wxListEvent ev;
+       content_selection_changed (ev);
 }
 
 void
@@ -1203,7 +1209,7 @@ FilmEditor::content_selection_changed (wxListEvent &)
        if (_audio_dialog && s && dynamic_pointer_cast<AudioContent> (s)) {
                _audio_dialog->set_content (dynamic_pointer_cast<AudioContent> (s));
        }
-       
+
        film_content_changed (s, ContentProperty::START);
        film_content_changed (s, ContentProperty::LENGTH);
        film_content_changed (s, VideoContentProperty::VIDEO_CROP);
@@ -1215,6 +1221,7 @@ FilmEditor::content_selection_changed (wxListEvent &)
        film_content_changed (s, FFmpegContentProperty::AUDIO_STREAMS);
        film_content_changed (s, FFmpegContentProperty::SUBTITLE_STREAM);
        film_content_changed (s, FFmpegContentProperty::SUBTITLE_STREAMS);
+       film_content_changed (s, FFmpegContentProperty::FILTERS);
        film_content_changed (s, SubtitleContentProperty::SUBTITLE_OFFSET);
        film_content_changed (s, SubtitleContentProperty::SUBTITLE_SCALE);
 }