DialogButtons fixes and apply to more windows (#9809)

* step import dialog

* update

* update

* drop file dialog

* Update UnsavedChangesDialog.cpp

* update

* fix focus

* Update CreatePresetsDialog.cpp

* improve usage of return button

* fix first button not getting hover effects

* update

* update

* improve button styles

* update button events

* update button events

* update button events

* remove Raise()
This commit is contained in:
yw4z
2025-06-14 05:27:10 +03:00
committed by GitHub
parent 33dc7bc1f2
commit 0999cb057d
15 changed files with 98 additions and 279 deletions

View File

@@ -1016,7 +1016,7 @@ wxWindow *CreateFilamentPresetDialog::create_dialog_buttons()
auto btn_ok = dlg_btns->GetOK(); auto btn_ok = dlg_btns->GetOK();
btn_ok->SetLabel(_L("Create")); btn_ok->SetLabel(_L("Create"));
btn_ok->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { btn_ok->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) {
//get vendor name //get vendor name
wxString vendor_str = m_filament_vendor_combobox->GetLabel(); wxString vendor_str = m_filament_vendor_combobox->GetLabel();
std::string vendor_name; std::string vendor_name;
@@ -1174,7 +1174,7 @@ wxWindow *CreateFilamentPresetDialog::create_dialog_buttons()
EndModal(wxID_OK); EndModal(wxID_OK);
}); });
dlg_btns->GetCANCEL()->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { dlg_btns->GetCANCEL()->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) {
EndModal(wxID_CANCEL); EndModal(wxID_CANCEL);
}); });
@@ -2024,13 +2024,13 @@ wxWindow *CreatePrinterPresetDialog::create_page1_dialog_buttons(wxWindow *paren
{ {
auto dlg_btns = new DialogButtons(parent, {"OK", "Cancel"}); auto dlg_btns = new DialogButtons(parent, {"OK", "Cancel"});
dlg_btns->GetOK()->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { dlg_btns->GetOK()->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) {
if (!validate_input_valid()) return; if (!validate_input_valid()) return;
data_init(); data_init();
show_page2(); show_page2();
}); });
dlg_btns->GetCANCEL()->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { EndModal(wxID_CANCEL); }); dlg_btns->GetCANCEL()->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) { EndModal(wxID_CANCEL); });
return dlg_btns; return dlg_btns;
} }
@@ -2577,13 +2577,13 @@ wxBoxSizer *CreatePrinterPresetDialog::create_presets_template_item(wxWindow *pa
wxWindow *CreatePrinterPresetDialog::create_page2_dialog_buttons(wxWindow *parent) wxWindow *CreatePrinterPresetDialog::create_page2_dialog_buttons(wxWindow *parent)
{ {
auto dlg_btns = new DialogButtons(parent, {"Back", "OK", "Cancel"}); auto dlg_btns = new DialogButtons(parent, {"Return", "OK", "Cancel"});
dlg_btns->GetBACK()->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { show_page1(); }); dlg_btns->GetRETURN()->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) { show_page1(); });
auto btn_ok = dlg_btns->GetOK(); auto btn_ok = dlg_btns->GetOK();
btn_ok->SetLabel(_L("Create")); btn_ok->SetLabel(_L("Create"));
btn_ok->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { btn_ok->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) {
PresetBundle *preset_bundle = wxGetApp().preset_bundle; PresetBundle *preset_bundle = wxGetApp().preset_bundle;
const wxString curr_selected_printer_type = curr_create_printer_type(); const wxString curr_selected_printer_type = curr_create_printer_type();
@@ -2828,7 +2828,7 @@ wxWindow *CreatePrinterPresetDialog::create_page2_dialog_buttons(wxWindow *paren
}); });
dlg_btns->GetCANCEL()->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { EndModal(wxID_CANCEL); }); dlg_btns->GetCANCEL()->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) { EndModal(wxID_CANCEL); });
return dlg_btns; return dlg_btns;
} }
@@ -3277,7 +3277,7 @@ CreatePresetSuccessfulDialog::CreatePresetSuccessfulDialog(wxWindow *parent, con
else if (create_success_type == FILAMENT && sync_user_preset_need_enabled) else if (create_success_type == FILAMENT && sync_user_preset_need_enabled)
dlg_btns->GetOK()->SetLabel(_L("Sync user presets")); dlg_btns->GetOK()->SetLabel(_L("Sync user presets"));
dlg_btns->GetOK()->Bind(wxEVT_LEFT_DOWN, [this, sync_user_preset_need_enabled](wxMouseEvent &e) { dlg_btns->GetOK()->Bind(wxEVT_BUTTON, [this, sync_user_preset_need_enabled](wxCommandEvent &e) {
if (sync_user_preset_need_enabled) { if (sync_user_preset_need_enabled) {
wxGetApp().app_config->set("sync_user_preset", "true"); wxGetApp().app_config->set("sync_user_preset", "true");
wxGetApp().start_sync_user_preset(); wxGetApp().start_sync_user_preset();
@@ -3286,7 +3286,7 @@ CreatePresetSuccessfulDialog::CreatePresetSuccessfulDialog(wxWindow *parent, con
}); });
if (is_cancel_needed) if (is_cancel_needed)
dlg_btns->GetCANCEL()->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { EndModal(wxID_CANCEL); }); dlg_btns->GetCANCEL()->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) { EndModal(wxID_CANCEL); });
m_main_sizer->Add(dlg_btns, 0, wxEXPAND); m_main_sizer->Add(dlg_btns, 0, wxEXPAND);
@@ -4028,7 +4028,7 @@ ExportConfigsDialog::ExportCase ExportConfigsDialog::archive_process_preset_to_f
wxWindow *ExportConfigsDialog::create_dialog_buttons(wxWindow* parent) wxWindow *ExportConfigsDialog::create_dialog_buttons(wxWindow* parent)
{ {
auto dlg_btns = new DialogButtons(parent, {"OK", "Cancel"}); auto dlg_btns = new DialogButtons(parent, {"OK", "Cancel"});
dlg_btns->GetOK()->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { dlg_btns->GetOK()->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) {
if (!has_check_box_selected()) { if (!has_check_box_selected()) {
MessageDialog dlg(this, _L("Please select at least one printer or filament."), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), MessageDialog dlg(this, _L("Please select at least one printer or filament."), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"),
wxYES | wxYES_DEFAULT | wxCENTRE); wxYES | wxYES_DEFAULT | wxCENTRE);
@@ -4065,7 +4065,7 @@ wxWindow *ExportConfigsDialog::create_dialog_buttons(wxWindow* parent)
EndModal(wxID_OK); EndModal(wxID_OK);
}); });
dlg_btns->GetCANCEL()->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { EndModal(wxID_CANCEL); }); dlg_btns->GetCANCEL()->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) { EndModal(wxID_CANCEL); });
return dlg_btns; return dlg_btns;
} }
@@ -4598,7 +4598,7 @@ wxWindow *EditFilamentPresetDialog::create_dialog_buttons()
e.Skip(); e.Skip();
})); }));
dlg_btns->GetOK()->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { EndModal(wxID_OK); }); dlg_btns->GetOK()->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) { EndModal(wxID_OK); });
return dlg_btns; return dlg_btns;
} }

