Match button styles on whole UI and fixes for button class (#11233)

* init

* web buttons

* Bind Dialog & Fix states

* update

* update

* Update common.css

* objcolordialog

* privacy update dialog

* Update CaliHistoryDialog.cpp

* Update MultiMachineManagerPage.cpp

* Update AMSControl.cpp

* TipsDialog

* Update AMSMaterialsSetting.cpp

* extrusion calibration

* Update UpdateDialogs.cpp

* recenterdialog

* update

* Update Calibration.cpp

* update

* update

* update

* fix

* update

* ReleaseNote

* update

* update

* fix remember checkbox position

* add comments
This commit is contained in:
yw4z 2025-12-18 15:14:56 +03:00 committed by GitHub
parent 59ad126b48
commit 00ff06a5d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
67 changed files with 406 additions and 1401 deletions

View file

@ -12,6 +12,7 @@
#include "libslic3r/Config.hpp"
#include "BitmapComboBox.hpp"
#include "Widgets/ComboBox.hpp"
#include "Widgets/DialogButtons.hpp"
#include <wx/sizer.h>
#include "libslic3r/ObjColorUtils.hpp"
@ -40,12 +41,7 @@ static void update_ui(wxWindow* window)
static const char g_min_cluster_color = 1;
static const char g_max_color = (int) EnforcerBlockerType::ExtruderMax;
const StateColor ok_btn_bg(std::pair<wxColour, int>(wxColour(0, 137, 123), StateColor::Pressed),
std::pair<wxColour, int>(wxColour(38, 166, 154), StateColor::Hovered),
std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Normal));
const StateColor ok_btn_disable_bg(std::pair<wxColour, int>(wxColour(205, 201, 201), StateColor::Pressed),
std::pair<wxColour, int>(wxColour(205, 201, 201), StateColor::Hovered),
std::pair<wxColour, int>(wxColour(205, 201, 201), StateColor::Normal));
wxBoxSizer* ObjColorDialog::create_btn_sizer(long flags,bool exist_error)
{
auto btn_sizer = new wxBoxSizer(wxHORIZONTAL);
@ -58,7 +54,7 @@ wxBoxSizer* ObjColorDialog::create_btn_sizer(long flags,bool exist_error)
auto font = tips->GetFont();
font.SetUnderlined(true);
tips->SetFont(font);
tips->SetForegroundColour(wxColour(0, 174, 100));
tips->SetForegroundColour(wxColour("#009687"));
tips->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) {
bool is_zh = wxGetApp().app_config->get("language") == "zh_CN";
if (is_zh) {
@ -71,79 +67,16 @@ wxBoxSizer* ObjColorDialog::create_btn_sizer(long flags,bool exist_error)
}
btn_sizer->AddStretchSpacer();
StateColor ok_btn_bd(
std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Normal)
);
StateColor ok_btn_text(
std::pair<wxColour, int>(wxColour(255, 255, 254), StateColor::Normal)
);
StateColor cancel_btn_bg(
std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Pressed),
std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Hovered),
std::pair<wxColour, int>(wxColour(255, 255, 255), StateColor::Normal)
);
StateColor cancel_btn_bd_(
std::pair<wxColour, int>(wxColour(38, 46, 48), StateColor::Normal)
);
StateColor cancel_btn_text(
std::pair<wxColour, int>(wxColour(38, 46, 48), StateColor::Normal)
);
StateColor calc_btn_bg(
std::pair<wxColour, int>(wxColour(0, 137, 123), StateColor::Pressed),
std::pair<wxColour, int>(wxColour(38, 166, 154), StateColor::Hovered),
std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Normal)
);
StateColor calc_btn_bd(
std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Normal)
);
StateColor calc_btn_text(
std::pair<wxColour, int>(wxColour(255, 255, 254), StateColor::Normal)
);
if (flags & wxOK) {
Button* ok_btn = new Button(this, _L("OK"));
ok_btn->SetMinSize(BTN_SIZE);
ok_btn->SetCornerRadius(FromDIP(12));
ok_btn->Enable(false);
ok_btn->SetBackgroundColor(ok_btn_disable_bg);
ok_btn->SetBorderColor(ok_btn_bd);
ok_btn->SetTextColor(ok_btn_text);
ok_btn->SetFocus();
ok_btn->SetId(wxID_OK);
btn_sizer->Add(ok_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, BTN_GAP);
m_button_list[wxOK] = ok_btn;
}
if (flags & wxCANCEL) {
Button* cancel_btn = new Button(this, _L("Cancel"));
cancel_btn->SetMinSize(BTN_SIZE);
cancel_btn->SetCornerRadius(FromDIP(12));
cancel_btn->SetBackgroundColor(cancel_btn_bg);
cancel_btn->SetBorderColor(cancel_btn_bd_);
cancel_btn->SetTextColor(cancel_btn_text);
cancel_btn->SetId(wxID_CANCEL);
btn_sizer->Add(cancel_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, BTN_GAP);
m_button_list[wxCANCEL] = cancel_btn;
}
auto dlg_btns = new DialogButtons(this, {"OK", "Cancel"});
m_button_list[wxOK] = dlg_btns->GetOK();
m_button_list[wxCANCEL] = dlg_btns->GetCANCEL();
btn_sizer->Add(dlg_btns, 0, wxEXPAND | wxALIGN_CENTER_VERTICAL);
return btn_sizer;
}
void ObjColorDialog::on_dpi_changed(const wxRect &suggested_rect)
{
for (auto button_item : m_button_list)
{
if (button_item.first == wxRESET)
{
button_item.second->SetMinSize(wxSize(FromDIP(75), FromDIP(24)));
button_item.second->SetCornerRadius(FromDIP(12));
}
if (button_item.first == wxOK) {
button_item.second->SetMinSize(BTN_SIZE);
button_item.second->SetCornerRadius(FromDIP(12));
}
if (button_item.first == wxCANCEL) {
button_item.second->SetMinSize(BTN_SIZE);
button_item.second->SetCornerRadius(FromDIP(12));
}
}
m_panel_ObjColor->msw_rescale();
this->Refresh();
}
@ -215,12 +148,12 @@ ObjColorDialog::ObjColorDialog(wxWindow *parent, Slic3r::ObjDialogInOut &in_out,
if (!ok) {
m_button_list[wxCANCEL]->Hide();
m_button_list[wxOK]->Enable(true);
m_button_list[wxOK]->SetBackgroundColor(ok_btn_bg);
// ORCA no need to set colors again
} else {
m_button_list[wxOK]->Bind(wxEVT_UPDATE_UI, ([this](wxUpdateUIEvent &e) {
if (m_panel_ObjColor->is_ok() == m_button_list[wxOK]->IsEnabled()) { return; }
m_button_list[wxOK]->Enable(m_panel_ObjColor->is_ok());
m_button_list[wxOK]->SetBackgroundColor(m_panel_ObjColor->is_ok() ? ok_btn_bg : ok_btn_disable_bg);
// ORCA no need to set colors again
}));
}
m_main_sizer->Add(m_buttons_sizer, 0, wxBOTTOM | wxTOP | wxRIGHT | wxEXPAND, BTN_GAP);
@ -556,23 +489,12 @@ void ObjColorPanel::do_layout_callback() {
wxBoxSizer *ObjColorPanel::create_approximate_match_btn_sizer(wxWindow *parent)
{
auto btn_sizer = new wxBoxSizer(wxHORIZONTAL);
StateColor calc_btn_bg(std::pair<wxColour, int>(wxColour(0, 137, 123), StateColor::Pressed), std::pair<wxColour, int>(wxColour(38, 166, 154), StateColor::Hovered),
std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Normal));
StateColor calc_btn_bd(std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Normal));
StateColor calc_btn_text(std::pair<wxColour, int>(wxColour(255, 255, 254), StateColor::Normal));
//create btn
m_quick_approximate_match_btn = new Button(parent, _L("Color match"));
m_quick_approximate_match_btn->SetToolTip(_L("Approximate color matching."));
auto cur_btn = m_quick_approximate_match_btn;
cur_btn->SetFont(Label::Body_13);
cur_btn->SetMinSize(wxSize(FromDIP(60), FromDIP(20)));
cur_btn->SetCornerRadius(FromDIP(10));
cur_btn->SetBackgroundColor(calc_btn_bg);
cur_btn->SetBorderColor(calc_btn_bd);
cur_btn->SetTextColor(calc_btn_text);
cur_btn->SetFocus();
btn_sizer->Add(cur_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 0);
cur_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent &) {
m_quick_approximate_match_btn->SetStyle(ButtonStyle::Regular, ButtonType::Window);
m_quick_approximate_match_btn->SetFocus();
btn_sizer->Add(m_quick_approximate_match_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 0);
m_quick_approximate_match_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent &) {
deal_approximate_match_btn();
deal_thumbnail();
});
@ -582,20 +504,10 @@ wxBoxSizer *ObjColorPanel::create_approximate_match_btn_sizer(wxWindow *parent)
wxBoxSizer *ObjColorPanel::create_add_btn_sizer(wxWindow *parent)
{
auto btn_sizer = new wxBoxSizer(wxHORIZONTAL);
StateColor calc_btn_bg(std::pair<wxColour, int>(wxColour(0, 137, 123), StateColor::Pressed), std::pair<wxColour, int>(wxColour(38, 166, 154), StateColor::Hovered),
std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Normal));
StateColor calc_btn_bd(std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Normal));
StateColor calc_btn_text(std::pair<wxColour, int>(wxColour(255, 255, 254), StateColor::Normal));
// create btn
m_quick_add_btn = new Button(parent, _L("Append"));
m_quick_add_btn->SetToolTip(_L("Append to existing filaments"));
auto cur_btn = m_quick_add_btn;
cur_btn->SetFont(Label::Body_13);
cur_btn->SetMinSize(wxSize(FromDIP(60), FromDIP(20)));
cur_btn->SetCornerRadius(FromDIP(10));
cur_btn->SetBackgroundColor(calc_btn_bg);
cur_btn->SetBorderColor(calc_btn_bd);
cur_btn->SetTextColor(calc_btn_text);
cur_btn->SetStyle(ButtonStyle::Regular, ButtonType::Window);
cur_btn->SetFocus();
btn_sizer->Add(cur_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 0);
cur_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent &) {
@ -608,20 +520,10 @@ wxBoxSizer *ObjColorPanel::create_add_btn_sizer(wxWindow *parent)
wxBoxSizer *ObjColorPanel::create_reset_btn_sizer(wxWindow *parent)
{
auto btn_sizer = new wxBoxSizer(wxHORIZONTAL);
StateColor calc_btn_bg(std::pair<wxColour, int>(wxColour(0, 137, 123), StateColor::Pressed), std::pair<wxColour, int>(wxColour(38, 166, 154), StateColor::Hovered),
std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Normal));
StateColor calc_btn_bd(std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Normal));
StateColor calc_btn_text(std::pair<wxColour, int>(wxColour(255, 255, 254), StateColor::Normal));
// create btn
m_quick_reset_btn = new Button(parent, _L("Reset"));
m_quick_reset_btn->SetToolTip(_L("Reset mapped extruders."));
auto cur_btn = m_quick_reset_btn;
cur_btn->SetFont(Label::Body_13);
cur_btn->SetMinSize(wxSize(FromDIP(60), FromDIP(20)));
cur_btn->SetCornerRadius(FromDIP(10));
cur_btn->SetBackgroundColor(calc_btn_bg);
cur_btn->SetBorderColor(calc_btn_bd);
cur_btn->SetTextColor(calc_btn_text);
cur_btn->SetStyle(ButtonStyle::Regular, ButtonType::Window);
cur_btn->SetFocus();
btn_sizer->Add(cur_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 0);
cur_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent &) {