+ shared_ptr<Content> c = selected_content ();
+ if (c) {
+ _film->remove_content (c);
+ }
+
+ wxListEvent ev;
+ content_selection_changed (ev);
+}
+
+void
+FilmEditor::content_selection_changed (wxListEvent &)
+{
+ setup_content_sensitivity ();
+ shared_ptr<Content> s = selected_content ();
+
+ 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);
+ film_content_changed (s, VideoContentProperty::VIDEO_RATIO);
+ film_content_changed (s, AudioContentProperty::AUDIO_GAIN);
+ film_content_changed (s, AudioContentProperty::AUDIO_DELAY);
+ film_content_changed (s, AudioContentProperty::AUDIO_MAPPING);
+ film_content_changed (s, FFmpegContentProperty::AUDIO_STREAM);
+ 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);
+}
+
+void
+FilmEditor::setup_content_sensitivity ()
+{
+ _content_add->Enable (_generally_sensitive);
+
+ shared_ptr<Content> selection = selected_content ();
+
+ _content_remove->Enable (selection && _generally_sensitive);
+ _content_timeline->Enable (_generally_sensitive);
+
+ _video_panel->Enable (selection && dynamic_pointer_cast<VideoContent> (selection) && _generally_sensitive);
+ _audio_panel->Enable (selection && dynamic_pointer_cast<AudioContent> (selection) && _generally_sensitive);
+ _subtitle_panel->Enable (selection && dynamic_pointer_cast<FFmpegContent> (selection) && _generally_sensitive);
+ _timing_panel->Enable (selection && _generally_sensitive);
+}
+
+shared_ptr<Content>
+FilmEditor::selected_content ()
+{
+ int const s = _content->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+ if (s == -1) {
+ return shared_ptr<Content> ();
+ }
+
+ Playlist::ContentList c = _film->content ();
+ if (s < 0 || size_t (s) >= c.size ()) {
+ return shared_ptr<Content> ();
+ }
+
+ return c[s];
+}
+
+shared_ptr<VideoContent>
+FilmEditor::selected_video_content ()
+{
+ shared_ptr<Content> c = selected_content ();
+ if (!c) {
+ return shared_ptr<VideoContent> ();
+ }
+
+ return dynamic_pointer_cast<VideoContent> (c);
+}
+
+shared_ptr<AudioContent>
+FilmEditor::selected_audio_content ()
+{
+ shared_ptr<Content> c = selected_content ();
+ if (!c) {
+ return shared_ptr<AudioContent> ();
+ }
+
+ return dynamic_pointer_cast<AudioContent> (c);
+}
+
+shared_ptr<SubtitleContent>
+FilmEditor::selected_subtitle_content ()
+{
+ shared_ptr<Content> c = selected_content ();
+ if (!c) {
+ return shared_ptr<SubtitleContent> ();
+ }
+
+ return dynamic_pointer_cast<SubtitleContent> (c);
+}
+
+void
+FilmEditor::setup_scaling_description ()
+{
+ shared_ptr<VideoContent> vc = selected_video_content ();
+ if (!vc) {
+ _scaling_description->SetLabel ("");
+ return;
+ }
+
+ wxString d;
+
+ int lines = 0;
+
+ if (vc->video_size().width && vc->video_size().height) {
+ d << wxString::Format (
+ _("Original video is %dx%d (%.2f:1)\n"),
+ vc->video_size().width, vc->video_size().height,
+ float (vc->video_size().width) / vc->video_size().height
+ );
+ ++lines;
+ }
+
+ Crop const crop = vc->crop ();
+ if ((crop.left || crop.right || crop.top || crop.bottom) && vc->video_size() != libdcp::Size (0, 0)) {
+ libdcp::Size cropped = vc->video_size ();
+ cropped.width -= crop.left + crop.right;
+ cropped.height -= crop.top + crop.bottom;
+ d << wxString::Format (
+ _("Cropped to %dx%d (%.2f:1)\n"),
+ cropped.width, cropped.height,
+ float (cropped.width) / cropped.height
+ );
+ ++lines;
+ }
+
+ Ratio const * ratio = vc->ratio ();
+ if (ratio) {
+ libdcp::Size container_size = _film->container()->size (_film->full_frame ());
+
+ libdcp::Size const scaled = ratio->size (container_size);
+ d << wxString::Format (
+ _("Scaled to %dx%d (%.2f:1)\n"),
+ scaled.width, scaled.height,
+ float (scaled.width) / scaled.height
+ );
+ ++lines;
+
+ if (scaled != container_size) {
+ d << wxString::Format (
+ _("Padded with black to %dx%d (%.2f:1)\n"),
+ container_size.width, container_size.height,
+ float (container_size.width) / container_size.height
+ );
+ ++lines;
+ }
+ }
+
+ for (int i = lines; i < 4; ++i) {
+ d << wxT ("\n ");
+ }
+
+ _scaling_description->SetLabel (d);
+}
+
+void
+FilmEditor::loop_content_toggled (wxCommandEvent &)
+{
+ if (_loop_content->GetValue ()) {
+ _film->set_loop (_loop_count->GetValue ());