Merge 1.0 in.
[dcpomatic.git] / src / wx / film_editor.cc
index 76c9d7812f4e31fd3032df3ead9365f1958de3c1..56b6973757e0f7be59a52f892060a4223b4123a9 100644 (file)
@@ -37,6 +37,8 @@
 #include "lib/ratio.h"
 #include "lib/config.h"
 #include "lib/still_image_content.h"
+#include "lib/moving_image_content.h"
+#include "lib/ffmpeg_content.h"
 #include "lib/sndfile_content.h"
 #include "lib/dcp_content_type.h"
 #include "lib/sound_processor.h"
@@ -146,6 +148,10 @@ FilmEditor::make_dcp_panel ()
        }
        ++r;
 
+       _encrypted = new wxCheckBox (_dcp_panel, wxID_ANY, wxT ("Encrypted"));
+       grid->Add (_encrypted, wxGBPosition (r, 0), wxGBSpan (1, 2));
+       ++r;
+
        add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Audio channels"), true, wxGBPosition (r, 0));
        _audio_channels = new wxSpinCtrl (_dcp_panel, wxID_ANY);
        grid->Add (_audio_channels, wxGBPosition (r, 1));
@@ -170,6 +176,11 @@ FilmEditor::make_dcp_panel ()
        }
        ++r;
 
+       add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Standard"), true, wxGBPosition (r, 0));
+       _standard = new wxChoice (_dcp_panel, wxID_ANY);
+       grid->Add (_standard, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
+       ++r;
+
        add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Scaler"), true, wxGBPosition (r, 0));
        _scaler = new wxChoice (_dcp_panel, wxID_ANY);
        grid->Add (_scaler, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
@@ -196,10 +207,13 @@ FilmEditor::make_dcp_panel ()
        }
 
        _audio_channels->SetRange (0, MAX_AUDIO_CHANNELS);
-       _j2k_bandwidth->SetRange (50, 250);
+       _j2k_bandwidth->SetRange (1, 250);
 
        _resolution->Append (_("2K"));
        _resolution->Append (_("4K"));
+
+       _standard->Append (_("SMPTE"));
+       _standard->Append (_("Interop"));
 }
 
 void
@@ -212,7 +226,8 @@ FilmEditor::connect_to_widgets ()
        _content->Bind          (wxEVT_COMMAND_LIST_ITEM_SELECTED,    boost::bind (&FilmEditor::content_selection_changed, this));
        _content->Bind          (wxEVT_COMMAND_LIST_ITEM_DESELECTED,  boost::bind (&FilmEditor::content_selection_changed, this));
        _content->Bind          (wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, boost::bind (&FilmEditor::content_right_click, this, _1));
-       _content_add->Bind      (wxEVT_COMMAND_BUTTON_CLICKED,        boost::bind (&FilmEditor::content_add_clicked, this));
+       _content_add_file->Bind (wxEVT_COMMAND_BUTTON_CLICKED,        boost::bind (&FilmEditor::content_add_file_clicked, this));
+       _content_add_folder->Bind (wxEVT_COMMAND_BUTTON_CLICKED,      boost::bind (&FilmEditor::content_add_folder_clicked, this));
        _content_remove->Bind   (wxEVT_COMMAND_BUTTON_CLICKED,        boost::bind (&FilmEditor::content_remove_clicked, this));
        _content_timeline->Bind (wxEVT_COMMAND_BUTTON_CLICKED,        boost::bind (&FilmEditor::content_timeline_clicked, this));
        _scaler->Bind           (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&FilmEditor::scaler_changed, this));
@@ -224,6 +239,7 @@ FilmEditor::connect_to_widgets ()
        _resolution->Bind       (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&FilmEditor::resolution_changed, this));
        _sequence_video->Bind   (wxEVT_COMMAND_CHECKBOX_CLICKED,      boost::bind (&FilmEditor::sequence_video_changed, this));
        _three_d->Bind          (wxEVT_COMMAND_CHECKBOX_CLICKED,      boost::bind (&FilmEditor::three_d_changed, this));
+       _standard->Bind         (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&FilmEditor::standard_changed, this));
 }
 
 void
