Bump libcxml version requirement in wscript.
[dcpomatic.git] / src / wx / film_editor.cc
index d0534f9c06f873accb754622412840d6149c035a..f569e0422a14a0dbcc134cc69bac3bdf9643181f 100644 (file)
@@ -45,6 +45,7 @@
 #include "lib/playlist.h"
 #include "lib/content.h"
 #include "lib/content_factory.h"
+#include "lib/safe_stringstream.h"
 #include "timecode.h"
 #include "wx_util.h"
 #include "film_editor.h"
@@ -57,7 +58,6 @@
 
 using std::string;
 using std::cout;
-using std::stringstream;
 using std::pair;
 using std::fixed;
 using std::setprecision;
@@ -70,7 +70,7 @@ using boost::dynamic_pointer_cast;
 using boost::lexical_cast;
 
 /** @param f Film to edit */
-FilmEditor::FilmEditor (shared_ptr<Film> f, wxWindow* parent)
+FilmEditor::FilmEditor (wxWindow* parent)
        : wxPanel (parent)
        , _menu (this)
        , _generally_sensitive (true)
@@ -86,7 +86,6 @@ FilmEditor::FilmEditor (shared_ptr<Film> f, wxWindow* parent)
        make_dcp_panel ();
        _main_notebook->AddPage (_dcp_panel, _("DCP"), false);
        
-       set_film (f);
        connect_to_widgets ();
 
        JobManager::instance()->ActiveJobsChanged.connect (
@@ -94,7 +93,8 @@ FilmEditor::FilmEditor (shared_ptr<Film> f, wxWindow* parent)
                );
 
        Config::instance()->Changed.connect (boost::bind (&FilmEditor::config_changed, this));
-       
+
+       set_film (shared_ptr<Film> ());
        SetSizerAndFit (s);
 }
 
@@ -238,6 +238,7 @@ FilmEditor::connect_to_widgets ()
        _content->Bind          (wxEVT_COMMAND_LIST_ITEM_SELECTED,    boost::bind (&FilmEditor::content_selection_changed, this));
        _content->Bind          (wxEVT_COMMAND_LIST_ITEM_DESELECTED,  boost::bind (&FilmEditor::content_selection_changed, this));
        _content->Bind          (wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, boost::bind (&FilmEditor::content_right_click, this, _1));
+       _content->Bind          (wxEVT_DROP_FILES,                    boost::bind (&FilmEditor::content_files_dropped, this, _1));
        _content_add_file->Bind (wxEVT_COMMAND_BUTTON_CLICKED,        boost::bind (&FilmEditor::content_add_file_clicked, this));
        _content_add_folder->Bind (wxEVT_COMMAND_BUTTON_CLICKED,      boost::bind (&FilmEditor::content_add_folder_clicked, this));
        _content_remove->Bind   (wxEVT_COMMAND_BUTTON_CLICKED,        boost::bind (&FilmEditor::content_remove_clicked, this));
@@ -308,6 +309,8 @@ FilmEditor::make_content_panel ()
        _panels.push_back (_subtitle_panel);
        _timing_panel = new TimingPanel (this);
        _panels.push_back (_timing_panel);
+
+       _content->DragAcceptFiles (true);
 }
 
 /** Called when the name widget has been changed */
@@ -420,7 +423,7 @@ FilmEditor::film_changed (Film::Property p)
                return;
        }
 
-       stringstream s;
+       SafeStringStream s;
 
        for (list<FilmEditorPanel*>::iterator i = _panels.begin(); i != _panels.end(); ++i) {
                (*i)->film_changed (p);
@@ -534,6 +537,8 @@ FilmEditor::film_content_changed (int property)
                setup_content ();
        } else if (property == ContentProperty::POSITION) {
                setup_content ();
+       } else if (property == VideoContentProperty::VIDEO_SCALE) {
+               setup_dcp_name ();
        }
 }
 
@@ -989,7 +994,7 @@ FilmEditor::set_selection (weak_ptr<Content> wc)
                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);
+                       _content->SetItemState (i, 0, wxLIST_STATE_SELECTED);
                }
        }
 }
@@ -1060,3 +1065,16 @@ FilmEditor::setup_frame_rate_widget ()
 
        _frame_rate_sizer->Layout ();
 }
+
+void
+FilmEditor::content_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])));
+       }
+}