ENH:The dropdown menu remains displayed after clicking on the image

jira: github 6255
Change-Id: I7f9a2b0e210a0b1405e1e15e8a494195570ce0d5
This commit is contained in:
zhou.xu 2025-04-01 09:38:47 +08:00 committed by lane.wei
parent cf5a2c9046
commit 619be468ac
2 changed files with 22 additions and 15 deletions

View File

@ -1603,6 +1603,7 @@ Sidebar::Sidebar(Plater *parent)
ScalableBitmap bitmap_bed(p->panel_printer_bed, "printer_placeholder", 32); 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 = 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->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); p->combo_printer_bed->wxEvtHandler::ProcessEvent(evt);
}); });
@ -1620,21 +1621,7 @@ Sidebar::Sidebar(Plater *parent)
} }
e.Skip(); // fix bug:Event spreads to sidebar e.Skip(); // fix bug:Event spreads to sidebar
}); });
p->image_printer_bed->Bind(wxEVT_ENTER_WINDOW, &Sidebar::on_enter_image_printer_bed, this);
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(); });
wxBoxSizer *bed_type_vsizer = new wxBoxSizer(wxVERTICAL); wxBoxSizer *bed_type_vsizer = new wxBoxSizer(wxVERTICAL);
bed_type_vsizer->AddStretchSpacer(1); bed_type_vsizer->AddStretchSpacer(1);
@ -1964,6 +1951,24 @@ Sidebar::Sidebar(Plater *parent)
Sidebar::~Sidebar() {} 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) { void Sidebar::on_change_color_mode(bool is_dark) {
const ModelObjectPtrs &mos = wxGetApp().model().objects; const ModelObjectPtrs &mos = wxGetApp().model().objects;
for (int i = 0; i < mos.size(); i++) { for (int i = 0; i < mos.size(); i++) {

View File

@ -140,6 +140,8 @@ public:
Sidebar &operator=(const Sidebar &) = delete; Sidebar &operator=(const Sidebar &) = delete;
~Sidebar(); ~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 on_change_color_mode(bool is_dark);
void create_printer_preset(); void create_printer_preset();
void init_filament_combo(PlaterPresetComboBox **combo, const int filament_idx); void init_filament_combo(PlaterPresetComboBox **combo, const int filament_idx);