From: Carl Hetherington Date: Sun, 10 Nov 2013 23:31:28 +0000 (+0000) Subject: Allow multiple selection; return multiple selection from FilmEditor methods. X-Git-Tag: v2.0.48~1166 X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;h=d1db495ddf466c47f635ac78eec9229ecfa24722;p=dcpomatic.git Allow multiple selection; return multiple selection from FilmEditor methods. --- diff --git a/src/lib/types.h b/src/lib/types.h index d4d66387d..ad706270e 100644 --- a/src/lib/types.h +++ b/src/lib/types.h @@ -26,6 +26,9 @@ #include 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 > ContentList; +typedef std::vector > VideoContentList; +typedef std::vector > AudioContentList; +typedef std::vector > SubtitleContentList; template struct TimedAudioBuffers diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index b789a8266..99b3c59a5 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -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 +ContentList FilmEditor::selected_content () { - int const s = _content->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); - if (s == -1) { - return shared_ptr (); - } + 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 (); + sel.push_back (_film->content[s]); } - - return c[s]; + + return sel; } -shared_ptr +VideoContentList FilmEditor::selected_video_content () { - shared_ptr c = selected_content (); - if (!c) { - return shared_ptr (); + ContentList c = selected_content (); + VideoContentList vc; + + for (ContentList::iterator i = c.begin(); i != c.end(); ++i) { + shared_ptr t = dynamic_pointer_cast (*i); + if (t) { + vc.push_back (t); + } } - return dynamic_pointer_cast (c); + return vc; } -shared_ptr +AudioContentList FilmEditor::selected_audio_content () { - shared_ptr c = selected_content (); - if (!c) { - return shared_ptr (); + ContentList c = selected_content (); + AudioContentList ac; + + for (ContentList::iterator i = c.begin(); i != c.end(); ++i) { + shared_ptr t = dynamic_pointer_cast (*i); + if (t) { + ac.push_back (t); + } } - return dynamic_pointer_cast (c); + return ac; } -shared_ptr +SubtitleContentList FilmEditor::selected_subtitle_content () { - shared_ptr c = selected_content (); - if (!c) { - return shared_ptr (); + ContentList c = selected_content (); + SubtitleContentList sc; + + for (ContentList::iterator i = c.begin(); i != c.end(); ++i) { + shared_ptr t = dynamic_pointer_cast (*i); + if (t) { + sc.push_back (t); + } } - return dynamic_pointer_cast (c); + return sc; } void diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h index 80c35d3d8..9808e0d2f 100644 --- a/src/wx/film_editor.h +++ b/src/wx/film_editor.h @@ -62,10 +62,10 @@ public: return _film; } - boost::shared_ptr selected_content (); - boost::shared_ptr selected_video_content (); - boost::shared_ptr selected_audio_content (); - boost::shared_ptr selected_subtitle_content (); + ContentList selected_content (); + VideoContentList selected_video_content (); + AudioContentList selected_audio_content (); + SubtitleContentList selected_subtitle_content (); private: void make_dcp_panel ();