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

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