#include <dcp/warnings.h>
LIBDCP_DISABLE_WARNINGS
#include <wx/display.h>
+#include <wx/dnd.h>
#include <wx/listctrl.h>
#include <wx/notebook.h>
#include <wx/wx.h>
#endif
+class ContentDropTarget : public wxFileDropTarget
+{
+public:
+ ContentDropTarget(ContentPanel* owner)
+ : _panel(owner)
+ {}
+
+ bool OnDropFiles(wxCoord, wxCoord, wxArrayString const& filenames) override
+ {
+ vector<boost::filesystem::path> files;
+ vector<boost::filesystem::path> dcps;
+ vector<boost::filesystem::path> folders;
+ for (size_t i = 0; i < filenames.GetCount(); ++i) {
+ auto path = boost::filesystem::path(wx_to_std(filenames[i]));
+ if (boost::filesystem::is_regular_file(path)) {
+ files.push_back(path);
+ } else if (boost::filesystem::is_directory(path)) {
+ if (contains_assetmap(path)) {
+ dcps.push_back(path);
+ } else {
+ folders.push_back(path);
+ }
+ }
+ }
+
+ if (!filenames.empty()) {
+ _panel->add_files(files);
+ }
+
+ for (auto dcp: dcps) {
+ _panel->add_dcp(dcp);
+ }
+
+ for (auto dir: folders) {
+ _panel->add_folder(dir);
+ }
+
+ return true;
+ };
+
+private:
+ ContentPanel* _panel;
+};
+
+
ContentPanel::ContentPanel (wxNotebook* n, shared_ptr<Film> film, weak_ptr<FilmViewer> viewer)
: _parent (n)
, _film (film)
_earlier->Bind (wxEVT_BUTTON, boost::bind (&ContentPanel::earlier_clicked, this));
_later->Bind (wxEVT_BUTTON, boost::bind (&ContentPanel::later_clicked, this));
_timeline->Bind (wxEVT_BUTTON, boost::bind (&ContentPanel::timeline_clicked, this));
+
+ _content->SetDropTarget(new ContentDropTarget(this));
}
return;
}
+ add_folder(path);
+}
+
+
+void
+ContentPanel::add_folder(boost::filesystem::path folder)
+{
vector<shared_ptr<Content>> content;
try {
- content = content_factory (path);
+ content = content_factory(folder);
} catch (exception& e) {
error_dialog (_parent, e.what());
return;
auto ic = dynamic_pointer_cast<ImageContent> (i);
if (ic) {
auto e = new ImageSequenceDialog (_splitter);
- r = e->ShowModal ();
+ int const r = e->ShowModal();
auto const frame_rate = e->frame_rate ();
e->Destroy ();
return;
}
+ add_dcp(path);
+}
+
+
+void
+ContentPanel::add_dcp(boost::filesystem::path dcp)
+{
try {
- _film->examine_and_add_content (make_shared<DCPContent>(path));
+ _film->examine_and_add_content(make_shared<DCPContent>(dcp));
} catch (ProjectFolderError &) {
error_dialog (
_parent,
)
);
} catch (exception& e) {
- error_dialog (_parent, e.what());
+ error_dialog(_parent, e.what());
}
}
void
ContentPanel::add_files (vector<boost::filesystem::path> paths)
{
+ if (!_film) {
+ return;
+ }
+
/* It has been reported that the paths returned from e.g. wxFileDialog are not always sorted;
I can't reproduce that, but sort them anyway. Don't use ImageFilenameSorter as a normal
alphabetical sort is expected here.
return _film_viewer;
}
+ void add_files(std::vector<boost::filesystem::path> files);
+ void add_dcp(boost::filesystem::path dcp);
+ void add_folder(boost::filesystem::path folder);
+
boost::signals2::signal<void (void)> SelectionChanged;
private:
void setup_sensitivity ();
void set_selected_state(int item, bool state);
- void add_files (std::vector<boost::filesystem::path>);
std::list<ContentSubPanel *> panels () const;
LimitedSplitter* _splitter;