Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize wxButtons and add button styling management #8184

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
12 changes: 1 addition & 11 deletions src/slic3r/GUI/AboutDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,17 +355,7 @@ AboutDialog::AboutDialog()
}
//Add "Portions copyright" button
Button* button_portions = new Button(this,_L("Portions copyright"));
StateColor report_bg(std::pair<wxColour, int>(wxColour(255, 255, 255), StateColor::Disabled), 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::Enabled),
std::pair<wxColour, int>(wxColour(255, 255, 255), StateColor::Normal));
button_portions->SetBackgroundColor(report_bg);
StateColor report_bd(std::pair<wxColour, int>(wxColour(144, 144, 144), StateColor::Disabled), std::pair<wxColour, int>(wxColour(38, 46, 48), StateColor::Enabled));
button_portions->SetBorderColor(report_bd);
StateColor report_text(std::pair<wxColour, int>(wxColour(144, 144, 144), StateColor::Disabled), std::pair<wxColour, int>(wxColour(38, 46, 48), StateColor::Enabled));
button_portions->SetTextColor(report_text);
button_portions->SetFont(Label::Body_12);
button_portions->SetCornerRadius(FromDIP(12));
button_portions->SetMinSize(wxSize(FromDIP(120), FromDIP(24)));
button_portions->SetStyle("Regular", "Window");

wxBoxSizer *copyright_button_ver = new wxBoxSizer(wxVERTICAL);
copyright_button_ver->Add( 0, 0, 0, wxTOP, FromDIP(10));
Expand Down
63 changes: 31 additions & 32 deletions src/slic3r/GUI/BedShapeDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,23 @@ void BedShapeDialog::build_dialog(const ConfigOptionPoints& default_pt, const Co

auto main_sizer = new wxBoxSizer(wxVERTICAL);
main_sizer->Add(m_panel, 1, wxEXPAND);
main_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10);

auto btn_sizer = new wxBoxSizer(wxHORIZONTAL);

Button* ok_btn = new Button(this, _L("OK"));
ok_btn->SetStyle("Confirm", "Choice");
ok_btn->SetFocus();
ok_btn->SetId(wxID_OK);
btn_sizer->Add(ok_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, FromDIP(ButtonProps::ChoiceGap()));
m_button_list[wxOK] = ok_btn;

Button* cancel_btn = new Button(this, _L("Cancel"));
cancel_btn->SetStyle("Regular", "Choice");
cancel_btn->SetId(wxID_CANCEL);
btn_sizer->Add(cancel_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, FromDIP(ButtonProps::ChoiceGap()));
m_button_list[wxCANCEL] = cancel_btn;

main_sizer->Add(btn_sizer, 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10);

wxGetApp().UpdateDlgDarkUI(this);

Expand All @@ -161,6 +177,9 @@ void BedShapeDialog::on_dpi_changed(const wxRect &suggested_rect)
for (auto og : m_panel->m_optgroups)
og->msw_rescale();

m_button_list[wxOK] ->SetType("Choice"); // Rescale Button
m_button_list[wxCANCEL] ->SetType("Choice"); // Rescale Button

const wxSize& size = wxSize(50 * em, -1);

SetMinSize(size);
Expand Down Expand Up @@ -204,6 +223,7 @@ void BedShapePanel::build_panel(const ConfigOptionPoints& default_pt, const std:
line.full_width = 1;
line.widget = [this](wxWindow* parent) {
Button* shape_btn = new Button(parent, _L("Load shape from STL..."));
shape_btn->SetStyle("Regular");
wxSizer* shape_sizer = new wxBoxSizer(wxHORIZONTAL);
shape_sizer->Add(shape_btn, 1, wxEXPAND);

Expand Down Expand Up @@ -285,33 +305,22 @@ wxPanel* BedShapePanel::init_texture_panel()
line.full_width = 1;
line.widget = [this](wxWindow* parent) {

StateColor btn_bg_white(std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Disabled), std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Pressed),
std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Hovered),
std::pair<wxColour, int>(*wxWHITE, StateColor::Normal));

StateColor btn_bd_white(std::pair<wxColour, int>(*wxWHITE, StateColor::Disabled), std::pair<wxColour, int>(wxColour(38, 46, 48), StateColor::Enabled));

