From: Carl Hetherington Date: Tue, 3 Jan 2023 20:17:36 +0000 (+0100) Subject: Allow drag-and-drop of DKDMs onto the list in the KDM creator. X-Git-Tag: v2.16.39~1 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=271e642f03145fe1d98b1fde128d42ea3a3418c6 Allow drag-and-drop of DKDMs onto the list in the KDM creator. --- diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc index 90e315aab..04b37b2c6 100644 --- a/src/tools/dcpomatic_kdm.cc +++ b/src/tools/dcpomatic_kdm.cc @@ -55,6 +55,7 @@ #include #include LIBDCP_DISABLE_WARNINGS +#include #include #include #include @@ -175,10 +176,31 @@ public: right->Add(_dkdm_search, 0, wxTOP | wxBOTTOM, DCPOMATIC_SIZER_Y_GAP); + class DKDMDropTarget : public wxFileDropTarget + { + public: + DKDMDropTarget(DOMFrame* frame) + : _frame(frame) + {} + + bool OnDropFiles(wxCoord, wxCoord, wxArrayString const& filenames) override + { + for (size_t i = 0; i < filenames.GetCount(); ++i) { + _frame->add_dkdm(boost::filesystem::path(wx_to_std(filenames[0]))); + } + + return true; + } + + private: + DOMFrame* _frame; + }; + auto dkdm_sizer = new wxBoxSizer (wxHORIZONTAL); _dkdm = new wxTreeCtrl ( overall_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTR_HIDE_ROOT | wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT ); + _dkdm->SetDropTarget(new DKDMDropTarget(this)); dkdm_sizer->Add(_dkdm, 1, wxEXPAND | wxBOTTOM, DCPOMATIC_SIZER_Y_GAP); auto dkdm_buttons = new wxBoxSizer(wxVERTICAL); _add_dkdm = new Button (overall_panel, _("Add..."));