View File

@@ -1,5 +1,6 @@
#include "PlateSettingsDialog.hpp" #include "PlateSettingsDialog.hpp"
#include "MsgDialog.hpp" #include "MsgDialog.hpp"
#include "Widgets/DialogButtons.hpp"
namespace Slic3r { namespace GUI { namespace Slic3r { namespace GUI {
static constexpr int MIN_LAYER_VALUE = 2; static constexpr int MIN_LAYER_VALUE = 2;
@@ -458,23 +459,9 @@ PlateSettingsDialog::PlateSettingsDialog(wxWindow* parent, const wxString& title
m_sizer_main->AddSpacer(FromDIP(5)); m_sizer_main->AddSpacer(FromDIP(5));
m_sizer_main->Add(m_other_layers_seq_panel, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(30)); m_sizer_main->Add(m_other_layers_seq_panel, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(30));
auto dlg_btns = new DialogButtons(this, {"OK", "Cancel"});
auto sizer_button = new wxBoxSizer(wxHORIZONTAL); dlg_btns->GetOK()->Bind(wxEVT_BUTTON, [this](auto& e) {
StateColor btn_bg_green(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 btn_bg_white(std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Pressed), std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Hovered),
std::pair<wxColour, int>(*wxWHITE, StateColor::Normal));
m_button_ok = new Button(this, _L("OK"));
m_button_ok->SetBackgroundColor(btn_bg_green);
m_button_ok->SetBorderColor(*wxWHITE);
m_button_ok->SetTextColor(wxColour("#FFFFFE"));
m_button_ok->SetFont(Label::Body_12);
m_button_ok->SetSize(wxSize(FromDIP(58), FromDIP(24)));
m_button_ok->SetMinSize(wxSize(FromDIP(58), FromDIP(24)));
m_button_ok->SetCornerRadius(FromDIP(12));
m_button_ok->Bind(wxEVT_BUTTON, [this](auto& e) {
wxCommandEvent evt(EVT_SET_BED_TYPE_CONFIRM, GetId()); wxCommandEvent evt(EVT_SET_BED_TYPE_CONFIRM, GetId());
static_cast<wxEvtHandler*>(m_other_layers_seq_panel)->ProcessEvent(evt); static_cast<wxEvtHandler*>(m_other_layers_seq_panel)->ProcessEvent(evt);
GetEventHandler()->ProcessEvent(evt); GetEventHandler()->ProcessEvent(evt);
@@ -486,26 +473,15 @@ PlateSettingsDialog::PlateSettingsDialog(wxWindow* parent, const wxString& title
this->Close(); this->Close();
}); });
m_button_cancel = new Button(this, _L("Cancel")); dlg_btns->GetCANCEL()->Bind(wxEVT_BUTTON, [this](auto& e) {
m_button_cancel->SetBackgroundColor(btn_bg_white);
m_button_cancel->SetBorderColor(wxColour(38, 46, 48));
m_button_cancel->SetFont(Label::Body_12);
m_button_cancel->SetSize(wxSize(FromDIP(58), FromDIP(24)));
m_button_cancel->SetMinSize(wxSize(FromDIP(58), FromDIP(24)));
m_button_cancel->SetCornerRadius(FromDIP(12));
m_button_cancel->Bind(wxEVT_BUTTON, [this](auto& e) {
if (this->IsModal()) if (this->IsModal())
EndModal(wxID_NO); EndModal(wxID_NO);
else else
this->Close(); this->Close();
}); });
sizer_button->AddStretchSpacer(); m_sizer_main->AddSpacer(FromDIP(20));
sizer_button->Add(m_button_ok, 0, wxALL, FromDIP(5)); m_sizer_main->Add(dlg_btns, 0, wxEXPAND);
sizer_button->Add(m_button_cancel, 0, wxALL, FromDIP(5));
sizer_button->Add(FromDIP(30),0, 0, 0);
m_sizer_main->Add(sizer_button, 0, wxEXPAND | wxTOP | wxBOTTOM, FromDIP(20));
SetSizer(m_sizer_main); SetSizer(m_sizer_main);
Layout(); Layout();
@@ -620,8 +596,6 @@ wxString PlateSettingsDialog::to_print_sequence_name(PrintSequence print_seq) {
void PlateSettingsDialog::on_dpi_changed(const wxRect& suggested_rect) void PlateSettingsDialog::on_dpi_changed(const wxRect& suggested_rect)
{ {
m_button_ok->Rescale();
m_button_cancel->Rescale();
} }
wxString PlateSettingsDialog::get_plate_name() const { wxString PlateSettingsDialog::get_plate_name() const {
@@ -670,48 +644,23 @@ PlateNameEditDialog::PlateNameEditDialog(wxWindow *parent, wxWindowID id, const
m_sizer_main->Add(top_sizer, 0, wxEXPAND | wxALL, FromDIP(30)); m_sizer_main->Add(top_sizer, 0, wxEXPAND | wxALL, FromDIP(30));
auto sizer_button = new wxBoxSizer(wxHORIZONTAL); auto dlg_btns = new DialogButtons(this, {"OK", "Cancel"});
StateColor btn_bg_green(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 btn_bg_white(std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Pressed), std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Hovered), dlg_btns->GetOK()->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) {
std::pair<wxColour, int>(*wxWHITE, StateColor::Normal));
m_button_ok = new Button(this, _L("OK"));
m_button_ok->SetBackgroundColor(btn_bg_green);
m_button_ok->SetBorderColor(*wxWHITE);
m_button_ok->SetTextColor(wxColour("#FFFFFE"));
m_button_ok->SetFont(Label::Body_12);
m_button_ok->SetSize(wxSize(FromDIP(58), FromDIP(24)));
m_button_ok->SetMinSize(wxSize(FromDIP(58), FromDIP(24)));
m_button_ok->SetCornerRadius(FromDIP(12));
m_button_ok->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) {
if (this->IsModal()) if (this->IsModal())
EndModal(wxID_YES); EndModal(wxID_YES);
else else
this->Close(); this->Close();
}); });
m_button_cancel = new Button(this, _L("Cancel")); dlg_btns->GetCANCEL()->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) {
m_button_cancel->SetBackgroundColor(btn_bg_white);
m_button_cancel->SetBorderColor(wxColour(38, 46, 48));
m_button_cancel->SetFont(Label::Body_12);
m_button_cancel->SetSize(wxSize(FromDIP(58), FromDIP(24)));
m_button_cancel->SetMinSize(wxSize(FromDIP(58), FromDIP(24)));
m_button_cancel->SetCornerRadius(FromDIP(12));
m_button_cancel->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) {
if (this->IsModal()) if (this->IsModal())
EndModal(wxID_NO); EndModal(wxID_NO);
else else
this->Close(); this->Close();
}); });
sizer_button->AddStretchSpacer(); m_sizer_main->Add(dlg_btns, 0, wxEXPAND, FromDIP(20));
sizer_button->Add(m_button_ok, 0, wxALL, FromDIP(5));
sizer_button->Add(m_button_cancel, 0, wxALL, FromDIP(5));
sizer_button->Add(FromDIP(30), 0, 0, 0);
m_sizer_main->Add(sizer_button, 0, wxEXPAND, FromDIP(20));
SetSizer(m_sizer_main); SetSizer(m_sizer_main);
Layout(); Layout();
@@ -726,8 +675,6 @@ PlateNameEditDialog::~PlateNameEditDialog() {}
void PlateNameEditDialog::on_dpi_changed(const wxRect &suggested_rect) void PlateNameEditDialog::on_dpi_changed(const wxRect &suggested_rect)
{ {
m_button_ok->Rescale();
m_button_cancel->Rescale();
} }

