Add total-playlist loop option; move state of content list into the Playlist.
[dcpomatic.git] / src / wx / film_editor.cc
index b6be39e9b5d90e3a8bf6afd8007422e6c49c95b5..4f08953b9537ffce7eef4d2185cbd779727aca91 100644 (file)
@@ -214,6 +214,8 @@ FilmEditor::connect_to_widgets ()
        _content_edit->Connect           (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED,       wxCommandEventHandler (FilmEditor::content_edit_clicked), 0, this);
        _content_earlier->Connect        (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED,       wxCommandEventHandler (FilmEditor::content_earlier_clicked), 0, this);
        _content_later->Connect          (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED,       wxCommandEventHandler (FilmEditor::content_later_clicked), 0, this);
+       _loop_content->Connect           (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED,     wxCommandEventHandler (FilmEditor::loop_content_toggled), 0, this);
+       _loop_count->Connect             (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::loop_count_changed), 0, this);
        _left_crop->Connect              (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::left_crop_changed), 0, this);
        _right_crop->Connect             (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::right_crop_changed), 0, this);
        _top_crop->Connect               (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::top_crop_changed), 0, this);
@@ -369,8 +371,18 @@ FilmEditor::make_content_panel ()
                 _content_sizer->Add (s, 1, wxEXPAND | wxALL, 6);
         }
 
+       wxBoxSizer* h = new wxBoxSizer (wxHORIZONTAL);
+       _loop_content = new wxCheckBox (_content_panel, wxID_ANY, _("Loop everything"));
+       h->Add (_loop_content, 0, wxALL, 6);
+       _loop_count = new wxSpinCtrl (_content_panel, wxID_ANY);
+       h->Add (_loop_count, 0, wxALL, 6);
+       add_label_to_sizer (h, _content_panel, _("times"));
+       _content_sizer->Add (h, 0, wxALL, 6);
+
        _content_information = new wxTextCtrl (_content_panel, wxID_ANY, wxT ("\n\n\n\n"), wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_MULTILINE);
        _content_sizer->Add (_content_information, 1, wxEXPAND | wxALL, 6);
+
+       _loop_count->SetRange (2, 1024);
 }
 
 void
@@ -620,6 +632,11 @@ FilmEditor::film_changed (Film::Property p)
                setup_show_audio_sensitivity ();
                setup_length ();
                break;
+       case Film::LOOP:
+               checked_set (_loop_content, _film->loop() > 1);
+               checked_set (_loop_count, _film->loop());
+               setup_loop_sensitivity ();
+               break;
        case Film::TRUST_CONTENT_HEADERS:
                checked_set (_trust_content_headers, _film->trust_content_headers ());
                break;
@@ -890,6 +907,7 @@ FilmEditor::set_film (shared_ptr<Film> f)
        film_changed (Film::NAME);
        film_changed (Film::USE_DCI_NAME);
        film_changed (Film::CONTENT);
+       film_changed (Film::LOOP);
        film_changed (Film::TRUST_CONTENT_HEADERS);
        film_changed (Film::DCP_CONTENT_TYPE);
        film_changed (Film::FORMAT);
@@ -1491,3 +1509,27 @@ FilmEditor::trim_type_changed (wxCommandEvent &)
 {
        _film->set_trim_type (_trim_type->GetSelection () == 0 ? Film::CPL : Film::ENCODE);
 }
+
+void
+FilmEditor::loop_content_toggled (wxCommandEvent &)
+{
+       if (_loop_content->GetValue ()) {
+               _film->set_loop (_loop_count->GetValue ());
+       } else {
+               _film->set_loop (1);
+       }
+               
+       setup_loop_sensitivity ();
+}
+
+void
+FilmEditor::loop_count_changed (wxCommandEvent &)
+{
+       _film->set_loop (_loop_count->GetValue ());
+}
+
+void
+FilmEditor::setup_loop_sensitivity ()
+{
+       _loop_count->Enable (_loop_content->GetValue ());
+}