Button* load_btn = new Button(parent, _L("Load..."));
load_btn->SetBackgroundColor(btn_bg_white);
load_btn->SetBorderColor(btn_bd_white);
load_btn->SetBackgroundColour(*wxWHITE);
load_btn->SetStyle("Regular");
wxSizer* load_sizer = new wxBoxSizer(wxHORIZONTAL);
load_sizer->Add(load_btn, 1, wxEXPAND);

wxStaticText* filename_lbl = new wxStaticText(parent, wxID_ANY, _(NONE));

wxSizer* filename_sizer = new wxBoxSizer(wxHORIZONTAL);
filename_sizer->Add(filename_lbl, 1, wxEXPAND);

Button* remove_btn = new Button(parent, _L("Remove"));
remove_btn->SetBackgroundColor(btn_bg_white);
remove_btn->SetBorderColor(btn_bd_white);
remove_btn->SetBackgroundColour(*wxWHITE);
remove_btn->SetStyle("Regular");
wxSizer* remove_sizer = new wxBoxSizer(wxHORIZONTAL);
remove_sizer->Add(remove_btn, 1, wxEXPAND);

wxGetApp().UpdateDarkUI(load_btn);
wxGetApp().UpdateDarkUI(remove_btn);
wxGetApp().UpdateDarkUI(load_btn); // ???? required?
wxGetApp().UpdateDarkUI(remove_btn); // ???? required?

wxSizer* sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(filename_sizer, 1, wxEXPAND);
Expand Down Expand Up @@ -374,33 +383,23 @@ wxPanel* BedShapePanel::init_model_panel()
Line line{ "", "" };
line.full_width = 1;
line.widget = [this](wxWindow* parent) {
StateColor btn_bg_white(std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Disabled), std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Pressed),
std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Hovered),
std::pair<wxColour, int>(*wxWHITE, StateColor::Normal));

StateColor btn_bd_white(std::pair<wxColour, int>(*wxWHITE, StateColor::Disabled), std::pair<wxColour, int>(wxColour(38, 46, 48), StateColor::Enabled));


Button* load_btn = new Button(parent, _L("Load..."));
load_btn->SetBackgroundColor(btn_bg_white);
load_btn->SetBorderColor(btn_bd_white);
load_btn->SetBackgroundColour(*wxWHITE);
load_btn->SetStyle("Regular");
wxSizer* load_sizer = new wxBoxSizer(wxHORIZONTAL);
load_sizer->Add(load_btn, 1, wxEXPAND);

wxStaticText* filename_lbl = new wxStaticText(parent, wxID_ANY, _(NONE));
wxSizer* filename_sizer = new wxBoxSizer(wxHORIZONTAL);
wxStaticText* filename_lbl = new wxStaticText(parent, wxID_ANY, _(NONE));
wxSizer* filename_sizer = new wxBoxSizer(wxHORIZONTAL);
filename_sizer->Add(filename_lbl, 1, wxEXPAND);

Button* remove_btn = new Button(parent, _L("Remove"));
remove_btn->SetBackgroundColor(btn_bg_white);
remove_btn->SetBorderColor(btn_bd_white);
remove_btn->SetBackgroundColour(*wxWHITE);
remove_btn->SetStyle("Regular");
wxSizer* remove_sizer = new wxBoxSizer(wxHORIZONTAL);
remove_sizer->Add(remove_btn, 1, wxEXPAND);

wxGetApp().UpdateDarkUI(load_btn);
wxGetApp().UpdateDarkUI(remove_btn);
wxGetApp().UpdateDarkUI(load_btn); // ???? Required
wxGetApp().UpdateDarkUI(remove_btn); // ????

wxSizer* sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(filename_sizer, 1, wxEXPAND);
Expand Down
2 changes: 2 additions & 0 deletions src/slic3r/GUI/BedShapeDialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "I18N.hpp"

#include <libslic3r/BuildVolume.hpp>
#include <slic3r/GUI/Widgets/Button.hpp>

#include <wx/dialog.h>
#include <wx/choicebk.h>
Expand Down Expand Up @@ -104,6 +105,7 @@ class BedShapeDialog : public DPIDialog

protected:
void on_dpi_changed(const wxRect &suggested_rect) override;
std::unordered_map<int, Button*> m_button_list; // ??? solve that without list. use sizer items as list and check their types to prevent errors
};

} // GUI
Expand Down
Loading
Loading