View File

@@ -172,8 +172,6 @@ protected:
ComboBox* m_spiral_mode_choice { nullptr }; ComboBox* m_spiral_mode_choice { nullptr };
DragCanvas* m_drag_canvas; DragCanvas* m_drag_canvas;
OtherLayersSeqPanel* m_other_layers_seq_panel; OtherLayersSeqPanel* m_other_layers_seq_panel;
Button* m_button_ok;
Button* m_button_cancel;
TextInput *m_ti_plate_name; TextInput *m_ti_plate_name;
}; };
@@ -195,8 +193,6 @@ public:
void set_plate_name(const wxString &name); void set_plate_name(const wxString &name);
protected: protected:
Button * m_button_ok;
Button * m_button_cancel;
TextInput *m_ti_plate_name; TextInput *m_ti_plate_name;
}; };
}} // namespace Slic3r::GUI }} // namespace Slic3r::GUI

View File

@@ -10754,7 +10754,6 @@ public:
WX_DECLARE_LIST(RadioSelector, RadioSelectorList); WX_DECLARE_LIST(RadioSelector, RadioSelectorList);
#define PROJECT_DROP_DIALOG_SELECT_PLANE_SIZE wxSize(FromDIP(350), FromDIP(120)) #define PROJECT_DROP_DIALOG_SELECT_PLANE_SIZE wxSize(FromDIP(350), FromDIP(120))
#define PROJECT_DROP_DIALOG_BUTTON_SIZE wxSize(FromDIP(60), FromDIP(24))
class ProjectDropDialog : public DPIDialog class ProjectDropDialog : public DPIDialog
{ {
@@ -10772,14 +10771,11 @@ public:
wxStaticText *m_fname_f; wxStaticText *m_fname_f;
wxStaticText *m_fname_s; wxStaticText *m_fname_s;
StaticBox * m_panel_select; StaticBox * m_panel_select;
Button * m_confirm;
Button * m_cancel;
void select_radio(int index); void select_radio(int index);
void on_select_radio(wxMouseEvent &event); void on_select_radio(wxMouseEvent &event);
void on_select_ok(wxMouseEvent &event); void on_select_ok(wxCommandEvent &event);
void on_select_cancel(wxMouseEvent &event); void on_select_cancel(wxCommandEvent &event);
int get_select_radio(int groupid); int get_select_radio(int groupid);
int get_action() const { return m_action; } int get_action() const { return m_action; }
@@ -10878,7 +10874,7 @@ ProjectDropDialog::ProjectDropDialog(const std::string &filename)
m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, 10); m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, 10);
wxBoxSizer *m_sizer_bottom = new wxBoxSizer(wxHORIZONTAL); // wxBoxSizer *m_sizer_bottom = new wxBoxSizer(wxHORIZONTAL);
// Orca: hide the "Don't show again" checkbox, people keeps accidentally checked this then forgot // Orca: hide the "Don't show again" checkbox, people keeps accidentally checked this then forgot
// wxBoxSizer *m_sizer_left = new wxBoxSizer(wxHORIZONTAL); // wxBoxSizer *m_sizer_left = new wxBoxSizer(wxHORIZONTAL);
// //
@@ -10886,34 +10882,14 @@ ProjectDropDialog::ProjectDropDialog(const std::string &filename)
// m_sizer_left->Add(dont_show_again, 0, wxALL, 5); // m_sizer_left->Add(dont_show_again, 0, wxALL, 5);
// //
// m_sizer_bottom->Add(m_sizer_left, 0, wxEXPAND, 5); // m_sizer_bottom->Add(m_sizer_left, 0, wxEXPAND, 5);
m_sizer_bottom->Add(0, 0, 1, wxEXPAND, 5);
wxBoxSizer *m_sizer_right = new wxBoxSizer(wxHORIZONTAL); auto dlg_btns = new DialogButtons(this, {"OK", "Cancel"});
m_confirm = new Button(this, _L("OK")); dlg_btns->GetOK()->Bind(wxEVT_BUTTON, &ProjectDropDialog::on_select_ok, this);
StateColor btn_bg_green(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));
m_confirm->SetBackgroundColor(btn_bg_green); dlg_btns->GetCANCEL()->Bind(wxEVT_BUTTON, &ProjectDropDialog::on_select_cancel, this);
m_confirm->SetBorderColor(wxColour(0, 150, 136));
m_confirm->SetTextColor(wxColour("#FFFFFE"));
m_confirm->SetSize(PROJECT_DROP_DIALOG_BUTTON_SIZE);
m_confirm->SetMinSize(PROJECT_DROP_DIALOG_BUTTON_SIZE);
m_confirm->SetCornerRadius(FromDIP(12));
m_confirm->Bind(wxEVT_LEFT_DOWN, &ProjectDropDialog::on_select_ok, this);
m_sizer_right->Add(m_confirm, 0, wxALL, 5);
m_cancel = new Button(this, _L("Cancel")); m_sizer_main->Add(dlg_btns, 0, wxEXPAND);
m_cancel->SetTextColor(wxColour(107, 107, 107));
m_cancel->SetSize(PROJECT_DROP_DIALOG_BUTTON_SIZE);
m_cancel->SetMinSize(PROJECT_DROP_DIALOG_BUTTON_SIZE);
m_cancel->SetCornerRadius(FromDIP(12));
m_cancel->Bind(wxEVT_LEFT_DOWN, &ProjectDropDialog::on_select_cancel, this);
m_sizer_right->Add(m_cancel, 0, wxALL, 5);
m_sizer_bottom->Add( m_sizer_right, 0, wxEXPAND, 5 );
m_sizer_main->Add(m_sizer_bottom, 0, wxEXPAND | wxLEFT | wxRIGHT, 40);
m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, 20);
SetSizer(m_sizer_main); SetSizer(m_sizer_main);
Layout(); Layout();
@@ -11057,7 +11033,7 @@ void ProjectDropDialog::on_select_radio(wxMouseEvent &event)
} }
} }
void ProjectDropDialog::on_select_ok(wxMouseEvent &event) void ProjectDropDialog::on_select_ok(wxCommandEvent &event)
{ {
if (m_remember_choice) { if (m_remember_choice) {
LoadType load_type = static_cast<LoadType>(get_action()); LoadType load_type = static_cast<LoadType>(get_action());
@@ -11075,15 +11051,13 @@ void ProjectDropDialog::on_select_ok(wxMouseEvent &event)
EndModal(wxID_OK); EndModal(wxID_OK);
} }
void ProjectDropDialog::on_select_cancel(wxMouseEvent &event) void ProjectDropDialog::on_select_cancel(wxCommandEvent &event)
{ {
EndModal(wxID_CANCEL); EndModal(wxID_CANCEL);
} }
void ProjectDropDialog::on_dpi_changed(const wxRect& suggested_rect) void ProjectDropDialog::on_dpi_changed(const wxRect& suggested_rect)
{ {
m_confirm->SetMinSize(PROJECT_DROP_DIALOG_BUTTON_SIZE);
m_cancel->SetMinSize(PROJECT_DROP_DIALOG_BUTTON_SIZE);
Fit(); Fit();
Refresh(); Refresh();
} }

View File

@@ -19,6 +19,8 @@
#include "format.hpp" #include "format.hpp"
#include "Tab.hpp" #include "Tab.hpp"
#include "Widgets/DialogButtons.hpp"
using Slic3r::GUI::format_wxstr; using Slic3r::GUI::format_wxstr;
namespace Slic3r { namespace GUI { namespace Slic3r { namespace GUI {
@@ -334,42 +336,14 @@ void SavePresetDialog::build(std::vector<Preset::Type> types, std::string suffix
// Add first item // Add first item
for (Preset::Type type : types) AddItem(type, suffix); for (Preset::Type type : types) AddItem(type, suffix);
wxBoxSizer *btns; auto dlg_btns = new DialogButtons(this, {"OK", "Cancel"});
btns = new wxBoxSizer(wxHORIZONTAL);
btns->Add(0, 0, 1, wxEXPAND, 5);
m_confirm = new Button(this, _L("OK")); dlg_btns->GetOK()->Bind(wxEVT_BUTTON, &SavePresetDialog::accept, this);
StateColor btn_bg_green(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));
m_confirm->SetBackgroundColor(btn_bg_green);
m_confirm->SetBorderColor(wxColour(0, 150, 136));
m_confirm->SetTextColor(wxColour("#FFFFFE"));
m_confirm->SetMinSize(SAVE_PRESET_DIALOG_BUTTON_SIZE);
m_confirm->SetCornerRadius(FromDIP(12));
m_confirm->Bind(wxEVT_BUTTON, &SavePresetDialog::accept, this);
btns->Add(m_confirm, 0, wxEXPAND, 0);
auto block_middle = new wxWindow(this, -1); dlg_btns->GetCANCEL()->Bind(wxEVT_BUTTON, &SavePresetDialog::on_select_cancel, this);
block_middle->SetBackgroundColour(SAVE_PRESET_DIALOG_DEF_COLOUR);
btns->Add(block_middle, 0, wxRIGHT, 10);
m_cancel = new Button(this, _L("Cancel"));
m_cancel->SetMinSize(SAVE_PRESET_DIALOG_BUTTON_SIZE);
m_cancel->SetCornerRadius(FromDIP(12));
m_cancel->Bind(wxEVT_BUTTON, &SavePresetDialog::on_select_cancel, this);
btns->Add(m_cancel, 0, wxEXPAND, 0);
auto block_right = new wxWindow(this, -1);
block_right->SetBackgroundColour(SAVE_PRESET_DIALOG_DEF_COLOUR);
btns->Add(block_right, 0, wxRIGHT, 40);
auto m_line = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1), wxTAB_TRAVERSAL);
m_line->SetBackgroundColour(wxColour(166, 169, 170));
m_Sizer_main->Add( m_line, 0, wxEXPAND, 0 );
m_Sizer_main->Add(m_presets_sizer, 0, wxEXPAND | wxALL, BORDER_W); m_Sizer_main->Add(m_presets_sizer, 0, wxEXPAND | wxALL, BORDER_W);
m_Sizer_main->Add(btns, 0, wxEXPAND | wxBOTTOM, BORDER_W + 7); m_Sizer_main->Add(dlg_btns, 0, wxEXPAND);
SetSizer(m_Sizer_main); SetSizer(m_Sizer_main);
m_Sizer_main->SetSizeHints(this); m_Sizer_main->SetSizeHints(this);
@@ -491,17 +465,11 @@ void SavePresetDialog::on_dpi_changed(const wxRect &suggested_rect)
{ {
const int &em = em_unit(); const int &em = em_unit();
msw_buttons_rescale(this, em, {wxID_OK, wxID_CANCEL});
//for (Item *item : m_items) item->update_valid_bmp(); //for (Item *item : m_items) item->update_valid_bmp();
// const wxSize& size = wxSize(45 * em, 35 * em); // const wxSize& size = wxSize(45 * em, 35 * em);
//SetMinSize(/*size*/ wxSize(100, 50)); //SetMinSize(/*size*/ wxSize(100, 50));
m_confirm->SetMinSize(SAVE_PRESET_DIALOG_BUTTON_SIZE);
m_cancel->SetMinSize(SAVE_PRESET_DIALOG_BUTTON_SIZE);
Fit(); Fit();
Refresh(); Refresh();
} }

View File

@@ -78,8 +78,6 @@ class SavePresetDialog : public DPIDialog
std::vector<Item*> m_items; std::vector<Item*> m_items;
Button* m_confirm {nullptr};
Button* m_cancel {nullptr};
wxBoxSizer* m_presets_sizer {nullptr}; wxBoxSizer* m_presets_sizer {nullptr};
wxStaticText* m_label {nullptr}; wxStaticText* m_label {nullptr};
wxBoxSizer* m_radio_sizer {nullptr}; wxBoxSizer* m_radio_sizer {nullptr};

View File

@@ -3,6 +3,8 @@
#include "GUI_App.hpp" #include "GUI_App.hpp"
#include "MainFrame.hpp" #include "MainFrame.hpp"
#include "Widgets/DialogButtons.hpp"
namespace Slic3r { namespace GUI { namespace Slic3r { namespace GUI {
SingleChoiceDialog::SingleChoiceDialog(const wxString &message, const wxString &caption, const wxArrayString &choices, int initialSelection, wxWindow *parent) SingleChoiceDialog::SingleChoiceDialog(const wxString &message, const wxString &caption, const wxArrayString &choices, int initialSelection, wxWindow *parent)
@@ -21,41 +23,16 @@ SingleChoiceDialog::SingleChoiceDialog(const wxString &message, const wxString &
type_comboBox = new ComboBox(this, wxID_ANY, choices[0], wxDefaultPosition, wxSize(FromDIP(dlg_width - 10), -1), 0, NULL, wxCB_READONLY); type_comboBox = new ComboBox(this, wxID_ANY, choices[0], wxDefaultPosition, wxSize(FromDIP(dlg_width - 10), -1), 0, NULL, wxCB_READONLY);
for (const wxString &type_name : choices) { type_comboBox->Append(type_name); } for (const wxString &type_name : choices) { type_comboBox->Append(type_name); }
bSizer->Add(type_comboBox, 0, wxALL | wxALIGN_CENTER, 5); bSizer->Add(type_comboBox, 0, wxALL | wxALIGN_CENTER, 5);
bSizer->Add(0, 0, 1, wxEXPAND, FromDIP(type_comboBox->GetClientSize().GetHeight())); bSizer->AddSpacer(FromDIP(10));
type_comboBox->SetSelection(initialSelection); type_comboBox->SetSelection(initialSelection);
wxBoxSizer *bSizer_button = new wxBoxSizer(wxHORIZONTAL); auto dlg_btns = new DialogButtons(this, {"OK", "Cancel"});
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(0, 137, 123), StateColor::Pressed), std::pair<wxColour, int>(wxColour(38, 166, 154), StateColor::Hovered), dlg_btns->GetOK()->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) { EndModal(wxID_OK); });
std::pair<wxColour, int>(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal));
m_button_ok = new Button(this, _L("OK")); dlg_btns->GetCANCEL()->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) { EndModal(wxID_CANCEL); });
m_button_ok->SetBackgroundColor(btn_bg_green);
m_button_ok->SetBorderColor(*wxWHITE);
m_button_ok->SetTextColor(wxColour(0xFFFFFE));
m_button_ok->SetFont(Label::Body_12);
m_button_ok->SetSize(wxSize(FromDIP(58), FromDIP(24)));
m_button_ok->SetMinSize(wxSize(FromDIP(58), FromDIP(24)));
m_button_ok->SetCornerRadius(FromDIP(12));
bSizer_button->Add(m_button_ok, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, FromDIP(int(dlg_width - 58 * 2) / 6));
m_button_ok->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { EndModal(wxID_OK); }); bSizer->Add(dlg_btns, 0, wxEXPAND);
StateColor btn_bg_white(std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Pressed), std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Hovered),
std::pair<wxColour, int>(*wxWHITE, StateColor::Normal));
m_button_cancel = new Button(this, _L("Cancel"));
m_button_cancel->SetBackgroundColor(btn_bg_white);
m_button_cancel->SetBorderColor(wxColour(38, 46, 48));
m_button_cancel->SetFont(Label::Body_12);
m_button_cancel->SetSize(wxSize(FromDIP(58), FromDIP(24)));
m_button_cancel->SetMinSize(wxSize(FromDIP(58), FromDIP(24)));
m_button_cancel->SetCornerRadius(FromDIP(12));
bSizer_button->Add(m_button_cancel, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, FromDIP(int(dlg_width - 58 * 2) / 6));
m_button_cancel->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { EndModal(wxID_CANCEL); });
bSizer->Add(bSizer_button, 1, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, FromDIP(5));
this->SetSizer(bSizer); this->SetSizer(bSizer);
this->Layout(); this->Layout();

