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
67 changed files with 406 additions and 1401 deletions

View File

@@ -133,37 +133,9 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
m_panel_option_right->SetMinSize(wxSize(FromDIP(180), -1));
m_panel_option_right->SetMaxSize(wxSize(FromDIP(180), -1));
StateColor btn_bg_green(std::pair<wxColour, int>(AMS_CONTROL_DISABLE_COLOUR, StateColor::Disabled),
std::pair<wxColour, int>(wxColour(0, 137, 123), StateColor::Pressed),
std::pair<wxColour, int>(wxColour(38, 166, 154), StateColor::Hovered),
std::pair<wxColour, int>(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal));
StateColor btn_bg_white(std::pair<wxColour, int>(AMS_CONTROL_DISABLE_COLOUR, StateColor::Disabled),
std::pair<wxColour, int>(AMS_CONTROL_DISABLE_COLOUR, StateColor::Pressed),
std::pair<wxColour, int>(AMS_CONTROL_DEF_BLOCK_BK_COLOUR, StateColor::Hovered),
std::pair<wxColour, int>(AMS_CONTROL_WHITE_COLOUR, StateColor::Normal));
StateColor btn_bd_green(std::pair<wxColour, int>(wxColour(255, 255, 254), StateColor::Disabled),
std::pair<wxColour, int>(AMS_CONTROL_BRAND_COLOUR, StateColor::Enabled));
StateColor btn_bd_white(std::pair<wxColour, int>(wxColour(255, 255, 254), StateColor::Disabled),
std::pair<wxColour, int>(wxColour(38, 46, 48), StateColor::Enabled));
StateColor btn_text_green(std::pair<wxColour, int>(wxColour(255, 255, 254), StateColor::Disabled),
std::pair<wxColour, int>(wxColour(255, 255, 254), StateColor::Enabled));
StateColor btn_text_white(std::pair<wxColour, int>(wxColour(255, 255, 254), StateColor::Disabled),
std::pair<wxColour, int>(wxColour(38, 46, 48), StateColor::Enabled));
/*option left*/
m_button_auto_refill = new Button(m_panel_option_left, _L("Auto-refill"));
m_button_auto_refill->SetBackgroundColor(btn_bg_white);
m_button_auto_refill->SetBorderColor(btn_bd_white);
m_button_auto_refill->SetTextColor(btn_text_white);
m_button_auto_refill->SetFont(Label::Body_13);
m_button_auto_refill->SetMinSize(wxSize(FromDIP(80), FromDIP(34)));
m_button_auto_refill->SetMaxSize(wxSize(FromDIP(80), FromDIP(34)));
m_button_auto_refill->SetStyle(ButtonStyle::Regular, ButtonType::Choice);
m_button_ams_setting_normal = ScalableBitmap(this, "ams_setting_normal", 24);
m_button_ams_setting_hover = ScalableBitmap(this, "ams_setting_hover", 24);
@@ -182,12 +154,7 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
/*option right*/
m_button_extruder_feed = new Button(m_panel_option_right, _L("Load"));
m_button_extruder_feed->SetFont(Label::Body_13);
m_button_extruder_feed->SetBackgroundColor(btn_bg_green);
m_button_extruder_feed->SetBorderColor(btn_bd_green);
m_button_extruder_feed->SetTextColor(btn_text_green);
m_button_extruder_feed->SetMinSize(wxSize(FromDIP(80),FromDIP(34)));
m_button_extruder_feed->SetMaxSize(wxSize(FromDIP(80),FromDIP(34)));
m_button_extruder_feed->SetStyle(ButtonStyle::Confirm, ButtonType::Choice);
m_button_extruder_feed->EnableTooltipEvenDisabled();
@@ -203,12 +170,7 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
if (wxGetApp().app_config->get("language") == "pt_BR") m_button_extruder_feed->SetLabel("Load");
m_button_extruder_back = new Button(m_panel_option_right, _L("Unload"));
m_button_extruder_back->SetBackgroundColor(btn_bg_white);
m_button_extruder_back->SetBorderColor(btn_bd_white);
m_button_extruder_back->SetTextColor(btn_text_white);
m_button_extruder_back->SetFont(Label::Body_13);
m_button_extruder_back->SetMinSize(wxSize(FromDIP(80), FromDIP(34)));
m_button_extruder_back->SetMaxSize(wxSize(FromDIP(80), FromDIP(34)));
m_button_auto_refill->SetStyle(ButtonStyle::Regular, ButtonType::Choice);
m_button_extruder_back->EnableTooltipEvenDisabled();
if (wxGetApp().app_config->get("language") == "de_DE") m_button_extruder_back->SetFont(Label::Body_9);
@@ -502,12 +464,9 @@ void AMSControl::msw_rescale()
m_extruder->msw_rescale();
if (m_button_extruder_feed) m_button_extruder_feed->SetMinSize(wxSize(FromDIP(80), FromDIP(34)));
if (m_button_extruder_feed) m_button_extruder_feed->SetMaxSize(wxSize(FromDIP(80), FromDIP(34)));
if (m_button_extruder_back) m_button_extruder_back->SetMinSize(wxSize(FromDIP(80), FromDIP(34)));
if (m_button_extruder_back) m_button_extruder_back->SetMaxSize(wxSize(FromDIP(80), FromDIP(34)));
if (m_button_auto_refill) m_button_auto_refill->SetMinSize(wxSize(FromDIP(80), FromDIP(34)));
if (m_button_auto_refill) m_button_auto_refill->SetMaxSize(wxSize(FromDIP(80), FromDIP(34)));
if (m_button_extruder_feed) m_button_extruder_feed->Rescale(); // ORCA
if (m_button_extruder_back) m_button_extruder_back->Rescale(); // ORCA
if (m_button_auto_refill) m_button_auto_refill->Rescale(); // ORCA
if (m_button_ams_setting) m_button_ams_setting->SetMinSize(wxSize(FromDIP(25), FromDIP(24)));

