mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-26 20:32:06 +00:00
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:
@@ -6,7 +6,7 @@ namespace Slic3r { namespace GUI {
|
||||
|
||||
// ORCA standardize dialog buttons
|
||||
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_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
@@ -73,8 +73,8 @@ Button* DialogButtons::GetAPPLY() {return GetButtonFromID(wxID_APPLY) ;}
|
||||
Button* DialogButtons::GetCONFIRM(){return GetButtonFromID(wxID_APPLY) ;}
|
||||
Button* DialogButtons::GetNO() {return GetButtonFromID(wxID_NO) ;}
|
||||
Button* DialogButtons::GetCANCEL() {return GetButtonFromID(wxID_CANCEL) ;}
|
||||
Button* DialogButtons::GetBACK() {return GetButtonFromID(wxID_BACKWARD);}
|
||||
Button* DialogButtons::GetFORWARD(){return GetButtonFromID(wxID_FORWARD) ;}
|
||||
Button* DialogButtons::GetRETURN() {return GetButtonFromID(wxID_BACKWARD);} // gets Return button
|
||||
Button* DialogButtons::GetNEXT() {return GetButtonFromID(wxID_FORWARD) ;}
|
||||
|
||||
void DialogButtons::SetPrimaryButton(wxString translated_label) {
|
||||
// use _L("Create") translated text for custom buttons
|
||||
@@ -92,8 +92,12 @@ void DialogButtons::SetPrimaryButton(wxString translated_label) {
|
||||
|
||||
m_primary = translated_label;
|
||||
|
||||
btn->SetFocus();
|
||||
// apply focus only if there is no focused element exist. this prevents stealing focus from input boxes
|
||||
if(m_parent->FindFocus() == nullptr)
|
||||
btn->SetFocus();
|
||||
|
||||
// we won't need color definations after button style management
|
||||
bool is_dark = wxGetApp().dark_mode();
|
||||
StateColor clr_bg = StateColor(
|
||||
std::pair(wxColour("#009688"), (int)StateColor::NotHovered),
|
||||
std::pair(wxColour("#DFDFDF"), (int)StateColor::Disabled),
|
||||
@@ -105,7 +109,8 @@ void DialogButtons::SetPrimaryButton(wxString translated_label) {
|
||||
btn->SetBackgroundColor(clr_bg);
|
||||
StateColor clr_br = StateColor(
|
||||
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);
|
||||
StateColor clr_tx = StateColor(
|
||||
@@ -143,6 +148,7 @@ void DialogButtons::SetAlertButton(wxString translated_label) {
|
||||
btn->SetBackgroundColor(clr_bg);
|
||||
StateColor clr_br = StateColor(
|
||||
std::pair(wxColour("#DFDFDF"), (int)StateColor::NotFocused),
|
||||
std::pair(wxColour("#DFDFDF"), (int)StateColor::Disabled),
|
||||
std::pair(wxColour("#26A69A"), (int)StateColor::Focused)
|
||||
);
|
||||
btn->SetBorderColor(clr_br);
|
||||
@@ -171,6 +177,7 @@ void DialogButtons::UpdateButtons() {
|
||||
);
|
||||
StateColor clr_br = StateColor(
|
||||
std::pair(wxColour("#DFDFDF"), (int)StateColor::NotFocused),
|
||||
std::pair(wxColour("#DFDFDF"), (int)StateColor::Disabled),
|
||||
std::pair(wxColour("#26A69A"), (int)StateColor::Focused)
|
||||
);
|
||||
StateColor clr_tx = StateColor(
|
||||
@@ -205,6 +212,9 @@ void DialogButtons::UpdateButtons() {
|
||||
|
||||
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
|
||||
if(!on_left(btn->GetId()))
|
||||
m_sizer->Add(btn, 0, wxRIGHT | wxTOP | wxBOTTOM | wxALIGN_CENTER_VERTICAL, btn_gap);
|
||||
|
||||
Reference in New Issue
Block a user