View File

@@ -20,8 +20,6 @@ public:
protected: protected:
ComboBox *type_comboBox = nullptr; ComboBox *type_comboBox = nullptr;
Button * m_button_ok = nullptr;
Button * m_button_cancel = nullptr;
}; };
}} // namespace Slic3r::GUI }} // namespace Slic3r::GUI

View File

@@ -10,6 +10,7 @@
#include "MainFrame.hpp" #include "MainFrame.hpp"
#include "Widgets/Button.hpp" #include "Widgets/Button.hpp"
#include "Widgets/TextInput.hpp" #include "Widgets/TextInput.hpp"
#include "Widgets/DialogButtons.hpp"
#include <chrono> #include <chrono>
using namespace Slic3r; using namespace Slic3r;
@@ -262,21 +263,14 @@ StepMeshDialog::StepMeshDialog(wxWindow* parent, Slic3r::Step& file, double line
bSizer_button->SetMinSize(wxSize(FromDIP(100), -1)); bSizer_button->SetMinSize(wxSize(FromDIP(100), -1));
m_checkbox = new wxCheckBox(this, wxID_ANY, _L("Don't show again"), wxDefaultPosition, wxDefaultSize, 0); m_checkbox = new wxCheckBox(this, wxID_ANY, _L("Don't show again"), wxDefaultPosition, wxDefaultSize, 0);
m_checkbox->SetForegroundColour(StateColor::darkModeColorFor(FONT_COLOR)); m_checkbox->SetForegroundColour(StateColor::darkModeColorFor(FONT_COLOR));
bSizer_button->Add(m_checkbox, 0, wxALIGN_LEFT); bSizer_button->Add(m_checkbox, 0, wxALIGN_LEFT | wxLEFT | wxALIGN_CENTER_VERTICAL, LEFT_RIGHT_PADING);
bSizer_button->AddStretchSpacer(1); bSizer_button->AddStretchSpacer(1);
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed), std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered),
std::pair<wxColour, int>(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal));
m_button_ok = new Button(this, _L("OK"));
m_button_ok->SetBackgroundColor(btn_bg_green);
m_button_ok->SetBorderColor(*wxWHITE);
m_button_ok->SetTextColor(wxColour(0xFFFFFE));
m_button_ok->SetFont(Label::Body_12);
m_button_ok->SetSize(BUTTON_SIZE);
m_button_ok->SetMinSize(BUTTON_SIZE);
m_button_ok->SetCornerRadius(FromDIP(12));
bSizer_button->Add(m_button_ok, 0, wxALIGN_RIGHT, BUTTON_BORDER);
m_button_ok->Bind(wxEVT_LEFT_DOWN, [this, angle_input, linear_input](wxMouseEvent& e) { auto dlg_btns = new DialogButtons(this, {"OK", "Cancel"});
bSizer_button->Add(dlg_btns, 0, wxEXPAND);
dlg_btns->GetOK()->Bind(wxEVT_BUTTON, [this, angle_input, linear_input](wxCommandEvent& e) {
stop_task(); stop_task();
if (validate_number_range(angle_input->GetTextCtrl()->GetValue(), 0.01, 1) && if (validate_number_range(angle_input->GetTextCtrl()->GetValue(), 0.01, 1) &&
validate_number_range(linear_input->GetTextCtrl()->GetValue(), 0.001, 0.1)) { validate_number_range(linear_input->GetTextCtrl()->GetValue(), 0.001, 0.1)) {
@@ -292,24 +286,12 @@ StepMeshDialog::StepMeshDialog(wxWindow* parent, Slic3r::Step& file, double line
SetFocusIgnoringChildren(); SetFocusIgnoringChildren();
}); });
StateColor btn_bg_white(std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Pressed), std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Hovered), dlg_btns->GetCANCEL()->Bind(wxEVT_BUTTON, [this](wxCommandEvent& e) {
std::pair<wxColour, int>(*wxWHITE, StateColor::Normal));
m_button_cancel = new Button(this, _L("Cancel"));
m_button_cancel->SetBackgroundColor(btn_bg_white);
m_button_cancel->SetBorderColor(wxColour(38, 46, 48));
m_button_cancel->SetFont(Label::Body_12);
m_button_cancel->SetSize(BUTTON_SIZE);
m_button_cancel->SetMinSize(BUTTON_SIZE);
m_button_cancel->SetCornerRadius(FromDIP(12));
bSizer_button->Add(m_button_cancel, 0, wxALIGN_RIGHT | wxLEFT, BUTTON_BORDER);
m_button_cancel->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
stop_task(); stop_task();
EndModal(wxID_CANCEL); EndModal(wxID_CANCEL);
}); });
bSizer->Add(bSizer_button, 1, wxEXPAND | wxALL, LEFT_RIGHT_PADING); bSizer->Add(bSizer_button, 1, wxEXPAND);
this->SetSizer(bSizer); this->SetSizer(bSizer);
update_mesh_number_text(); update_mesh_number_text();

