Allow multiple selection of content files, and improve behaviour on examining still...
[dcpomatic.git] / src / wx / film_editor.cc
index f9ca8609b4298fee872d28c73adba9bede6ea537..b6be39e9b5d90e3a8bf6afd8007422e6c49c95b5 100644 (file)
@@ -60,6 +60,7 @@ using std::fixed;
 using std::setprecision;
 using std::list;
 using std::vector;
+using std::max;
 using boost::shared_ptr;
 using boost::weak_ptr;
 using boost::dynamic_pointer_cast;
@@ -742,7 +743,7 @@ FilmEditor::film_content_changed (weak_ptr<Content> content, int property)
        } else if (property == FFmpegContentProperty::AUDIO_STREAMS) {
                setup_streams ();
                setup_show_audio_sensitivity ();
-       } else if (property == VideoContentProperty::VIDEO_LENGTH) {
+       } else if (property == VideoContentProperty::VIDEO_LENGTH || property == AudioContentProperty::AUDIO_LENGTH) {
                setup_length ();
                boost::shared_ptr<Content> c = content.lock ();
                if (c && c == selected_content()) {
@@ -786,17 +787,19 @@ 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"));
-       } 
+       ContentVideoFrame const frames = _film->content_length ();
+       
+       if (frames && _film->video_frame_rate()) {
+               s << frames << " " << wx_to_std (_("frames")) << "; " << seconds_to_hms (frames / _film->video_frame_rate());
+       } else if (frames) {
+               s << frames << " " << 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());
+       
+       if (frames) {
+               _trim_start->SetRange (0, frames);
+               _trim_end->SetRange (0, frames);
        }
 }      
 
@@ -1295,7 +1298,7 @@ FilmEditor::setup_content ()
 void
 FilmEditor::content_add_clicked (wxCommandEvent &)
 {
-       wxFileDialog* d = new wxFileDialog (this);
+       wxFileDialog* d = new wxFileDialog (this, _("Choose a file or files"), wxT (""), wxT (""), wxT ("*.*"), wxFD_MULTIPLE);
        int const r = d->ShowModal ();
        d->Destroy ();
 
@@ -1303,16 +1306,20 @@ FilmEditor::content_add_clicked (wxCommandEvent &)
                return;
        }
 
-       boost::filesystem::path p (wx_to_std (d->GetPath()));
+       wxArrayString paths;
+       d->GetPaths (paths);
 
-       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)));
+       for (unsigned int i = 0; i < paths.GetCount(); ++i) {
+               boost::filesystem::path p (wx_to_std (paths[i]));
+
+               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