- _generally_sensitive = s;
-
- /* Stuff in the Content / DCP tabs */
- _name->Enable (s);
- _use_dci_name->Enable (s);
- _edit_dci_button->Enable (s);
- _content->Enable (s);
- _content_add->Enable (s);
- _content_remove->Enable (s);
- _content_timeline->Enable (s);
- _dcp_content_type->Enable (s);
- _dcp_frame_rate->Enable (s);
- _dcp_audio_channels->Enable (s);
- _j2k_bandwidth->Enable (s);
- _container->Enable (s);
- _best_dcp_frame_rate->Enable (s && _film && _film->best_dcp_video_frame_rate () != _film->dcp_video_frame_rate ());
- _sequence_video->Enable (s);
- _dcp_resolution->Enable (s);
- _scaler->Enable (s);
-
- /* Set the panels in the content notebook */
- for (list<FilmEditorPanel*>::iterator i = _panels.begin(); i != _panels.end(); ++i) {
- (*i)->Enable (s);
- }
-}
-
-/** Called when the scaler widget has been changed */
-void
-FilmEditor::scaler_changed (wxCommandEvent &)
-{
- if (!_film) {
- return;
- }
-
- int const n = _scaler->GetSelection ();
- if (n >= 0) {
- _film->set_scaler (Scaler::from_index (n));
- }
-}
-
-void
-FilmEditor::use_dci_name_toggled (wxCommandEvent &)
-{
- if (!_film) {
- return;
- }
-
- _film->set_use_dci_name (_use_dci_name->GetValue ());
-}
-
-void
-FilmEditor::edit_dci_button_clicked (wxCommandEvent &)
-{
- if (!_film) {
- return;
- }
-
- DCIMetadataDialog* d = new DCIMetadataDialog (this, _film->dci_metadata ());
- d->ShowModal ();
- _film->set_dci_metadata (d->dci_metadata ());
- d->Destroy ();
-}
-
-void
-FilmEditor::active_jobs_changed (bool a)
-{
- set_general_sensitivity (!a);
-}
-
-void
-FilmEditor::setup_dcp_name ()
-{
- string s = _film->dcp_name (true);
- if (s.length() > 28) {
- _dcp_name->SetLabel (std_to_wx (s.substr (0, 28)) + N_("..."));
- _dcp_name->SetToolTip (std_to_wx (s));
- } else {
- _dcp_name->SetLabel (std_to_wx (s));
- }
-}
-
-void
-FilmEditor::best_dcp_frame_rate_clicked (wxCommandEvent &)
-{
- if (!_film) {
- return;
- }
-
- _film->set_dcp_video_frame_rate (_film->best_dcp_video_frame_rate ());
-}
-
-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 item of content if none was selected before */
- _content->SetItemState (0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
- }
-}
-
-void
-FilmEditor::content_add_clicked (wxCommandEvent &)
-{
- wxFileDialog* d = new wxFileDialog (this, _("Choose a file or files"), wxT (""), wxT (""), wxT ("*.*"), wxFD_MULTIPLE);
- int const r = d->ShowModal ();
- d->Destroy ();
-
- if (r != wxID_OK) {
- return;
- }
-
- wxArrayString paths;
- d->GetPaths (paths);
-
- 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)) {
- c.reset (new StillImageContent (_film, p));
- } else if (SndfileContent::valid_file (p)) {
- c.reset (new SndfileContent (_film, p));
- } else {
- c.reset (new FFmpegContent (_film, p));
- }
-
- _film->examine_and_add_content (c);
- }
-}
-
-void
-FilmEditor::content_remove_clicked (wxCommandEvent &)
-{
- 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 ();
-
- /* All other sensitivity in content panels should be triggered by
- one of these.
- */
- 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);
-}
-
-/** Set up broad sensitivity based on the type of content that is selected */
-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> ();
- }
-
- 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::content_timeline_clicked (wxCommandEvent &)
-{
- if (_timeline_dialog) {
- _timeline_dialog->Destroy ();
- _timeline_dialog = 0;
- }
-
- _timeline_dialog = new TimelineDialog (this, _film);
- _timeline_dialog->Show ();
-}
-
-void
-FilmEditor::set_selection (weak_ptr<Content> wc)
-{
- ContentList content = _film->content ();
- for (size_t i = 0; i < content.size(); ++i) {
- if (content[i] == wc.lock ()) {
- _content->SetItemState (i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
- } else {
- _content->SetItemState (i, 0, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
- }
- }
-}
-
-void
-FilmEditor::sequence_video_changed (wxCommandEvent &)
-{
- if (!_film) {
- return;
- }
-
- _film->set_sequence_video (_sequence_video->GetValue ());