}
++r;
- _frame_rate_description = new wxStaticText (_film_panel, wxID_ANY, wxT (" \n "), wxDefaultPosition, wxDefaultSize);
+ _frame_rate_description = new wxStaticText (_film_panel, wxID_ANY, wxT (" \n \n "), wxDefaultPosition, wxDefaultSize);
- grid->Add (video_control (_frame_rate_description), wxGBPosition (r, 0), wxGBSpan (1, 2), wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 6);
+ grid->Add (_frame_rate_description, wxGBPosition (r, 0), wxGBSpan (1, 2), wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 6);
wxFont font = _frame_rate_description->GetFont();
font.SetStyle(wxFONTSTYLE_ITALIC);
font.SetPointSize(font.GetPointSize() - 1);
grid->Add (_bottom_crop, wxGBPosition (r, 1));
++r;
+ _scaling_description = new wxStaticText (_video_panel, wxID_ANY, wxT ("\n \n \n \n"), wxDefaultPosition, wxDefaultSize);
+ grid->Add (_scaling_description, wxGBPosition (r, 0), wxGBSpan (1, 2), wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 6);
+ wxFont font = _scaling_description->GetFont();
+ font.SetStyle(wxFONTSTYLE_ITALIC);
+ font.SetPointSize(font.GetPointSize() - 1);
+ _scaling_description->SetFont(font);
+ ++r;
+
/* VIDEO-only stuff */
{
- video_control (add_label_to_grid_bag_sizer (grid, _video_panel, _("Filters"), wxGBPosition (r, 0)));
+ add_label_to_grid_bag_sizer (grid, _video_panel, _("Filters"), wxGBPosition (r, 0));
wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
_filters = new wxStaticText (_video_panel, wxID_ANY, _("None"));
- video_control (_filters);
s->Add (_filters, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxRIGHT, 6);
_filters_button = new wxButton (_video_panel, wxID_ANY, _("Edit..."));
- video_control (_filters_button);
s->Add (_filters_button, 0);
grid->Add (s, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
}
_subtitle_sizer->Add (grid, 0, wxALL, 8);
_with_subtitles = new wxCheckBox (_subtitle_panel, wxID_ANY, _("With Subtitles"));
- video_control (_with_subtitles);
grid->Add (_with_subtitles, 1);
- _subtitle_stream = new wxChoice (_subtitle_panel, wxID_ANY);
- grid->Add (video_control (_subtitle_stream));
+ _ffmpeg_subtitle_stream = new wxChoice (_subtitle_panel, wxID_ANY);
+ grid->Add (_ffmpeg_subtitle_stream);
- add_label_to_sizer (grid, _subtitle_panel, _("Subtitle Offset"));
- _subtitle_offset = new wxSpinCtrl (_subtitle_panel);
- grid->Add (_subtitle_offset, 1);
+ {
- video_control (add_label_to_sizer (grid, _subtitle_panel, _("Subtitle Offset")));
++ add_label_to_sizer (grid, _subtitle_panel, _("Subtitle Offset"));
+ wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
+ _subtitle_offset = new wxSpinCtrl (_subtitle_panel);
+ s->Add (_subtitle_offset);
- video_control (add_label_to_sizer (s, _subtitle_panel, _("pixels")));
++ add_label_to_sizer (s, _subtitle_panel, _("pixels"));
+ grid->Add (s);
+ }
{
- video_control (add_label_to_sizer (grid, _subtitle_panel, _("Subtitle Scale")));
+ add_label_to_sizer (grid, _subtitle_panel, _("Subtitle Scale"));
wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
_subtitle_scale = new wxSpinCtrl (_subtitle_panel);
- s->Add (video_control (_subtitle_scale));
- video_control (add_label_to_sizer (s, _subtitle_panel, _("%")));
+ s->Add (_subtitle_scale);
+ add_label_to_sizer (s, _subtitle_panel, _("%"));
grid->Add (s);
}
setup_subtitle_control_sensitivity ();
setup_streams ();
setup_show_audio_sensitivity ();
- setup_length ();
- setup_frame_rate_description ();
break;
- case Film::TRUST_CONTENT_HEADER:
- checked_set (_trust_content_header, _film->trust_content_header ());
- break;
- case Film::SUBTITLE_STREAMS:
- setup_subtitle_control_sensitivity ();
- setup_streams ();
- break;
- case Film::CONTENT_AUDIO_STREAMS:
- setup_streams ();
- setup_show_audio_sensitivity ();
- setup_frame_rate_description ();
+ case Film::TRUST_CONTENT_HEADERS:
+ checked_set (_trust_content_headers, _film->trust_content_headers ());
break;
case Film::FORMAT:
- {
- int n = 0;
- vector<Format const *>::iterator i = _formats.begin ();
- while (i != _formats.end() && *i != _film->format ()) {
- ++i;
- ++n;
- }
- if (i == _formats.end()) {
- checked_set (_format, -1);
- } else {
- checked_set (_format, n);
- }
- setup_dcp_name ();
- setup_scaling_description ();
+ setup_format ();
break;
- }
case Film::CROP:
checked_set (_left_crop, _film->crop().left);
checked_set (_right_crop, _film->crop().right);
}
}
- if (_film->source_frame_rate()) {
- _best_dcp_frame_rate->Enable (best_dcp_frame_rate (_film->source_frame_rate ()) != _film->dcp_frame_rate ());
+ if (_film->video_frame_rate()) {
- _frame_rate_description->SetLabel (std_to_wx (FrameRateConversion (_film->video_frame_rate(), _film->dcp_frame_rate()).description));
+ _best_dcp_frame_rate->Enable (best_dcp_frame_rate (_film->video_frame_rate ()) != _film->dcp_frame_rate ());
} else {
- _frame_rate_description->SetLabel (wxT (""));
_best_dcp_frame_rate->Disable ();
}
-
+ setup_frame_rate_description ();
+ break;
+ case Film::AUDIO_MAPPING:
+ _audio_mapping->set_mapping (_film->audio_mapping ());
+ break;
+ }
+}
+
+void
+FilmEditor::film_content_changed (weak_ptr<Content> content, int property)
+{
+ if (!_film) {
+ /* We call this method ourselves (as well as using it as a signal handler)
+ so _film can be 0.
+ */
+ return;
+ }
+
+ if (property == FFmpegContentProperty::SUBTITLE_STREAMS) {
+ setup_subtitle_control_sensitivity ();
+ setup_streams ();
+ } else if (property == FFmpegContentProperty::AUDIO_STREAMS) {
+ setup_streams ();
+ setup_show_audio_sensitivity ();
+ } else if (property == VideoContentProperty::VIDEO_LENGTH) {
+ setup_length ();
+ boost::shared_ptr<Content> c = content.lock ();
+ if (c && c == selected_content()) {
+ setup_content_information ();
+ }
+ } else if (property == FFmpegContentProperty::AUDIO_STREAM) {
+ if (_film->ffmpeg_audio_stream()) {
+ checked_set (_ffmpeg_audio_stream, boost::lexical_cast<string> (_film->ffmpeg_audio_stream()->id));
+ }
+ setup_dcp_name ();
+ setup_audio_details ();
+ setup_show_audio_sensitivity ();
+ } else if (property == FFmpegContentProperty::SUBTITLE_STREAM) {
+ if (_film->ffmpeg_subtitle_stream()) {
+ checked_set (_ffmpeg_subtitle_stream, boost::lexical_cast<string> (_film->ffmpeg_subtitle_stream()->id));
+ }
}
}
- setup_dcp_name ();
+void
+FilmEditor::setup_format ()
+{
+ int n = 0;
+ vector<Format const *>::iterator i = _formats.begin ();
+ while (i != _formats.end() && *i != _film->format ()) {
+ ++i;
+ ++n;
+ }
++
+ if (i == _formats.end()) {
+ checked_set (_format, -1);
+ } else {
+ checked_set (_format, n);
+ }
- if (_film->format ()) {
- _format_description->SetLabel (std_to_wx (_film->format()->description ()));
- } else {
- _format_description->SetLabel (wxT (""));
- }
+
- if (_film->source_frame_rate()) {
- d << std_to_wx (FrameRateConversion (_film->source_frame_rate(), _film->dcp_frame_rate()).description);
++ setup_dcp_name ();
++ setup_scaling_description ();
+}
+
+void
+FilmEditor::setup_length ()
+{
+ stringstream s;
+ if (_film->video_frame_rate() > 0 && _film->video_length()) {
+ s << _film->video_length() << " "
+ << wx_to_std (_("frames")) << "; " << seconds_to_hms (_film->video_length() / _film->video_frame_rate());
+ } else if (_film->video_length()) {
+ s << _film->video_length() << " "
+ << wx_to_std (_("frames"));
+ }
+ _length->SetLabel (std_to_wx (s.str ()));
+ if (_film->video_length()) {
+ _trim_start->SetRange (0, _film->video_length());
+ _trim_end->SetRange (0, _film->video_length());
+ }
+}
+
+ void
+ FilmEditor::setup_frame_rate_description ()
+ {
+ wxString d;
- if (_film->audio_stream() && _film->audio_stream()->sample_rate() != _film->target_audio_sample_rate ()) {
++ if (_film->video_frame_rate()) {
++ d << std_to_wx (FrameRateConversion (_film->video_frame_rate(), _film->dcp_frame_rate()).description);
+ #ifdef HAVE_SWRESAMPLE
- _film->audio_stream()->sample_rate(),
++ if (_film->audio_frame_rate() != _film->target_audio_sample_rate ()) {
+ d << wxString::Format (
+ _("Audio will be resampled from %dHz to %dHz\n"),
++ _film->audio_frame_rate(),
+ _film->target_audio_sample_rate()
+ );
+ } else {
+ d << "\n";
+ }
+ #else
+ d << "\n";
+ #endif
+ }
+
+ _frame_rate_description->SetLabel (d);
+ }
/** Called when the format widget has been changed */
void
void
FilmEditor::set_film (shared_ptr<Film> f)
{
- _film = f;
-
+ set_things_sensitive (_film != 0);
+
+ if (_film == f) {
+ return;
+ }
+
+ _film = f;
+
- set_things_sensitive (_film != 0);
-
if (_film) {
_film->Changed.connect (bind (&FilmEditor::film_changed, this, _1));
+ _film->ContentChanged.connect (bind (&FilmEditor::film_content_changed, this, _1, _2));
}
if (_film) {
_film->set_audio_delay (_audio_delay->GetValue ());
}
-wxControl *
-FilmEditor::video_control (wxControl* c)
-{
- _video_controls.push_back (c);
- return c;
-}
-
-wxControl *
-FilmEditor::still_control (wxControl* c)
-{
- _still_controls.push_back (c);
- return c;
-}
-
-void
-FilmEditor::setup_visibility ()
-{
- ContentType c = VIDEO;
-
- if (_film) {
- c = _film->content_type ();
- }
-
- for (list<wxControl*>::iterator i = _video_controls.begin(); i != _video_controls.end(); ++i) {
- (*i)->Show (c == VIDEO);
- }
-
- for (list<wxControl*>::iterator i = _still_controls.begin(); i != _still_controls.end(); ++i) {
- (*i)->Show (c == STILL);
- }
-
- setup_notebook_size ();
-}
-
+ void
+ FilmEditor::setup_notebook_size ()
+ {
+ _notebook->InvalidateBestSize ();
+
+ _film_sizer->Layout ();
+ _film_sizer->SetSizeHints (_film_panel);
+ _video_sizer->Layout ();
+ _video_sizer->SetSizeHints (_video_panel);
+ _audio_sizer->Layout ();
+ _audio_sizer->SetSizeHints (_audio_panel);
+ _subtitle_sizer->Layout ();
+ _subtitle_sizer->SetSizeHints (_subtitle_panel);
+
+ _notebook->Fit ();
+ Fit ();
+ }
+
-void
-FilmEditor::still_duration_changed (wxCommandEvent &)
-{
- if (!_film) {
- return;
- }
-
- _film->set_still_duration (_still_duration->GetValue ());
-}
-
void
FilmEditor::trim_start_changed (wxCommandEvent &)
{
void
FilmEditor::setup_audio_details ()
{
- if (!_film->content_audio_stream()) {
+ if (!_film->ffmpeg_audio_stream()) {
_audio->SetLabel (wxT (""));
} else {
- stringstream s;
+ wxString s;
- if (_film->audio_stream()->channels() == 1) {
+ if (_film->audio_channels() == 1) {
- s << wx_to_std (_("1 channel"));
+ s << _("1 channel");
} else {
- s << _film->audio_channels() << " " << wx_to_std (_("channels"));
- s << _film->audio_stream()->channels () << " " << _("channels");
++ s << _film->audio_channels() << " " << _("channels");
}
- s << ", " << _film->audio_frame_rate() << wx_to_std (_("Hz"));
- _audio->SetLabel (std_to_wx (s.str ()));
- s << ", " << _film->audio_stream()->sample_rate() << _("Hz");
++ s << ", " << _film->audio_frame_rate() << _("Hz");
+ _audio->SetLabel (s);
}
+
+ setup_notebook_size ();
}
void
_show_audio->Enable (_film && _film->has_audio ());
}
- _film->size().width, _film->size().height,
- float (_film->size().width) / _film->size().height
+void
+FilmEditor::setup_content ()
+{
+ string selected_summary;
+ int const s = _content->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+ if (s != -1) {
+ selected_summary = wx_to_std (_content->GetItemText (s));
+ }
+
+ _content->DeleteAllItems ();
+
+ ContentList content = _film->content ();
+ for (ContentList::iterator i = content.begin(); i != content.end(); ++i) {
+ int const t = _content->GetItemCount ();
+ _content->InsertItem (t, std_to_wx ((*i)->summary ()));
+ if ((*i)->summary() == selected_summary) {
+ _content->SetItemState (t, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
+ }
+ }
+
+ if (selected_summary.empty () && !content.empty ()) {
+ /* Select the first item of content if non was selected before */
+ _content->SetItemState (0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
+ }
+}
+
+void
+FilmEditor::content_add_clicked (wxCommandEvent &)
+{
+ wxFileDialog* d = new wxFileDialog (this);
+ int const r = d->ShowModal ();
+ d->Destroy ();
+
+ if (r != wxID_OK) {
+ return;
+ }
+
+ boost::filesystem::path p (wx_to_std (d->GetPath()));
+
+ if (ImageMagickContent::valid_file (p)) {
+ _film->add_content (shared_ptr<ImageMagickContent> (new ImageMagickContent (p)));
+ } else if (SndfileContent::valid_file (p)) {
+ _film->add_content (shared_ptr<SndfileContent> (new SndfileContent (p)));
+ } else {
+ _film->add_content (shared_ptr<FFmpegContent> (new FFmpegContent (p)));
+ }
+
+}
+
+void
+FilmEditor::content_remove_clicked (wxCommandEvent &)
+{
+ shared_ptr<Content> c = selected_content ();
+ if (c) {
+ _film->remove_content (c);
+ }
+}
+
+void
+FilmEditor::content_activated (wxListEvent& ev)
+{
+ ContentList c = _film->content ();
+ assert (ev.GetIndex() >= 0 && size_t (ev.GetIndex()) < c.size ());
+
+ edit_content (c[ev.GetIndex()]);
+}
+
+void
+FilmEditor::content_edit_clicked (wxCommandEvent &)
+{
+ shared_ptr<Content> c = selected_content ();
+ if (!c) {
+ return;
+ }
+
+ edit_content (c);
+}
+
+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"),
- libdcp::Size const cropped = _film->cropped_size (_film->size ());
++ _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 << " \n";
+ }
+
+ _scaling_description->SetLabel (d);
+ }