View File

@@ -174,7 +174,7 @@ void Button::SetVertical(bool vertical)
// Background Foreground Border on focus
// Button Colors 0-Disabled 1-Pressed 2-Hover 3-Normal 4-Enabled 5-Disabled 6-Normal 7-Hover 8-Dark 9-Light
wxString btn_regular[10] = {"#DFDFDF", "#DFDFDF", "#D4D4D4", "#DFDFDF", "#DFDFDF", "#6B6A6A", "#262E30", "#262E30", "#009688", "#009688"};
wxString btn_confirm[10] = {"#DFDFDF", "#009688", "#26A69A", "#009688", "#009688", "#6B6A6A", "#FEFEFE", "#FEFEFE", "#26A69A", "#00FFD4"};
wxString btn_confirm[10] = {"#DFDFDF", "#009688", "#26A69A", "#009688", "#009688", "#6B6A6A", "#FEFEFE", "#FEFEFE", "#22bfb0", "#00FFD4"};
wxString btn_alert[10] = {"#DFDFDF", "#DFDFDF", "#E14747", "#DFDFDF", "#DFDFDF", "#6B6A6A", "#262E30", "#FFFFFD", "#009688", "#009688"};
wxString btn_disabled[10] = {"#DFDFDF", "#DFDFDF", "#DFDFDF", "#DFDFDF", "#DFDFDF", "#6B6A6A", "#6B6A6A", "#262E30", "#DFDFDF", "#DFDFDF"};
@@ -220,19 +220,24 @@ void Button::SetStyle(const ButtonStyle style, const ButtonType type)
style == ButtonStyle::Disabled ? btn_disabled :
btn_regular ;
this->SetBackgroundColor(StateColor(
std::pair(wxColour(clr_arr[3]), (int)StateColor::NotHovered),
auto bg_color = StateColor(
std::pair(wxColour(clr_arr[0]), (int)StateColor::Disabled),
std::pair(wxColour(clr_arr[1]), (int)StateColor::Pressed),
std::pair(wxColour(clr_arr[2]), (int)StateColor::Hovered),
std::pair(wxColour(clr_arr[3]), (int)StateColor::Normal),
std::pair(wxColour(clr_arr[4]), (int)StateColor::Enabled)
));
this->SetBorderColor(StateColor(
std::pair(wxColour(clr_arr[3]), (int)StateColor::NotFocused),
);
bg_color.setTakeFocusedAsHovered(false);
this->SetBackgroundColor(bg_color);
wxColour focus_clr = clr_arr[is_dark ? 8 : 9];
auto border_color = StateColor(
std::pair(wxColour(clr_arr[0]), (int)StateColor::Disabled),
std::pair(wxColour(clr_arr[is_dark ? 8 : 9]), (int)StateColor::Focused)
));
std::pair(wxColour(clr_arr[2]), (int)(StateColor::Hovered | ~StateColor::Focused)),
std::pair(wxColour(focus_clr ), (int)StateColor::Focused),
std::pair(wxColour(clr_arr[3]), (int)StateColor::Normal)
);
border_color.setTakeFocusedAsHovered(false);
this->SetBorderColor(border_color);
this->SetTextColor(StateColor(
std::pair(wxColour(clr_arr[5]), (int)StateColor::Disabled),
std::pair(wxColour(clr_arr[7]), (int)StateColor::Hovered),

View File

@@ -5,13 +5,14 @@
namespace Slic3r { namespace GUI {
// ORCA standardize dialog buttons
DialogButtons::DialogButtons(wxWindow* parent, std::vector<wxString> non_translated_labels, const wxString& primary_btn_translated_label)
DialogButtons::DialogButtons(wxWindow* parent, std::vector<wxString> non_translated_labels, const wxString& primary_btn_translated_label, const int left_aligned_buttons_count)
: wxPanel(parent, wxID_ANY)
{
m_parent = parent;
m_sizer = new wxBoxSizer(wxHORIZONTAL);
m_primary = primary_btn_translated_label;
m_alert = wxEmptyString;
m_left_aligned_buttons_count = left_aligned_buttons_count;
SetBackgroundColour(StateColor::darkModeColorFor(wxColour("#FFFFFF")));
// Add all to array
@@ -55,6 +56,13 @@ Button* DialogButtons::GetButtonFromLabel(wxString translated_label) {
return nullptr;
}
Button* DialogButtons::GetButtonFromIndex(int index) {
if(index >= 0 && index < m_buttons.size())
return m_buttons[index];
else
return nullptr;
}
Button* DialogButtons::PickFromList(std::set<wxStandardID> ID_list) {
// Picks first button from given list
Button* b;
@@ -75,6 +83,8 @@ Button* DialogButtons::GetNO() {return GetButtonFromID(wxID_NO) ;}
Button* DialogButtons::GetCANCEL() {return GetButtonFromID(wxID_CANCEL) ;}
Button* DialogButtons::GetRETURN() {return GetButtonFromID(wxID_BACKWARD);} // gets Return button
Button* DialogButtons::GetNEXT() {return GetButtonFromID(wxID_FORWARD) ;}
Button* DialogButtons::GetFIRST() {return GetButtonFromIndex(0) ;}
Button* DialogButtons::GetLAST() {return GetButtonFromIndex(m_buttons.size() - 1);}
void DialogButtons::SetPrimaryButton(wxString translated_label) {
// use _L("Create") translated text for custom buttons
@@ -127,25 +137,18 @@ void DialogButtons::UpdateButtons() {
btn->Bind(wxEVT_KEY_DOWN, &DialogButtons::on_keydown, this);
}
int btn_gap = FromDIP(10);
int btn_gap = FromDIP(ButtonProps::ChoiceButtonGap());
auto list = m_left_align_IDs;
auto on_left = [list](int id){
return list.find(wxStandardID(id)) != list.end();
};
for (Button* btn : m_buttons) // Left aligned
if(on_left(btn->GetId()))
m_sizer->Add(btn, 0, wxLEFT | wxTOP | wxBOTTOM | wxALIGN_CENTER_VERTICAL, btn_gap);
m_sizer->AddStretchSpacer();
if(m_sizer->IsEmpty()) // add left margin if no button on left. fixes no gap on small windows
if(m_left_aligned_buttons_count == 0)
m_sizer->AddSpacer(btn_gap);
for (Button* btn : m_buttons) // Right aligned
if(!on_left(btn->GetId()))
m_sizer->Add(btn, 0, wxRIGHT | wxTOP | wxBOTTOM | wxALIGN_CENTER_VERTICAL, btn_gap);
for (int i = 0; i < m_buttons.size(); i++) {
if(m_left_aligned_buttons_count == i)
m_sizer->AddStretchSpacer();
auto margin_to = (i >= m_left_aligned_buttons_count ? wxRIGHT : wxLEFT);
m_sizer->Add(m_buttons[i], 0, margin_to | wxTOP | wxBOTTOM | wxALIGN_CENTER_VERTICAL, btn_gap);
}
SetPrimaryButton(m_primary);
SetAlertButton(m_alert);
@@ -158,6 +161,11 @@ int DialogButtons::FromDIP(int d) {
return m_parent->FromDIP(d);
}
void DialogButtons::SetLeftAlignedButtonsCount(int left_aligned_buttons_count){
m_left_aligned_buttons_count = left_aligned_buttons_count;
UpdateButtons();
}
// This might be helpful for future use
// Append Button

View File

@@ -16,7 +16,7 @@ namespace Slic3r { namespace GUI {
class DialogButtons : public wxPanel{
public:
DialogButtons(wxWindow* parent, std::vector<wxString> non_translated_labels, const wxString& primary_btn_label = "");
DialogButtons(wxWindow* parent, std::vector<wxString> non_translated_labels, const wxString& primary_btn_label = "", const int left_aligned_buttons_count = 0);
wxBoxSizer* GetSizer() const { return m_sizer; }
@@ -24,6 +24,8 @@ public:
Button* GetButtonFromLabel(wxString label);
Button* GetButtonFromIndex(int index);
Button* GetOK();
Button* GetYES();
Button* GetAPPLY();
@@ -32,11 +34,15 @@ public:
Button* GetCANCEL();
Button* GetRETURN();
Button* GetNEXT();
Button* GetFIRST();
Button* GetLAST();
void SetPrimaryButton(wxString label);
void SetAlertButton(wxString label);
void SetLeftAlignedButtonsCount(int left_aligned_buttons_count);
void UpdateButtons();
~DialogButtons();
@@ -47,6 +53,7 @@ private:
std::vector<Button*> m_buttons;
wxString m_primary;
wxString m_alert;
int m_left_aligned_buttons_count;
// missing ones Transfer / Update / Create
const std::map<wxString, wxStandardID> m_standardIDs = {
@@ -106,12 +113,6 @@ private:
wxID_EXIT
};
std::set<wxStandardID> m_left_align_IDs {
wxID_DELETE,
wxID_BACKWARD,
wxID_FORWARD
};
Button* PickFromList(std::set<wxStandardID> ID_list);
int FromDIP(int d);

View File

@@ -14,6 +14,7 @@ static std::map<wxColour, wxColour> gDarkColors{
{"#DFDFDF", "#3E3E45"}, // rgb(223, 223, 223) Button Background color
{"#D4D4D4", "#4D4D54"}, // rgb(212, 212, 212) Button Background color on Hover
{"#6B6A6A", "#909090"}, // rgb(107, 107, 106) Button Dimmed text
{"#26A69A", "#008172"}, // rgb(0, 150, 136) Button Confirm Color hover | ORCA Color Hover
{"#6B6B6A", "#B3B3B5"}, // rgb(107, 107, 106) Input box side text
{"#2C2C2E", "#B3B3B4"}, // rgb(44, 44, 46) ???
{"#6B6B6B", "#818183"}, // rgb(107, 107, 107) Disabled Text