Allow multiple selection; return multiple selection from FilmEditor methods.
authorCarl Hetherington <cth@carlh.net>
Sun, 10 Nov 2013 23:31:28 +0000 (23:31 +0000)
committerCarl Hetherington <cth@carlh.net>
Sun, 10 Nov 2013 23:31:28 +0000 (23:31 +0000)
src/lib/types.h
src/wx/film_editor.cc
src/wx/film_editor.h

index d4d66387d0c5c17c08183b1f04aecfe6ce2cebff..ad706270e66a79d2ace667d79604f35bc9c69de4 100644 (file)
@@ -26,6 +26,9 @@
 #include <libdcp/util.h>
 
 class Content;
+class VideoContent;
+class AudioContent;
+class SubtitleContent;
 class AudioBuffers;
 
 /** The version number of the protocol used to communicate
@@ -40,6 +43,9 @@ typedef int64_t Time;
 typedef int64_t OutputAudioFrame;
 typedef int    OutputVideoFrame;
 typedef std::vector<boost::shared_ptr<Content> > ContentList;
+typedef std::vector<boost::shared_ptr<VideoContent> > VideoContentList;
+typedef std::vector<boost::shared_ptr<AudioContent> > AudioContentList;
+typedef std::vector<boost::shared_ptr<SubtitleContent> > SubtitleContentList;
 
 template<class T>
 struct TimedAudioBuffers
index b789a826695dbceac24f8df65220be4a0cacc1aa..99b3c59a5e6450f1848b2c2e56ffc8eb64521953 100644 (file)
@@ -258,7 +258,7 @@ FilmEditor::make_content_panel ()
        {
                wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
                
-               _content = new wxListCtrl (_content_panel, wxID_ANY, wxDefaultPosition, wxSize (320, 160), wxLC_REPORT | wxLC_NO_HEADER | wxLC_SINGLE_SEL);
+               _content = new wxListCtrl (_content_panel, wxID_ANY, wxDefaultPosition, wxSize (320, 160), wxLC_REPORT | wxLC_NO_HEADER);
                s->Add (_content, 1, wxEXPAND | wxTOP | wxBOTTOM, 6);
 
                _content->InsertColumn (0, wxT(""));
@@ -832,53 +832,69 @@ FilmEditor::setup_content_sensitivity ()
        _timing_panel->Enable   (selection && _generally_sensitive);
 }
 
-shared_ptr<Content>
+ContentList
 FilmEditor::selected_content ()
 {
-       int const s = _content->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
-       if (s == -1) {
-               return shared_ptr<Content> ();
-       }
+       ContentList sel;
+       long int s = -1;
+       while (1) {
+               s = _content->GetNextItem (s, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+               if (s == -1) {
+                       break;
+               }
 
-       ContentList c = _film->content ();
-       if (s < 0 || size_t (s) >= c.size ()) {
-               return shared_ptr<Content> ();
+               sel.push_back (_film->content[s]);
        }
-       
-       return c[s];
+
+       return sel;
 }
 
-shared_ptr<VideoContent>
+VideoContentList
 FilmEditor::selected_video_content ()
 {
-       shared_ptr<Content> c = selected_content ();
-       if (!c) {
-               return shared_ptr<VideoContent> ();
+       ContentList c = selected_content ();
+       VideoContentList vc;
+       
+       for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
+               shared_ptr<VideoContent> t = dynamic_pointer_cast<VideoContent> (*i);
+               if (t) {
+                       vc.push_back (t);
+               }
        }
 
-       return dynamic_pointer_cast<VideoContent> (c);
+       return vc;
 }
 
-shared_ptr<AudioContent>
+AudioContentList
 FilmEditor::selected_audio_content ()
 {
-       shared_ptr<Content> c = selected_content ();
-       if (!c) {
-               return shared_ptr<AudioContent> ();
+       ContentList c = selected_content ();
+       AudioContentList ac;
+       
+       for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
+               shared_ptr<AudioContent> t = dynamic_pointer_cast<AudioContent> (*i);
+               if (t) {
+                       ac.push_back (t);
+               }
        }
 
-       return dynamic_pointer_cast<AudioContent> (c);
+       return ac;
 }
 
-shared_ptr<SubtitleContent>
+SubtitleContentList
 FilmEditor::selected_subtitle_content ()
 {
-       shared_ptr<Content> c = selected_content ();
-       if (!c) {
-               return shared_ptr<SubtitleContent> ();
+       ContentList c = selected_content ();
+       SubtitleContentList sc;
+       
+       for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
+               shared_ptr<SubtitleContent> t = dynamic_pointer_cast<SubtitleContent> (*i);
+               if (t) {
+                       sc.push_back (t);
+               }
        }
 
-       return dynamic_pointer_cast<SubtitleContent> (c);
+       return sc;
 }
 
 void
index 80c35d3d86cb8c9bfdac7e07a3206288f409d7f2..9808e0d2f8f76aaa7f2729d53bfb27135d5833c7 100644 (file)
@@ -62,10 +62,10 @@ public:
                return _film;
        }
 
-       boost::shared_ptr<Content> selected_content ();
-       boost::shared_ptr<VideoContent> selected_video_content ();
-       boost::shared_ptr<AudioContent> selected_audio_content ();
-       boost::shared_ptr<SubtitleContent> selected_subtitle_content ();
+       ContentList selected_content ();
+       VideoContentList selected_video_content ();
+       AudioContentList selected_audio_content ();
+       SubtitleContentList selected_subtitle_content ();
        
 private:
        void make_dcp_panel ();