diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index f4b7e758a..9e7409c11 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -6536,12 +6536,7 @@ void Plater::search(bool plater_is_active) canvas3D()->on_char(evt); } else - { - wxPoint pos = this->ClientToScreen(wxPoint(0, 0)); - pos.x += em_unit(this) * 40; - pos.y += em_unit(this) * 4; - p->sidebar->get_searcher().search_dialog->Popup(pos); - } + p->sidebar->get_searcher().show_dialog(); } void Plater::msw_rescale() diff --git a/src/slic3r/GUI/Search.cpp b/src/slic3r/GUI/Search.cpp index 83d60ac6e..000ebf402 100644 --- a/src/slic3r/GUI/Search.cpp +++ b/src/slic3r/GUI/Search.cpp @@ -289,7 +289,6 @@ bool OptionsSearcher::search(const std::string& search, bool force/* = false*/) OptionsSearcher::OptionsSearcher() { - search_dialog = new SearchDialog(this); } OptionsSearcher::~OptionsSearcher() @@ -386,6 +385,22 @@ Option OptionsSearcher::get_option(const std::string& opt_key, const wxString& l return create_option(opt_key, label, type, gc); } +void OptionsSearcher::show_dialog() +{ + if (!search_dialog) { + search_dialog = new SearchDialog(this); + + auto parent = search_dialog->GetParent(); + wxPoint pos = parent->ClientToScreen(wxPoint(0, 0)); + pos.x += em_unit(parent) * 40; + pos.y += em_unit(parent) * 4; + + search_dialog->SetPosition(pos); + } + + search_dialog->Popup(); +} + void OptionsSearcher::add_key(const std::string& opt_key, Preset::Type type, const wxString& group, const wxString& category) { groups_and_categories[get_key(opt_key, type)] = GroupAndCategory{group, category}; @@ -405,7 +420,7 @@ static const std::map icon_idxs = { }; SearchDialog::SearchDialog(OptionsSearcher* searcher) - : GUI::DPIDialog(NULL, wxID_ANY, _L("Search"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), + : GUI::DPIDialog(GUI::wxGetApp().tab_panel(), wxID_ANY, _L("Search"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), searcher(searcher) { SetFont(GUI::wxGetApp().normal_font()); @@ -506,7 +521,8 @@ void SearchDialog::Popup(wxPoint position /*= wxDefaultPosition*/) if (check_english) check_english->SetValue(params.english); - this->SetPosition(position); + if (position != wxDefaultPosition) + this->SetPosition(position); this->ShowModal(); } diff --git a/src/slic3r/GUI/Search.hpp b/src/slic3r/GUI/Search.hpp index a942a89f8..99575e1fa 100644 --- a/src/slic3r/GUI/Search.hpp +++ b/src/slic3r/GUI/Search.hpp @@ -134,6 +134,8 @@ public: return o1.key < o2.key; }); } void sort_options_by_label() { sort_options(); } + + void show_dialog(); };