FIX: switch_diameter in sync

Change-Id: Iff7c654ef932f36b9c3cb4267e4ea90b8074c9c2
Jira: STUDIO-9744
(cherry picked from commit 0c01d7b3e0224f745b249e8d8dbe1990f3b407bc)
This commit is contained in:
chunmao.guo 2025-01-16 16:12:21 +08:00 committed by Noisyfox
parent d1de8c47d7
commit 66eb27cfaa
2 changed files with 12 additions and 5 deletions

View file

@ -1001,7 +1001,11 @@ ExtruderGroup::ExtruderGroup(wxWindow * parent, int index, wxString const &title
//label_ams->SetMinSize({FromDIP(70), -1});
if (index >= 0) {
btn_edit = new ScalableButton(this, wxID_ANY, "dot");
#ifdef __WXOSX__
btn_edit->SetBackgroundColour("#F7F7F7");
#else
btn_edit->SetBackgroundColour(*wxWHITE);
#endif
btn_edit->Hide();
btn_edit->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [this, index](auto &evt) {
PopupWindow *window = new AMSCountPopupWindow(this, index);
@ -1300,7 +1304,9 @@ bool Sidebar::priv::sync_extruder_list(bool &only_external_material)
left_extruder->combo_diameter->SetSelection(get_diameter_index(nozzle_diameters[0]));
right_extruder->combo_diameter->SetSelection(get_diameter_index(nozzle_diameters[1]));
is_switching_diameter = true;
switch_diameter(false);
is_switching_diameter = false;
AMSCountPopupWindow::SetAMSCount(deputy_index, deputy_4, deputy_1);
AMSCountPopupWindow::SetAMSCount(main_index, main_4, main_1);
AMSCountPopupWindow::UpdateAMSCount(0, left_extruder);
@ -1751,7 +1757,7 @@ Sidebar::Sidebar(Plater *parent)
auto switch_diameter = [this](wxCommandEvent & evt) {
auto extruder = dynamic_cast<ExtruderGroup *>(dynamic_cast<ComboBox *>(evt.GetEventObject())->GetParent());
p->is_switching_diameter = true;
auto result = p->switch_diameter(extruder == p->single_extruder);
p->switch_diameter(extruder == p->single_extruder);
p->is_switching_diameter = false;
};
p->left_extruder->combo_diameter->Bind(wxEVT_COMBOBOX, switch_diameter);

View file

@ -61,10 +61,11 @@ void StaticGroup::PaintForeground(wxDC &dc, const struct tagRECT &rc)
int right = rc.right - 1;
int bottom = rc.bottom - 1;
auto blue = GetBackgroundColour().Blue();
while (image.GetBlue(0, top) == blue) ++top;
while (image.GetBlue(left, top) != blue) ++left; // --left; // fix start
while (image.GetBlue(right, top) != blue) --right; ++right;
while (image.GetBlue(0, bottom) == blue) --bottom;
while (image.GetBlue(0, top) == blue && top < bottom) ++top;
while (image.GetBlue(left, top) != blue && left < right) ++left; // --left; // fix start
while (image.GetBlue(right, top) != blue && right > 0) --right;
++right;
while (image.GetBlue(0, bottom) == blue && bottom > 0) --bottom;
// Draw border with foreground color
wxPoint polygon[] = { {left, top}, {0, top}, {0, bottom}, {rc.right - 1, bottom}, {rc.right - 1, top}, {right, top} };
dc.SetPen(wxPen(borderColor_, 1));