From db31995310c1743faa0c1ce9d3135af6cb7e2c71 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Thu, 16 Jun 2022 11:12:32 +0200 Subject: Allow drag and drop on files into PrusaSlicer no matter which is the current selected tab --- src/slic3r/GUI/Plater.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index d23a3dd13..b78a6db95 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1586,12 +1586,15 @@ std::string& Sidebar::get_search_line() class PlaterDropTarget : public wxFileDropTarget { public: - PlaterDropTarget(Plater* plater) : m_plater(plater) { this->SetDefaultAction(wxDragCopy); } + PlaterDropTarget(MainFrame& mainframe, Plater& plater) : m_mainframe(mainframe), m_plater(plater) { + this->SetDefaultAction(wxDragCopy); + } virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &filenames); private: - Plater* m_plater; + MainFrame& m_mainframe; + Plater& m_plater; }; bool PlaterDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &filenames) @@ -1601,8 +1604,11 @@ bool PlaterDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &fi this->MSWUpdateDragImageOnLeave(); #endif // WIN32 - bool res = (m_plater != nullptr) ? m_plater->load_files(filenames) : false; - wxGetApp().mainframe->update_title(); + m_mainframe.Raise(); + m_mainframe.select_tab(size_t(0)); + m_plater.select_view_3D("3D"); + bool res = m_plater.load_files(filenames); + m_mainframe.update_title(); return res; } @@ -2144,7 +2150,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) } // Drop target: - q->SetDropTarget(new PlaterDropTarget(q)); // if my understanding is right, wxWindow takes the owenership + main_frame->SetDropTarget(new PlaterDropTarget(*main_frame, *q)); // if my understanding is right, wxWindow takes the owenership q->Layout(); set_current_panel(wxGetApp().is_editor() ? static_cast(view3D) : static_cast(preview)); -- cgit v1.2.3