Forward-port 1e6 -> 1000000 fix from master.
[dcpomatic.git] / src / wx / film_editor.cc
index c0e169835f8f2cb9834a8e1aa5000a1d67fa1a4b..f2514da510358bab694432a43fb5e35ba8128ac2 100644 (file)
 #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"
 #include "lib/scaler.h"
+#include "lib/playlist.h"
 #include "timecode.h"
 #include "wx_util.h"
 #include "film_editor.h"
@@ -147,6 +149,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));
@@ -171,6 +177,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);
@@ -197,10 +208,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
@@ -216,16 +230,20 @@ FilmEditor::connect_to_widgets ()
        _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_earlier->Bind  (wxEVT_COMMAND_BUTTON_CLICKED,        boost::bind (&FilmEditor::content_earlier_clicked, this));
+       _content_later->Bind    (wxEVT_COMMAND_BUTTON_CLICKED,        boost::bind (&FilmEditor::content_later_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));
        _dcp_content_type->Bind (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&FilmEditor::dcp_content_type_changed, this));
        _frame_rate->Bind       (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&FilmEditor::frame_rate_changed, this));
        _best_frame_rate->Bind  (wxEVT_COMMAND_BUTTON_CLICKED,        boost::bind (&FilmEditor::best_frame_rate_clicked, this));
+       _encrypted->Bind        (wxEVT_COMMAND_CHECKBOX_CLICKED,      boost::bind (&FilmEditor::encrypted_toggled, this));
        _audio_channels->Bind   (wxEVT_COMMAND_SPINCTRL_UPDATED,      boost::bind (&FilmEditor::audio_channels_changed, this));
        _j2k_bandwidth->Bind    (wxEVT_COMMAND_SPINCTRL_UPDATED,      boost::bind (&FilmEditor::j2k_bandwidth_changed, this));
        _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
@@ -251,6 +269,10 @@ FilmEditor::make_content_panel ()
                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_earlier = new wxButton (_content_panel, wxID_UP);
+               b->Add (_content_earlier, 1, wxEXPAND);
+               _content_later = new wxButton (_content_panel, wxID_DOWN);
+               b->Add (_content_later, 1, wxEXPAND);
                _content_timeline = new wxButton (_content_panel, wxID_ANY, _("Timeline..."));
                b->Add (_content_timeline, 1, wxEXPAND | wxLEFT | wxRIGHT);
 
@@ -293,9 +315,20 @@ FilmEditor::j2k_bandwidth_changed ()
                return;
        }
        
-       _film->set_j2k_bandwidth (_j2k_bandwidth->GetValue() * 1e6);
+       _film->set_j2k_bandwidth (_j2k_bandwidth->GetValue() * 1000000);
 }
 
+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 ()
 {
@@ -330,6 +363,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.
@@ -373,12 +415,15 @@ 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 ();
                break;
        case Film::J2K_BANDWIDTH:
-               checked_set (_j2k_bandwidth, double (_film->j2k_bandwidth()) / 1e6);
+               checked_set (_j2k_bandwidth, double (_film->j2k_bandwidth()) / 1000000);
                break;
        case Film::USE_DCI_NAME:
                checked_set (_use_dci_name, _film->use_dci_name ());
@@ -406,7 +451,7 @@ FilmEditor::film_changed (Film::Property p)
                break;
        }
        case Film::AUDIO_CHANNELS:
-               _audio_channels->SetValue (_film->audio_channels ());
+               checked_set (_audio_channels, _film->audio_channels ());
                setup_dcp_name ();
                break;
        case Film::SEQUENCE_VIDEO:
@@ -416,6 +461,9 @@ FilmEditor::film_changed (Film::Property p)
                checked_set (_three_d, _film->three_d ());
                setup_dcp_name ();
                break;
+       case Film::INTEROP:
+               checked_set (_standard, _film->interop() ? 1 : 0);
+               break;
        }
 }
 
@@ -526,12 +574,15 @@ 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::ENCRYPTED);
        film_changed (Film::SEQUENCE_VIDEO);
        film_changed (Film::THREE_D);
+       film_changed (Film::INTEROP);
 
        if (!_film->content().empty ()) {
                set_selection (_film->content().front ());
@@ -553,8 +604,11 @@ FilmEditor::set_general_sensitivity (bool s)
        _content_add_file->Enable (s);
        _content_add_folder->Enable (s);
        _content_remove->Enable (s);
+       _content_earlier->Enable (s);
+       _content_later->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);
@@ -564,6 +618,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) {
@@ -740,6 +795,7 @@ FilmEditor::content_selection_changed ()
        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);
@@ -762,6 +818,8 @@ FilmEditor::setup_content_sensitivity ()
        shared_ptr<Content> selection = selected_content ();
 
        _content_remove->Enable (selection && _generally_sensitive);
+       _content_earlier->Enable (selection && _generally_sensitive);
+       _content_later->Enable (selection && _generally_sensitive);
        _content_timeline->Enable (_generally_sensitive);
 
        _video_panel->Enable    (selection && dynamic_pointer_cast<VideoContent>  (selection) && _generally_sensitive);
@@ -871,3 +929,17 @@ FilmEditor::three_d_changed ()
 
        _film->set_three_d (_three_d->GetValue ());
 }
+
+void
+FilmEditor::content_earlier_clicked ()
+{
+       _film->move_content_earlier (selected_content ());
+       content_selection_changed ();
+}
+
+void
+FilmEditor::content_later_clicked ()
+{
+       _film->move_content_later (selected_content ());
+       content_selection_changed ();
+}