@@ -243,8 +259,10 @@ FilmEditor::make_content_panel ()
                _content->SetColumnWidth (0, 512);
 
                wxBoxSizer* b = new wxBoxSizer (wxVERTICAL);
-               _content_add = new wxButton (_content_panel, wxID_ANY, _("Add..."));
-               b->Add (_content_add, 1, wxEXPAND | wxLEFT | wxRIGHT);
+               _content_add_file = new wxButton (_content_panel, wxID_ANY, _("Add file(s)..."));
+               b->Add (_content_add_file, 1, wxEXPAND | wxLEFT | wxRIGHT);
+               _content_add_folder = new wxButton (_content_panel, wxID_ANY, _("Add folder..."));
+               b->Add (_content_add_folder, 1, wxEXPAND | wxLEFT | wxRIGHT);
                _content_remove = new wxButton (_content_panel, wxID_ANY, _("Remove"));
                b->Add (_content_remove, 1, wxEXPAND | wxLEFT | wxRIGHT);
                _content_timeline = new wxButton (_content_panel, wxID_ANY, _("Timeline..."));
@@ -292,6 +310,17 @@ FilmEditor::j2k_bandwidth_changed ()
        _film->set_j2k_bandwidth (_j2k_bandwidth->GetValue() * 1e6);
 }
 
+void
+FilmEditor::encrypted_toggled ()
+{
+       if (!_film) {
+               return;
+       }
+
+       _film->set_encrypted (_encrypted->GetValue ());
+}
+                              
+/** Called when the name widget has been changed */
 void
 FilmEditor::frame_rate_changed ()
 {
@@ -326,6 +355,15 @@ FilmEditor::resolution_changed ()
        _film->set_resolution (_resolution->GetSelection() == 0 ? RESOLUTION_2K : RESOLUTION_4K);
 }
 
+void
+FilmEditor::standard_changed ()
+{
+       if (!_film) {
+               return;
+       }
+
+       _film->set_interop (_standard->GetSelection() == 1);
+}
 
 /** Called when the metadata stored in the Film object has changed;
  *  so that we can update the GUI.
@@ -369,6 +407,9 @@ FilmEditor::film_changed (Film::Property p)
        case Film::SCALER:
                checked_set (_scaler, Scaler::as_index (_film->scaler ()));
                break;
+       case Film::ENCRYPTED:
+               checked_set (_encrypted, _film->encrypted ());
+               break;
        case Film::RESOLUTION:
                checked_set (_resolution, _film->resolution() == RESOLUTION_2K ? 0 : 1);
                setup_dcp_name ();
@@ -410,6 +451,10 @@ FilmEditor::film_changed (Film::Property p)
                break;
        case Film::THREE_D:
                checked_set (_three_d, _film->three_d ());
+               setup_dcp_name ();
+               break;
+       case Film::INTEROP:
+               checked_set (_standard, _film->interop() ? 1 : 0);
                break;
        }
 }
@@ -496,8 +541,6 @@ FilmEditor::set_film (shared_ptr<Film> f)
 {
        set_general_sensitivity (f != 0);
 
-       content_selection_changed ();
-
        if (_film == f) {
                return;
        }
@@ -523,16 +566,20 @@ FilmEditor::set_film (shared_ptr<Film> f)
        film_changed (Film::RESOLUTION);
        film_changed (Film::SCALER);
        film_changed (Film::WITH_SUBTITLES);
+       film_changed (Film::ENCRYPTED);
        film_changed (Film::J2K_BANDWIDTH);
        film_changed (Film::DCI_METADATA);
        film_changed (Film::VIDEO_FRAME_RATE);
        film_changed (Film::AUDIO_CHANNELS);
        film_changed (Film::SEQUENCE_VIDEO);
        film_changed (Film::THREE_D);
+       film_changed (Film::INTEROP);
 
        if (!_film->content().empty ()) {
                set_selection (_film->content().front ());
        }
+
+       content_selection_changed ();
 }
 
 void
@@ -545,10 +592,12 @@ FilmEditor::set_general_sensitivity (bool s)
        _use_dci_name->Enable (s);
        _edit_dci_button->Enable (s);
        _content->Enable (s);
-       _content_add->Enable (s);
+       _content_add_file->Enable (s);
+       _content_add_folder->Enable (s);
        _content_remove->Enable (s);
        _content_timeline->Enable (s);
        _dcp_content_type->Enable (s);
+       _encrypted->Enable (s);
        _frame_rate->Enable (s);
        _audio_channels->Enable (s);
        _j2k_bandwidth->Enable (s);
@@ -558,6 +607,7 @@ FilmEditor::set_general_sensitivity (bool s)
        _resolution->Enable (s);
        _scaler->Enable (s);
        _three_d->Enable (s);
+       _standard->Enable (s);
 
        /* Set the panels in the content notebook */
        for (list<FilmEditorPanel*>::iterator i = _panels.begin(); i != _panels.end(); ++i) {
@@ -657,7 +707,7 @@ FilmEditor::setup_content ()
 }
 
 void
