From 619be468ac2004d3848d1a8852c68fa2c41c5403 Mon Sep 17 00:00:00 2001 From: "zhou.xu" Date: Tue, 1 Apr 2025 09:38:47 +0800 Subject: [PATCH] ENH:The dropdown menu remains displayed after clicking on the image jira: github 6255 Change-Id: I7f9a2b0e210a0b1405e1e15e8a494195570ce0d5 --- src/slic3r/GUI/Plater.cpp | 35 ++++++++++++++++++++--------------- src/slic3r/GUI/Plater.hpp | 2 ++ 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 99f456436..d98a3c21b 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1603,6 +1603,7 @@ Sidebar::Sidebar(Plater *parent) ScalableBitmap bitmap_bed(p->panel_printer_bed, "printer_placeholder", 32); p->image_printer_bed = new wxStaticBitmap(p->panel_printer_bed, wxID_ANY, bitmap_bed.bmp(), wxDefaultPosition, wxDefaultSize, 0); p->image_printer_bed->Bind(wxEVT_LEFT_DOWN, [this](auto &evt) { + p->image_printer_bed->Unbind(wxEVT_LEAVE_WINDOW, &Sidebar::on_leave_image_printer_bed, this); p->combo_printer_bed->wxEvtHandler::ProcessEvent(evt); }); @@ -1620,21 +1621,7 @@ Sidebar::Sidebar(Plater *parent) } e.Skip(); // fix bug:Event spreads to sidebar }); - - p->image_printer_bed->Bind(wxEVT_ENTER_WINDOW, [this](wxMouseEvent &evt) { - auto pos = p->image_printer_bed->GetScreenPosition(); - auto rect = p->image_printer_bed->GetRect(); - wxPoint temp_pos(pos.x + rect.GetWidth(), pos.y); - if (p->big_bed_image_popup == nullptr) { - p->big_bed_image_popup = new ImageDPIFrame(); - auto image_path = get_cur_select_bed_image(); - p->big_bed_image_popup->set_bitmap(create_scaled_bitmap("big_" + image_path, p->big_bed_image_popup, p->big_bed_image_popup->get_image_px())); - } - p->big_bed_image_popup->SetCanFocus(false); - p->big_bed_image_popup->SetPosition(temp_pos); - p->big_bed_image_popup->on_show(); - }); - p->image_printer_bed->Bind(wxEVT_LEAVE_WINDOW, [this](wxMouseEvent &evt) { p->big_bed_image_popup->on_hide(); }); + p->image_printer_bed->Bind(wxEVT_ENTER_WINDOW, &Sidebar::on_enter_image_printer_bed, this); wxBoxSizer *bed_type_vsizer = new wxBoxSizer(wxVERTICAL); bed_type_vsizer->AddStretchSpacer(1); @@ -1964,6 +1951,24 @@ Sidebar::Sidebar(Plater *parent) Sidebar::~Sidebar() {} +void Sidebar::on_enter_image_printer_bed(wxMouseEvent &evt) { + p->image_printer_bed->Unbind(wxEVT_LEAVE_WINDOW, &Sidebar::on_leave_image_printer_bed, this); + auto pos = p->image_printer_bed->GetScreenPosition(); + auto rect = p->image_printer_bed->GetRect(); + wxPoint temp_pos(pos.x + rect.GetWidth(), pos.y); + if (p->big_bed_image_popup == nullptr) { + p->big_bed_image_popup = new ImageDPIFrame(); + auto image_path = get_cur_select_bed_image(); + p->big_bed_image_popup->set_bitmap(create_scaled_bitmap("big_" + image_path, p->big_bed_image_popup, p->big_bed_image_popup->get_image_px())); + } + p->big_bed_image_popup->SetCanFocus(false); + p->big_bed_image_popup->SetPosition(temp_pos); + p->big_bed_image_popup->on_show(); +} + +void Sidebar::on_leave_image_printer_bed(wxMouseEvent &evt) { + p->big_bed_image_popup->on_hide(); +} void Sidebar::on_change_color_mode(bool is_dark) { const ModelObjectPtrs &mos = wxGetApp().model().objects; for (int i = 0; i < mos.size(); i++) { diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 127d0246b..fc281bf9c 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -140,6 +140,8 @@ public: Sidebar &operator=(const Sidebar &) = delete; ~Sidebar(); + void on_enter_image_printer_bed(wxMouseEvent &evt); + void on_leave_image_printer_bed(wxMouseEvent &evt); void on_change_color_mode(bool is_dark); void create_printer_preset(); void init_filament_combo(PlaterPresetComboBox **combo, const int filament_idx);