View File

@@ -35,8 +35,6 @@ public:
} }
private: private:
Slic3r::Step& m_file; Slic3r::Step& m_file;
Button* m_button_ok = nullptr;
Button* m_button_cancel = nullptr;
wxCheckBox* m_checkbox = nullptr; wxCheckBox* m_checkbox = nullptr;
wxCheckBox* m_split_compound_checkbox = nullptr; wxCheckBox* m_split_compound_checkbox = nullptr;
wxString m_linear_last; wxString m_linear_last;

View File

@@ -24,6 +24,7 @@
#include "PresetComboBoxes.hpp" #include "PresetComboBoxes.hpp"
#include "Widgets/RoundedRectangle.hpp" #include "Widgets/RoundedRectangle.hpp"
#include "Widgets/CheckBox.hpp" #include "Widgets/CheckBox.hpp"
#include "Widgets/DialogButtons.hpp"
using boost::optional; using boost::optional;
@@ -1931,11 +1932,6 @@ std::array<Preset::Type, 3> DiffPresetDialog::types_list() const
void DiffPresetDialog::create_buttons() void DiffPresetDialog::create_buttons()
{ {
wxFont font = this->GetFont().Scaled(1.4f);
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(206, 206, 206), 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>(wxColour(0, 150, 136), StateColor::Normal));
m_buttons = new wxBoxSizer(wxHORIZONTAL); m_buttons = new wxBoxSizer(wxHORIZONTAL);
auto show_in_bottom_info = [this](const wxString& ext_line, wxEvent* e = nullptr) { auto show_in_bottom_info = [this](const wxString& ext_line, wxEvent* e = nullptr) {
@@ -1945,15 +1941,12 @@ void DiffPresetDialog::create_buttons()
if (e) e->Skip(); if (e) e->Skip();
}; };
// Transfer auto dlg_btns = new DialogButtons(this, {"OK", "Cancel"});
m_transfer_btn = new Button(this, L("Transfer"));
m_transfer_btn->SetBackgroundColor(btn_bg_green);
m_transfer_btn->SetBorderColor(wxColour(0, 150, 136));
m_transfer_btn->SetTextColor(wxColour("#FFFFFE"));
m_transfer_btn->SetMinSize(wxSize(-1, -1));
m_transfer_btn->SetCornerRadius(FromDIP(12));
m_transfer_btn->Bind(wxEVT_BUTTON, [this](wxEvent&) { button_event(Action::Transfer);}); // Transfer
auto transfer_btn = dlg_btns->GetOK();
transfer_btn->SetLabel(L("Transfer"));
transfer_btn->Bind(wxEVT_BUTTON, [this](wxEvent&) { button_event(Action::Transfer);});
auto enable_transfer = [this](const Preset::Type& type) { auto enable_transfer = [this](const Preset::Type& type) {
@@ -1962,7 +1955,7 @@ void DiffPresetDialog::create_buttons()
return main_edited_preset.name == get_right_preset_name(type); return main_edited_preset.name == get_right_preset_name(type);
return true; return true;
}; };
m_transfer_btn->Bind(wxEVT_UPDATE_UI, [this, enable_transfer, show_in_bottom_info](wxUpdateUIEvent& evt) { transfer_btn->Bind(wxEVT_UPDATE_UI, [this, enable_transfer, show_in_bottom_info, transfer_btn](wxUpdateUIEvent& evt) {
bool enable = m_tree->has_selection(); bool enable = m_tree->has_selection();
if (enable) { if (enable) {
if (m_view_type == Preset::TYPE_INVALID) { if (m_view_type == Preset::TYPE_INVALID) {
@@ -1975,30 +1968,26 @@ void DiffPresetDialog::create_buttons()
else else
enable = enable_transfer(m_view_type); enable = enable_transfer(m_view_type);
if (!enable && m_transfer_btn->IsShown()) { if (!enable && transfer_btn->IsShown()) {
show_in_bottom_info(_L("You can only transfer to current active profile because it has been modified.")); show_in_bottom_info(_L("You can only transfer to current active profile because it has been modified."));
} }
} }
evt.Enable(enable); evt.Enable(enable);
}); });
m_transfer_btn->Bind(wxEVT_ENTER_WINDOW, [show_in_bottom_info](wxMouseEvent& e) { transfer_btn->Bind(wxEVT_ENTER_WINDOW, [show_in_bottom_info](wxMouseEvent& e) {
show_in_bottom_info(_L("Transfer the selected options from left preset to the right.\n" show_in_bottom_info(_L("Transfer the selected options from left preset to the right.\n"
"Note: New modified presets will be selected in settings tabs after close this dialog."), &e); }); "Note: New modified presets will be selected in settings tabs after close this dialog."), &e); });
// Cancel // Cancel
m_cancel_btn = new Button(this, L("Cancel")); auto cancel_btn = dlg_btns->GetCANCEL();
m_cancel_btn->SetTextColor(wxColour(107, 107, 107)); cancel_btn->Bind(wxEVT_BUTTON, [this](wxEvent&) { button_event(Action::Discard);});
m_cancel_btn->SetMinSize(wxSize(-1, -1));
m_cancel_btn->SetCornerRadius(FromDIP(12));
m_cancel_btn->Bind(wxEVT_BUTTON, [this](wxEvent&) { button_event(Action::Discard);}); for (Button* btn : { transfer_btn, cancel_btn }) {
for (Button* btn : { m_transfer_btn, m_cancel_btn }) {
btn->Bind(wxEVT_LEAVE_WINDOW, [this](wxMouseEvent& e) { update_bottom_info(); Layout(); e.Skip(); }); btn->Bind(wxEVT_LEAVE_WINDOW, [this](wxMouseEvent& e) { update_bottom_info(); Layout(); e.Skip(); });
m_buttons->Add(btn, 1, wxLEFT, 5);
btn->SetFont(font);
} }
m_buttons->Add(dlg_btns, 1, wxEXPAND);
m_buttons->Show(false); m_buttons->Show(false);
} }
@@ -2024,7 +2013,7 @@ void DiffPresetDialog::create_edit_sizer()
// Create and fill edit sizer // Create and fill edit sizer
m_edit_sizer = new wxBoxSizer(wxHORIZONTAL); m_edit_sizer = new wxBoxSizer(wxHORIZONTAL);
m_edit_sizer->Add(m_use_for_transfer, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 5); m_edit_sizer->Add(m_use_for_transfer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 10);
m_edit_sizer->AddSpacer(em_unit() * 10); m_edit_sizer->AddSpacer(em_unit() * 10);
m_edit_sizer->Add(m_buttons, 1, wxLEFT, 5); m_edit_sizer->Add(m_buttons, 1, wxLEFT, 5);
m_edit_sizer->Show(false); m_edit_sizer->Show(false);
@@ -2040,7 +2029,7 @@ void DiffPresetDialog::complete_dialog_creation()
topSizer->Add(m_show_all_presets, 0, wxEXPAND | wxALL, border); topSizer->Add(m_show_all_presets, 0, wxEXPAND | wxALL, border);
topSizer->Add(m_tree, 1, wxEXPAND | wxALL, border); topSizer->Add(m_tree, 1, wxEXPAND | wxALL, border);
topSizer->Add(m_bottom_info_line, 0, wxEXPAND | wxALL, 2 * border); topSizer->Add(m_bottom_info_line, 0, wxEXPAND | wxALL, 2 * border);
topSizer->Add(m_edit_sizer, 0, wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT, 2 * border); topSizer->Add(m_edit_sizer, 0, wxEXPAND);
this->SetMinSize(wxSize(80 * em_unit(), 30 * em_unit())); this->SetMinSize(wxSize(80 * em_unit(), 30 * em_unit()));
this->SetSizer(topSizer); this->SetSizer(topSizer);
@@ -2278,10 +2267,6 @@ void DiffPresetDialog::on_dpi_changed(const wxRect&)
{ {
int em = em_unit(); int em = em_unit();
msw_buttons_rescale(this, em, {wxID_CANCEL});
for (auto btn : {m_transfer_btn, m_cancel_btn})
if (btn) btn->SetMinSize(UNSAVE_CHANGE_DIALOG_BUTTON_SIZE);
const wxSize& size = wxSize(80 * em, 30 * em); const wxSize& size = wxSize(80 * em, 30 * em);
SetMinSize(size); SetMinSize(size);

View File

@@ -413,8 +413,6 @@ class DiffPresetDialog : public DPIDialog
wxStaticText* m_bottom_info_line { nullptr }; wxStaticText* m_bottom_info_line { nullptr };
wxCheckBox* m_show_all_presets { nullptr }; wxCheckBox* m_show_all_presets { nullptr };
wxCheckBox* m_use_for_transfer { nullptr }; wxCheckBox* m_use_for_transfer { nullptr };
Button* m_transfer_btn { nullptr };
Button* m_cancel_btn { nullptr };
wxBoxSizer* m_buttons { nullptr }; wxBoxSizer* m_buttons { nullptr };
wxBoxSizer* m_edit_sizer { nullptr }; wxBoxSizer* m_edit_sizer { nullptr };

View File

@@ -6,7 +6,7 @@ namespace Slic3r { namespace GUI {
// ORCA standardize dialog buttons // 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)
: wxWindow(parent, wxID_ANY) : wxPanel(parent, wxID_ANY)
{ {
m_parent = parent; m_parent = parent;
m_sizer = new wxBoxSizer(wxHORIZONTAL); m_sizer = new wxBoxSizer(wxHORIZONTAL);
@@ -73,8 +73,8 @@ Button* DialogButtons::GetAPPLY() {return GetButtonFromID(wxID_APPLY) ;}
Button* DialogButtons::GetCONFIRM(){return GetButtonFromID(wxID_APPLY) ;} Button* DialogButtons::GetCONFIRM(){return GetButtonFromID(wxID_APPLY) ;}
Button* DialogButtons::GetNO() {return GetButtonFromID(wxID_NO) ;} Button* DialogButtons::GetNO() {return GetButtonFromID(wxID_NO) ;}
Button* DialogButtons::GetCANCEL() {return GetButtonFromID(wxID_CANCEL) ;} Button* DialogButtons::GetCANCEL() {return GetButtonFromID(wxID_CANCEL) ;}
Button* DialogButtons::GetBACK() {return GetButtonFromID(wxID_BACKWARD);} Button* DialogButtons::GetRETURN() {return GetButtonFromID(wxID_BACKWARD);} // gets Return button
Button* DialogButtons::GetFORWARD(){return GetButtonFromID(wxID_FORWARD) ;} Button* DialogButtons::GetNEXT() {return GetButtonFromID(wxID_FORWARD) ;}
void DialogButtons::SetPrimaryButton(wxString translated_label) { void DialogButtons::SetPrimaryButton(wxString translated_label) {
// use _L("Create") translated text for custom buttons // use _L("Create") translated text for custom buttons
@@ -92,8 +92,12 @@ void DialogButtons::SetPrimaryButton(wxString translated_label) {
m_primary = translated_label; m_primary = translated_label;
// apply focus only if there is no focused element exist. this prevents stealing focus from input boxes
if(m_parent->FindFocus() == nullptr)
btn->SetFocus(); btn->SetFocus();
// we won't need color definations after button style management // we won't need color definations after button style management
bool is_dark = wxGetApp().dark_mode();
StateColor clr_bg = StateColor( StateColor clr_bg = StateColor(
std::pair(wxColour("#009688"), (int)StateColor::NotHovered), std::pair(wxColour("#009688"), (int)StateColor::NotHovered),
std::pair(wxColour("#DFDFDF"), (int)StateColor::Disabled), std::pair(wxColour("#DFDFDF"), (int)StateColor::Disabled),
@@ -105,7 +109,8 @@ void DialogButtons::SetPrimaryButton(wxString translated_label) {
btn->SetBackgroundColor(clr_bg); btn->SetBackgroundColor(clr_bg);
StateColor clr_br = StateColor( StateColor clr_br = StateColor(
std::pair(wxColour("#009688"), (int)StateColor::NotFocused), std::pair(wxColour("#009688"), (int)StateColor::NotFocused),
std::pair(wxColour("#26A69A"), (int)StateColor::Focused) std::pair(wxColour("#DFDFDF"), (int)StateColor::Disabled),
std::pair(wxColour(is_dark ? "#26A69A" : "#00FFD4"), (int)StateColor::Focused)
); );
btn->SetBorderColor(clr_br); btn->SetBorderColor(clr_br);
StateColor clr_tx = StateColor( StateColor clr_tx = StateColor(
@@ -143,6 +148,7 @@ void DialogButtons::SetAlertButton(wxString translated_label) {
btn->SetBackgroundColor(clr_bg); btn->SetBackgroundColor(clr_bg);
StateColor clr_br = StateColor( StateColor clr_br = StateColor(
std::pair(wxColour("#DFDFDF"), (int)StateColor::NotFocused), std::pair(wxColour("#DFDFDF"), (int)StateColor::NotFocused),
std::pair(wxColour("#DFDFDF"), (int)StateColor::Disabled),
std::pair(wxColour("#26A69A"), (int)StateColor::Focused) std::pair(wxColour("#26A69A"), (int)StateColor::Focused)
); );
btn->SetBorderColor(clr_br); btn->SetBorderColor(clr_br);
@@ -171,6 +177,7 @@ void DialogButtons::UpdateButtons() {
); );
StateColor clr_br = StateColor( StateColor clr_br = StateColor(
std::pair(wxColour("#DFDFDF"), (int)StateColor::NotFocused), std::pair(wxColour("#DFDFDF"), (int)StateColor::NotFocused),
std::pair(wxColour("#DFDFDF"), (int)StateColor::Disabled),
std::pair(wxColour("#26A69A"), (int)StateColor::Focused) std::pair(wxColour("#26A69A"), (int)StateColor::Focused)
); );
StateColor clr_tx = StateColor( StateColor clr_tx = StateColor(
@@ -205,6 +212,9 @@ void DialogButtons::UpdateButtons() {
m_sizer->AddStretchSpacer(); m_sizer->AddStretchSpacer();
if(m_sizer->IsEmpty()) // add left margin if no button on left. fixes no gap on small windows
m_sizer->AddSpacer(btn_gap);
for (Button* btn : m_buttons) // Right aligned for (Button* btn : m_buttons) // Right aligned
if(!on_left(btn->GetId())) if(!on_left(btn->GetId()))
m_sizer->Add(btn, 0, wxRIGHT | wxTOP | wxBOTTOM | wxALIGN_CENTER_VERTICAL, btn_gap); m_sizer->Add(btn, 0, wxRIGHT | wxTOP | wxBOTTOM | wxALIGN_CENTER_VERTICAL, btn_gap);

View File

@@ -13,7 +13,7 @@
namespace Slic3r { namespace GUI { namespace Slic3r { namespace GUI {
class DialogButtons : public wxWindow{ class DialogButtons : public wxPanel{
public: 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 = "");
@@ -30,8 +30,8 @@ public:
Button* GetCONFIRM(); Button* GetCONFIRM();
Button* GetNO(); Button* GetNO();
Button* GetCANCEL(); Button* GetCANCEL();
Button* GetBACK(); Button* GetRETURN();
Button* GetFORWARD(); Button* GetNEXT();
void SetPrimaryButton(wxString label); void SetPrimaryButton(wxString label);
@@ -75,7 +75,7 @@ private:
{"replace" , wxID_REPLACE}, {"replace" , wxID_REPLACE},
{"replace all", wxID_REPLACE_ALL}, {"replace all", wxID_REPLACE_ALL},
// Navigation // Navigation
{"back" , wxID_BACKWARD}, {"return" , wxID_BACKWARD}, // use return instead back. back mostly used as side of object in translations
{"next" , wxID_FORWARD}, {"next" , wxID_FORWARD},
// Alert / Negative // Alert / Negative
{"remove" , wxID_REMOVE}, {"remove" , wxID_REMOVE},

View File

@@ -9,6 +9,7 @@
#include "MsgDialog.hpp" #include "MsgDialog.hpp"
#include "libslic3r/Color.hpp" #include "libslic3r/Color.hpp"
#include "Widgets/Button.hpp" #include "Widgets/Button.hpp"
#include "Widgets/DialogButtons.hpp"
#include "slic3r/Utils/ColorSpaceConvert.hpp" #include "slic3r/Utils/ColorSpaceConvert.hpp"
#include "MainFrame.hpp" #include "MainFrame.hpp"
#include "libslic3r/Config.hpp" #include "libslic3r/Config.hpp"
@@ -331,14 +332,6 @@ void WipingDialog::on_dpi_changed(const wxRect &suggested_rect)
button_item.second->SetMinSize(wxSize(FromDIP(75), FromDIP(24))); button_item.second->SetMinSize(wxSize(FromDIP(75), FromDIP(24)));
button_item.second->SetCornerRadius(FromDIP(12)); 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_wiping->msw_rescale(); m_panel_wiping->msw_rescale();
this->Refresh(); this->Refresh();
@@ -375,23 +368,18 @@ WipingDialog::WipingDialog(wxWindow* parent, const std::vector<float>& matrix, c
main_sizer->SetMinSize(wxSize(sizer_width, -1)); main_sizer->SetMinSize(wxSize(sizer_width, -1));
main_sizer->Add(m_panel_wiping, 1, wxEXPAND | wxALL, 0); main_sizer->Add(m_panel_wiping, 1, wxEXPAND | wxALL, 0);
auto btn_sizer = create_btn_sizer(wxOK | wxCANCEL); auto dlg_btns = new DialogButtons(this, {"OK", "Cancel"});
main_sizer->Add(btn_sizer, 0, wxBOTTOM | wxRIGHT | wxEXPAND, BTN_GAP); main_sizer->Add(dlg_btns, 0, wxEXPAND);
SetSizer(main_sizer); SetSizer(main_sizer);
main_sizer->SetSizeHints(this); main_sizer->SetSizeHints(this);
if (this->FindWindowById(wxID_OK, this)) { dlg_btns->GetOK()->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { // if OK button is clicked..
this->FindWindowById(wxID_OK, this)->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { // if OK button is clicked..
m_output_matrix = m_panel_wiping->read_matrix_values(); // ..query wiping panel and save returned values m_output_matrix = m_panel_wiping->read_matrix_values(); // ..query wiping panel and save returned values
m_output_extruders = m_panel_wiping->read_extruders_values(); // so they can be recovered later by calling get_...() m_output_extruders = m_panel_wiping->read_extruders_values(); // so they can be recovered later by calling get_...()
EndModal(wxID_OK); EndModal(wxID_OK);
}, wxID_OK); }, wxID_OK);
}
if (this->FindWindowById(wxID_CANCEL, this)) {
update_ui(static_cast<wxButton*>(this->FindWindowById(wxID_CANCEL, this)));
this->FindWindowById(wxID_CANCEL, this)->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { EndModal(wxCANCEL); });
} dlg_btns->GetCANCEL()->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { EndModal(wxCANCEL); });
/* /*
if (this->FindWindowById(wxID_RESET, this)) { if (this->FindWindowById(wxID_RESET, this)) {