From 8d3c346b1a030628fe6ea509ccd6bedd3382737e Mon Sep 17 00:00:00 2001 From: "chunmao.guo" Date: Mon, 20 Jan 2025 18:38:41 +0800 Subject: [PATCH] FIX: cancel switch diameter restore old selection Change-Id: Ic0919ade0ab3f75c417d87c7cf6c5738958a1cf8 Jira: STUDIO-10069 --- src/slic3r/GUI/MsgDialog.cpp | 11 +++++------ src/slic3r/GUI/Plater.cpp | 14 ++++++++------ src/slic3r/GUI/Widgets/StateColor.cpp | 1 + 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/slic3r/GUI/MsgDialog.cpp b/src/slic3r/GUI/MsgDialog.cpp index 103a57523..4020b15d1 100644 --- a/src/slic3r/GUI/MsgDialog.cpp +++ b/src/slic3r/GUI/MsgDialog.cpp @@ -178,13 +178,11 @@ Button* MsgDialog::add_button(wxWindowID btn_id, bool set_focus /*= false*/, con std::pair(wxColour(38, 46, 48), StateColor::Normal) ); - if (btn_id == wxID_OK || btn_id == wxID_YES) { + if (set_focus) { btn->SetBackgroundColor(btn_bg_green); btn->SetBorderColor(btn_bd_green); btn->SetTextColor(btn_text_green); - } - - if (btn_id == wxID_CANCEL || btn_id == wxID_NO) { + } else { btn->SetBackgroundColor(btn_bg_white); btn->SetBorderColor(btn_bd_white); btn->SetTextColor(btn_text_white); @@ -213,8 +211,9 @@ Button* MsgDialog::get_button(wxWindowID btn_id){ void MsgDialog::apply_style(long style) { - if (style & wxOK) add_button(wxID_OK, true, _L("OK")); - if (style & wxYES) add_button(wxID_YES, true, _L("Yes")); + bool focus = (style & wxNO_DEFAULT) == 0; + if (style & wxOK) add_button(wxID_OK, focus, _L("OK")); + if (style & wxYES) add_button(wxID_YES, focus, _L("Yes")); if (style & wxNO) add_button(wxID_NO, false,_L("No")); if (style & wxCANCEL) add_button(wxID_CANCEL, false, _L("Cancel")); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index f16115396..36dcad435 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1103,13 +1103,13 @@ bool Sidebar::priv::switch_diameter(bool single) _L("The software does not support using different diameter of nozzles for one print.\n" "If the left and right nozzles are inconsistent, we can only proceed with single-head printing.\n" "Please confirm which nozzle you would like to use for this project."), - _L("Switch diameter"), wxNO | wxCANCEL); - dlg.SetButtonLabel(wxID_NO, wxString::Format(_L("Left nozzle: %smm"), diameter_left)); - dlg.SetButtonLabel(wxID_CANCEL, wxString::Format(_L("Right nozzle: %smm"), diameter_right)); + _L("Switch diameter"), wxYES_NO | wxNO_DEFAULT); + dlg.SetButtonLabel(wxID_YES, wxString::Format(_L("Left nozzle: %smm"), diameter_left)); + dlg.SetButtonLabel(wxID_NO, wxString::Format(_L("Right nozzle: %smm"), diameter_right)); int result = dlg.ShowModal(); - if (result == wxID_NO) + if (result == wxID_YES) diameter = diameter_left; - else if (result == wxID_CANCEL) + else if (result == wxID_NO) diameter = diameter_right; else return false; @@ -1660,8 +1660,10 @@ Sidebar::Sidebar(Plater *parent) auto switch_diameter = [this](wxCommandEvent & evt) { auto extruder = dynamic_cast(dynamic_cast(evt.GetEventObject())->GetParent()); p->is_switching_diameter = true; - p->switch_diameter(extruder == p->single_extruder); + auto result = p->switch_diameter(extruder == p->single_extruder); p->is_switching_diameter = false; + if (!result) + extruder->combo_diameter->SetValue(extruder->diameter); }; p->left_extruder->combo_diameter->Bind(wxEVT_COMBOBOX, switch_diameter); p->right_extruder->combo_diameter->Bind(wxEVT_COMBOBOX, switch_diameter); diff --git a/src/slic3r/GUI/Widgets/StateColor.cpp b/src/slic3r/GUI/Widgets/StateColor.cpp index ad1d3a874..817257cfd 100644 --- a/src/slic3r/GUI/Widgets/StateColor.cpp +++ b/src/slic3r/GUI/Widgets/StateColor.cpp @@ -24,6 +24,7 @@ static std::map gDarkColors{ {"#DBFDD5", "#3B3B40"}, {"#000000", "#FFFFFE"}, {"#F4F4F4", "#36363D"}, + {"#F7F7F7", "#333337"}, {"#DBDBDB", "#4A4A51"}, {"#EDFAF2", "#283232"}, {"#323A3C", "#E5E5E6"},