From b9fd18b56b30e658ac4fbb852c46bae71afa35ad Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 31 Aug 2014 14:54:41 +0100 Subject: [PATCH] Allow drag-and-drop of files onto the content panel (#395). --- ChangeLog | 4 ++++ src/wx/film_editor.cc | 16 ++++++++++++++++ src/wx/film_editor.h | 1 + 3 files changed, 21 insertions(+) diff --git a/ChangeLog b/ChangeLog index a966e7532..d2938bda9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-08-31 Carl Hetherington + + * Allow drag-and-drop of files onto the content list (#395). + 2014-08-29 Carl Hetherington * Some improvements to the manual. diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index e2886b5f5..017a9d7c9 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -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 */ @@ -1060,3 +1063,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]))); + } +} diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h index 6f39f2d68..1854df05e 100644 --- a/src/wx/film_editor.h +++ b/src/wx/film_editor.h @@ -83,6 +83,7 @@ private: void content_remove_clicked (); void content_earlier_clicked (); void content_later_clicked (); + void content_files_dropped (wxDropFilesEvent& event); void container_changed (); void dcp_content_type_changed (); void scaler_changed (); -- 2.30.2