-FilmEditor::content_add_clicked ()
+FilmEditor::content_add_file_clicked ()
 {
        wxFileDialog* d = new wxFileDialog (this, _("Choose a file or files"), wxT (""), wxT (""), wxT ("*.*"), wxFD_MULTIPLE);
        int const r = d->ShowModal ();
@@ -670,12 +720,14 @@ FilmEditor::content_add_clicked ()
        wxArrayString paths;
        d->GetPaths (paths);
 
+       /* XXX: check for lots of files here and do something */
+
        for (unsigned int i = 0; i < paths.GetCount(); ++i) {
                boost::filesystem::path p (wx_to_std (paths[i]));
 
                shared_ptr<Content> c;
 
-               if (StillImageContent::valid_file (p)) {
+               if (valid_image_file (p)) {
                        c.reset (new StillImageContent (_film, p));
                } else if (SndfileContent::valid_file (p)) {
                        c.reset (new SndfileContent (_film, p));
@@ -687,6 +739,24 @@ FilmEditor::content_add_clicked ()
        }
 }
 
+void
+FilmEditor::content_add_folder_clicked ()
+{
+       wxDirDialog* d = new wxDirDialog (this, _("Choose a folder"), wxT (""), wxDD_DIR_MUST_EXIST);
+       int const r = d->ShowModal ();
+       d->Destroy ();
+       
+       if (r != wxID_OK) {
+               return;
+       }
+
+       _film->examine_and_add_content (
+               shared_ptr<MovingImageContent> (
+                       new MovingImageContent (_film, boost::filesystem::path (wx_to_std (d->GetPath ())))
+                       )
+               );
+}
+
 void
 FilmEditor::content_remove_clicked ()
 {
@@ -707,11 +777,14 @@ FilmEditor::content_selection_changed ()
        /* All other sensitivity in content panels should be triggered by
           one of these.
        */
-       film_content_changed (s, ContentProperty::START);
+       film_content_changed (s, ContentProperty::POSITION);
        film_content_changed (s, ContentProperty::LENGTH);
+       film_content_changed (s, ContentProperty::TRIM_START);
+       film_content_changed (s, ContentProperty::TRIM_END);
        film_content_changed (s, VideoContentProperty::VIDEO_CROP);
        film_content_changed (s, VideoContentProperty::VIDEO_RATIO);
        film_content_changed (s, VideoContentProperty::VIDEO_FRAME_TYPE);
+       film_content_changed (s, VideoContentProperty::COLOUR_CONVERSION);
        film_content_changed (s, AudioContentProperty::AUDIO_GAIN);
        film_content_changed (s, AudioContentProperty::AUDIO_DELAY);
        film_content_changed (s, AudioContentProperty::AUDIO_MAPPING);
@@ -728,7 +801,8 @@ FilmEditor::content_selection_changed ()
 void
 FilmEditor::setup_content_sensitivity ()
 {
-       _content_add->Enable (_generally_sensitive);
+       _content_add_file->Enable (_generally_sensitive);
+       _content_add_folder->Enable (_generally_sensitive);
 
        shared_ptr<Content> selection = selected_content ();