Hand-apply 0ca0ab9f23ac0238643a6d148148385388f71c00 from master;
[dcpomatic.git] / src / wx / content_panel.cc
index 40ffb9b2e98fc734c239a280cdbeb16f5a19d715..2932ee7c58bca7cd6da585f47b7fb5bb435f6a63 100644 (file)
@@ -38,6 +38,7 @@
 
 using std::list;
 using std::string;
+using std::cout;
 using boost::shared_ptr;
 using boost::weak_ptr;
 using boost::dynamic_pointer_cast;
@@ -63,27 +64,36 @@ ContentPanel::ContentPanel (wxNotebook* n, boost::shared_ptr<Film> f)
                _content->SetColumnWidth (0, 512);
 
                wxBoxSizer* b = new wxBoxSizer (wxVERTICAL);
+               
                _add_file = new wxButton (_panel, wxID_ANY, _("Add file(s)..."));
-               b->Add (_add_file, 1, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
+               _add_file->SetToolTip (_("Add video, image or sound files to the film."));
+               b->Add (_add_file, 0, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
+               
                _add_folder = new wxButton (_panel, wxID_ANY, _("Add folder..."));
+               _add_folder->SetToolTip (_("Add a folder of image files (which will be used as a moving image sequence) or a DCP."));
                b->Add (_add_folder, 1, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
+               
                _remove = new wxButton (_panel, wxID_ANY, _("Remove"));
-               b->Add (_remove, 1, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
+               _remove->SetToolTip (_("Remove the selected piece of content from the film."));
+               b->Add (_remove, 0, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
+               
                _earlier = new wxButton (_panel, wxID_ANY, _("Up"));
-               b->Add (_earlier, 1, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
+               _earlier->SetToolTip (_("Move the selected piece of content earlier in the film."));
+               b->Add (_earlier, 0, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
+               
                _later = new wxButton (_panel, wxID_ANY, _("Down"));
-               b->Add (_later, 1, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
+               _later->SetToolTip (_("Move the selected piece of content later in the film."));
+               b->Add (_later, 0, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
+               
                _timeline = new wxButton (_panel, wxID_ANY, _("Timeline..."));
-               b->Add (_timeline, 1, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
+               _timeline->SetToolTip (_("Open the timeline for the film."));
+               b->Add (_timeline, 0, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
 
                s->Add (b, 0, wxALL, 4);
 
                _sizer->Add (s, 0, wxEXPAND | wxALL, 6);
        }
 
-       _sequence_video = new wxCheckBox (_panel, wxID_ANY, _("Keep video in sequence"));
-       _sizer->Add (_sequence_video);
-
        _notebook = new wxNotebook (_panel, wxID_ANY);
        _sizer->Add (_notebook, 1, wxEXPAND | wxTOP, 6);
 
@@ -99,13 +109,13 @@ ContentPanel::ContentPanel (wxNotebook* n, boost::shared_ptr<Film> f)
        _content->Bind (wxEVT_COMMAND_LIST_ITEM_SELECTED, boost::bind (&ContentPanel::selection_changed, this));
        _content->Bind (wxEVT_COMMAND_LIST_ITEM_DESELECTED, boost::bind (&ContentPanel::selection_changed, this));
        _content->Bind (wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, boost::bind (&ContentPanel::right_click, this, _1));
+       _content->Bind (wxEVT_DROP_FILES, boost::bind (&ContentPanel::files_dropped, this, _1));
        _add_file->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ContentPanel::add_file_clicked, this));
        _add_folder->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ContentPanel::add_folder_clicked, this));
        _remove->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ContentPanel::remove_clicked, this));
        _earlier->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ContentPanel::earlier_clicked, this));
        _later->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ContentPanel::later_clicked, this));
        _timeline->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ContentPanel::timeline_clicked, this));
-       _sequence_video->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&ContentPanel::sequence_video_changed, this));
 }
 
 ContentList
@@ -191,16 +201,6 @@ ContentPanel::selected_ffmpeg ()
        return sc;
 }
 
-void
-ContentPanel::sequence_video_changed ()
-{
-       if (!_film) {
-               return;
-       }
-       
-       _film->set_sequence_video (_sequence_video->GetValue ());
-}
-
 void
 ContentPanel::film_changed (Film::Property p)
 {
@@ -208,9 +208,6 @@ ContentPanel::film_changed (Film::Property p)
        case Film::CONTENT:
                setup ();
                break;
-       case Film::SEQUENCE_VIDEO:
-               checked_set (_sequence_video, _film->sequence_video ());
-               break;
        default:
                break;
        }
@@ -261,6 +258,7 @@ ContentPanel::add_folder_clicked ()
 {
        wxDirDialog* d = new wxDirDialog (_panel, _("Choose a folder"), wxT (""), wxDD_DIR_MUST_EXIST);
        int const r = d->ShowModal ();
+       boost::filesystem::path const path (wx_to_std (d->GetPath ()));
        d->Destroy ();
        
        if (r != wxID_OK) {
@@ -270,10 +268,10 @@ ContentPanel::add_folder_clicked ()
        shared_ptr<Content> content;
        
        try {
-               content.reset (new ImageContent (_film, boost::filesystem::path (wx_to_std (d->GetPath ()))));
+               content.reset (new ImageContent (_film, path));
        } catch (...) {
                try {
-                       content.reset (new DCPContent (_film, boost::filesystem::path (wx_to_std (d->GetPath ()))));
+                       content.reset (new DCPContent (_film, path));
                } catch (...) {
                        error_dialog (_panel, _("Could not find any images nor a DCP in that folder"));
                        return;
@@ -340,6 +338,9 @@ void
 ContentPanel::set_film (shared_ptr<Film> f)
 {
        _film = f;
+
+       film_changed (Film::CONTENT);
+       film_changed (Film::AUDIO_CHANNELS);
        selection_changed ();
 }
 
@@ -355,7 +356,6 @@ ContentPanel::set_general_sensitivity (bool s)
        _earlier->Enable (s);
        _later->Enable (s);
        _timeline->Enable (s);
-       _sequence_video->Enable (s);
 
        /* Set the panels in the content notebook */
        for (list<ContentSubPanel*>::iterator i = _panels.begin(); i != _panels.end(); ++i) {
@@ -421,7 +421,7 @@ ContentPanel::setup ()
 
        ContentList content = _film->content ();
        sort (content.begin(), content.end(), ContentSorter ());
-       
+
        for (ContentList::iterator i = content.begin(); i != content.end(); ++i) {
                int const t = _content->GetItemCount ();
                bool const valid = (*i)->paths_valid ();
@@ -455,3 +455,15 @@ ContentPanel::setup ()
        }
 }
 
+void
+ContentPanel::files_dropped (wxDropFilesEvent& event)
+{
+       if (!_film) {
+               return;
+       }
+       
+       wxString* paths = event.GetFiles ();
+       for (int i = 0; i < event.GetNumberOfFiles(); i++) {
+               _film->examine_and_add_content (content_factory (_film, wx_to_std (paths[i])));
+       }
+}