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 64dc09ea56
commit 71e96eed48
15 changed files with 98 additions and 279 deletions

View File

@@ -10754,7 +10754,6 @@ public:
WX_DECLARE_LIST(RadioSelector, RadioSelectorList);
#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
{
@@ -10772,14 +10771,11 @@ public:
wxStaticText *m_fname_f;
wxStaticText *m_fname_s;
StaticBox * m_panel_select;
Button * m_confirm;
Button * m_cancel;
void select_radio(int index);
void on_select_radio(wxMouseEvent &event);
void on_select_ok(wxMouseEvent &event);
void on_select_cancel(wxMouseEvent &event);
void on_select_ok(wxCommandEvent &event);
void on_select_cancel(wxCommandEvent &event);
int get_select_radio(int groupid);
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);
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
// 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_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"));
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));
dlg_btns->GetOK()->Bind(wxEVT_BUTTON, &ProjectDropDialog::on_select_ok, this);
m_confirm->SetBackgroundColor(btn_bg_green);
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);
dlg_btns->GetCANCEL()->Bind(wxEVT_BUTTON, &ProjectDropDialog::on_select_cancel, this);
m_cancel = new Button(this, _L("Cancel"));
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);
m_sizer_main->Add(dlg_btns, 0, wxEXPAND);
SetSizer(m_sizer_main);
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) {
LoadType load_type = static_cast<LoadType>(get_action());
@@ -11075,15 +11051,13 @@ void ProjectDropDialog::on_select_ok(wxMouseEvent &event)
EndModal(wxID_OK);
}
void ProjectDropDialog::on_select_cancel(wxMouseEvent &event)
void ProjectDropDialog::on_select_cancel(wxCommandEvent &event)
{
EndModal(wxID_CANCEL);
}
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();
Refresh();
}