+void
+FilmEditor::edit_content (shared_ptr<Content> c)
+{
+ shared_ptr<ImageMagickContent> im = dynamic_pointer_cast<ImageMagickContent> (c);
+ if (im) {
+ ImageMagickContentDialog* d = new ImageMagickContentDialog (this, im);
+ d->ShowModal ();
+ d->Destroy ();
+
+ im->set_video_length (d->video_length() * 24);
+ }
+}
+
+void
+FilmEditor::content_earlier_clicked (wxCommandEvent &)
+{
+ shared_ptr<Content> c = selected_content ();
+ if (c) {
+ _film->move_content_earlier (c);
+ }
+}
+
+void
+FilmEditor::content_later_clicked (wxCommandEvent &)
+{
+ shared_ptr<Content> c = selected_content ();
+ if (c) {
+ _film->move_content_later (c);
+ }
+}
+
+void
+FilmEditor::content_selection_changed (wxListEvent &)
+{
+ setup_content_button_sensitivity ();
+ setup_content_information ();
+}
+
+void
+FilmEditor::setup_content_information ()
+{
+ shared_ptr<Content> c = selected_content ();
+ if (!c) {
+ _content_information->SetValue (wxT (""));
+ return;
+ }
+
+ _content_information->SetValue (std_to_wx (c->information ()));
+}
+
+void
+FilmEditor::setup_content_button_sensitivity ()
+{
+ _content_add->Enable (_generally_sensitive);
+
+ shared_ptr<Content> selection = selected_content ();
+
+ _content_edit->Enable (selection && _generally_sensitive && dynamic_pointer_cast<ImageMagickContent> (selection));
+ _content_remove->Enable (selection && _generally_sensitive);
+ _content_earlier->Enable (selection && _generally_sensitive);
+ _content_later->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> ();
+ }
+
+ ContentList c = _film->content ();
+ if (s < 0 || size_t (s) >= c.size ()) {
+ return shared_ptr<Content> ();
+ }
+
+ return c[s];
+}
+
+void
+FilmEditor::setup_scaling_description ()
+{
+ wxString d;
+
+ int lines = 0;
+
+ d << wxString::Format (
+ _("Original video is %dx%d (%.2f:1)\n"),
+ _film->video_size().width, _film->video_size().height,
+ float (_film->video_size().width) / _film->video_size().height
+ );
+
+ ++lines;
+
+ Crop const crop = _film->crop ();
+ if (crop.left || crop.right || crop.top || crop.bottom) {
+ libdcp::Size const cropped = _film->cropped_size (_film->video_size ());
+ d << wxString::Format (
+ _("Cropped to %dx%d (%.2f:1)\n"),
+ cropped.width, cropped.height,
+ float (cropped.width) / cropped.height
+ );
+ ++lines;
+ }
+
+ Format const * format = _film->format ();
+ if (format) {
+ int const padding = format->dcp_padding (_film);
+ libdcp::Size scaled = format->dcp_size ();
+ scaled.width -= padding * 2;
+ d << wxString::Format (
+ _("Scaled to %dx%d (%.2f:1)\n"),
+ scaled.width, scaled.height,
+ float (scaled.width) / scaled.height
+ );
+ ++lines;
+
+ if (padding) {
+ d << wxString::Format (
+ _("Padded with black to %dx%d (%.2f:1)\n"),
+ format->dcp_size().width, format->dcp_size().height,
+ float (format->dcp_size().width) / format->dcp_size().height
+ );
+ ++lines;
+ }
+ }
+
+ for (int i = lines; i < 4; ++i) {
+ d << wxT (" \n");
+ }
+
+ _scaling_description->SetLabel (d);
+}