Fixed Windows DarkMode for some dialogues.

+ ProjectDropDialog: wxRadiloBox was changes to the wxStaticBox with wxRadioButtons because of dark mode colors update
+ Preferences: Fixed update of the text colors
This commit is contained in:
YuSanka 2021-07-13 18:27:15 +02:00
parent 782e220890
commit 428362ec53
9 changed files with 39 additions and 40 deletions

View file

@ -72,8 +72,7 @@ CopyrightsDialog::CopyrightsDialog()
m_html->Bind(wxEVT_HTML_LINK_CLICKED, &CopyrightsDialog::onLinkClicked, this); m_html->Bind(wxEVT_HTML_LINK_CLICKED, &CopyrightsDialog::onLinkClicked, this);
wxStdDialogButtonSizer* buttons = this->CreateStdDialogButtonSizer(wxCLOSE); wxStdDialogButtonSizer* buttons = this->CreateStdDialogButtonSizer(wxCLOSE);
wxGetApp().UpdateDarkUI(static_cast<wxButton*>(this->FindWindowById(wxID_CLOSE, this))); wxGetApp().UpdateDlgDarkUI(this, true);
this->SetEscapeId(wxID_CLOSE); this->SetEscapeId(wxID_CLOSE);
this->Bind(wxEVT_BUTTON, &CopyrightsDialog::onCloseDialog, this, wxID_CLOSE); this->Bind(wxEVT_BUTTON, &CopyrightsDialog::onCloseDialog, this, wxID_CLOSE);
sizer->Add(buttons, 0, wxEXPAND | wxRIGHT | wxBOTTOM, 3); sizer->Add(buttons, 0, wxEXPAND | wxRIGHT | wxBOTTOM, 3);
@ -297,7 +296,6 @@ AboutDialog::AboutDialog()
wxStdDialogButtonSizer* buttons = this->CreateStdDialogButtonSizer(wxCLOSE); wxStdDialogButtonSizer* buttons = this->CreateStdDialogButtonSizer(wxCLOSE);
wxGetApp().UpdateDarkUI(static_cast<wxButton*>(this->FindWindowById(wxID_CLOSE, this)));
m_copy_rights_btn_id = NewControlId(); m_copy_rights_btn_id = NewControlId();
auto copy_rights_btn = new wxButton(this, m_copy_rights_btn_id, _L("Portions copyright")+dots); auto copy_rights_btn = new wxButton(this, m_copy_rights_btn_id, _L("Portions copyright")+dots);
@ -309,8 +307,7 @@ AboutDialog::AboutDialog()
buttons->Insert(1, copy_version_btn, 0, wxLEFT, 5); buttons->Insert(1, copy_version_btn, 0, wxLEFT, 5);
copy_version_btn->Bind(wxEVT_BUTTON, &AboutDialog::onCopyToClipboard, this); copy_version_btn->Bind(wxEVT_BUTTON, &AboutDialog::onCopyToClipboard, this);
wxGetApp().UpdateDarkUI(copy_rights_btn); wxGetApp().UpdateDlgDarkUI(this, true);
wxGetApp().UpdateDarkUI(copy_version_btn);
this->SetEscapeId(wxID_CLOSE); this->SetEscapeId(wxID_CLOSE);
this->Bind(wxEVT_BUTTON, &AboutDialog::onCloseDialog, this, wxID_CLOSE); this->Bind(wxEVT_BUTTON, &AboutDialog::onCloseDialog, this, wxID_CLOSE);

View file

@ -177,7 +177,6 @@ void BedShape::apply_optgroup_values(ConfigOptionsGroupShp optgroup)
void BedShapeDialog::build_dialog(const ConfigOptionPoints& default_pt, const ConfigOptionString& custom_texture, const ConfigOptionString& custom_model) void BedShapeDialog::build_dialog(const ConfigOptionPoints& default_pt, const ConfigOptionString& custom_texture, const ConfigOptionString& custom_model)
{ {
SetFont(wxGetApp().normal_font()); SetFont(wxGetApp().normal_font());
// wxGetApp().UpdateDarkUI(this);
m_panel = new BedShapePanel(this); m_panel = new BedShapePanel(this);
m_panel->build_panel(default_pt, custom_texture, custom_model); m_panel->build_panel(default_pt, custom_texture, custom_model);
@ -186,8 +185,7 @@ void BedShapeDialog::build_dialog(const ConfigOptionPoints& default_pt, const Co
main_sizer->Add(m_panel, 1, wxEXPAND); main_sizer->Add(m_panel, 1, wxEXPAND);
main_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10); main_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10);
wxGetApp().UpdateDarkUI(static_cast<wxButton*>(this->FindWindowById(wxID_OK, this)), true); wxGetApp().UpdateDlgDarkUI(this, true);
wxGetApp().UpdateDarkUI(static_cast<wxButton*>(this->FindWindowById(wxID_CANCEL, this)), true);
SetSizer(main_sizer); SetSizer(main_sizer);
SetMinSize(GetSize()); SetMinSize(GetSize());
@ -249,7 +247,6 @@ void BedShapePanel::build_panel(const ConfigOptionPoints& default_pt, const Conf
line.full_width = 1; line.full_width = 1;
line.widget = [this](wxWindow* parent) { line.widget = [this](wxWindow* parent) {
wxButton* shape_btn = new wxButton(parent, wxID_ANY, _L("Load shape from STL...")); wxButton* shape_btn = new wxButton(parent, wxID_ANY, _L("Load shape from STL..."));
wxGetApp().UpdateDarkUI(shape_btn, true);
wxSizer* shape_sizer = new wxBoxSizer(wxHORIZONTAL); wxSizer* shape_sizer = new wxBoxSizer(wxHORIZONTAL);
shape_sizer->Add(shape_btn, 1, wxEXPAND); shape_sizer->Add(shape_btn, 1, wxEXPAND);
@ -333,7 +330,6 @@ wxPanel* BedShapePanel::init_texture_panel()
line.full_width = 1; line.full_width = 1;
line.widget = [this](wxWindow* parent) { line.widget = [this](wxWindow* parent) {
wxButton* load_btn = new wxButton(parent, wxID_ANY, _(L("Load..."))); wxButton* load_btn = new wxButton(parent, wxID_ANY, _(L("Load...")));
wxGetApp().UpdateDarkUI(load_btn, true);
wxSizer* load_sizer = new wxBoxSizer(wxHORIZONTAL); wxSizer* load_sizer = new wxBoxSizer(wxHORIZONTAL);
load_sizer->Add(load_btn, 1, wxEXPAND); load_sizer->Add(load_btn, 1, wxEXPAND);
@ -343,7 +339,6 @@ wxPanel* BedShapePanel::init_texture_panel()
filename_sizer->Add(filename_lbl, 1, wxEXPAND); filename_sizer->Add(filename_lbl, 1, wxEXPAND);
wxButton* remove_btn = new wxButton(parent, wxID_ANY, _(L("Remove"))); wxButton* remove_btn = new wxButton(parent, wxID_ANY, _(L("Remove")));
wxGetApp().UpdateDarkUI(remove_btn, true);
wxSizer* remove_sizer = new wxBoxSizer(wxHORIZONTAL); wxSizer* remove_sizer = new wxBoxSizer(wxHORIZONTAL);
remove_sizer->Add(remove_btn, 1, wxEXPAND); remove_sizer->Add(remove_btn, 1, wxEXPAND);
@ -417,7 +412,6 @@ wxPanel* BedShapePanel::init_model_panel()
line.full_width = 1; line.full_width = 1;
line.widget = [this](wxWindow* parent) { line.widget = [this](wxWindow* parent) {
wxButton* load_btn = new wxButton(parent, wxID_ANY, _(L("Load..."))); wxButton* load_btn = new wxButton(parent, wxID_ANY, _(L("Load...")));
wxGetApp().UpdateDarkUI(load_btn, true);
wxSizer* load_sizer = new wxBoxSizer(wxHORIZONTAL); wxSizer* load_sizer = new wxBoxSizer(wxHORIZONTAL);
load_sizer->Add(load_btn, 1, wxEXPAND); load_sizer->Add(load_btn, 1, wxEXPAND);
@ -426,7 +420,6 @@ wxPanel* BedShapePanel::init_model_panel()
filename_sizer->Add(filename_lbl, 1, wxEXPAND); filename_sizer->Add(filename_lbl, 1, wxEXPAND);
wxButton* remove_btn = new wxButton(parent, wxID_ANY, _(L("Remove"))); wxButton* remove_btn = new wxButton(parent, wxID_ANY, _(L("Remove")));
wxGetApp().UpdateDarkUI(remove_btn, true);
wxSizer* remove_sizer = new wxBoxSizer(wxHORIZONTAL); wxSizer* remove_sizer = new wxBoxSizer(wxHORIZONTAL);
remove_sizer->Add(remove_btn, 1, wxEXPAND); remove_sizer->Add(remove_btn, 1, wxEXPAND);

View file

@ -70,9 +70,9 @@ ButtonsDescription::ButtonsDescription(wxWindow* parent, const std::vector<Entry
auto buttons = CreateStdDialogButtonSizer(wxOK|wxCANCEL); auto buttons = CreateStdDialogButtonSizer(wxOK|wxCANCEL);
main_sizer->Add(buttons, 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10); main_sizer->Add(buttons, 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10);
wxGetApp().UpdateDlgDarkUI(this, true);
wxButton* btn = static_cast<wxButton*>(FindWindowById(wxID_OK, this)); wxButton* btn = static_cast<wxButton*>(FindWindowById(wxID_OK, this));
wxGetApp().UpdateDarkUI(btn);
wxGetApp().UpdateDarkUI(static_cast<wxButton*>(this->FindWindowById(wxID_CANCEL, this)));
btn->Bind(wxEVT_BUTTON, [sys_colour, mod_colour, this](wxCommandEvent&) { btn->Bind(wxEVT_BUTTON, [sys_colour, mod_colour, this](wxCommandEvent&) {
wxGetApp().set_label_clr_sys(sys_colour->GetColour()); wxGetApp().set_label_clr_sys(sys_colour->GetColour());
wxGetApp().set_label_clr_modified(mod_colour->GetColour()); wxGetApp().set_label_clr_modified(mod_colour->GetColour());

View file

@ -1115,10 +1115,11 @@ void GUI_App::UpdateDarkUI(wxWindow* window, bool highlited/* = false*/, bool ju
// recursive function for scaling fonts for all controls in Window // recursive function for scaling fonts for all controls in Window
#ifdef _WIN32 #ifdef _WIN32
static void update_dark_children_ui(wxWindow* window) static void update_dark_children_ui(wxWindow* window, bool just_buttons_update = false)
{ {
bool highlight_btn = dynamic_cast<wxButton*>(window) != nullptr; bool is_btn = dynamic_cast<wxButton*>(window) != nullptr;
wxGetApp().UpdateDarkUI(window, highlight_btn); if (!(just_buttons_update && !is_btn))
wxGetApp().UpdateDarkUI(window, is_btn);
auto children = window->GetChildren(); auto children = window->GetChildren();
for (auto child : children) { for (auto child : children) {
@ -1127,10 +1128,11 @@ static void update_dark_children_ui(wxWindow* window)
} }
#endif #endif
void GUI_App::UpdateDlgDarkUI(wxDialog* dlg) // Note: Don't use this function for Dialog contains ScalableButtons
void GUI_App::UpdateDlgDarkUI(wxDialog* dlg, bool just_buttons_update/* = false*/)
{ {
#ifdef _WIN32 #ifdef _WIN32
update_dark_children_ui(dlg); update_dark_children_ui(dlg, just_buttons_update);
#endif #endif
} }
void GUI_App::UpdateDVCDarkUI(wxDataViewCtrl* dvc, bool highlited/* = false*/) void GUI_App::UpdateDVCDarkUI(wxDataViewCtrl* dvc, bool highlited/* = false*/)

View file

@ -182,7 +182,7 @@ public:
// update color mode for window // update color mode for window
void UpdateDarkUI(wxWindow *window, bool highlited = false, bool just_font = false); void UpdateDarkUI(wxWindow *window, bool highlited = false, bool just_font = false);
// update color mode for whole dialog including all children // update color mode for whole dialog including all children
void UpdateDlgDarkUI(wxDialog* dlg); void UpdateDlgDarkUI(wxDialog* dlg, bool just_buttons_update = false);
// update color mode for DataViewControl // update color mode for DataViewControl
void UpdateDVCDarkUI(wxDataViewCtrl* dvc, bool highlited = false); void UpdateDVCDarkUI(wxDataViewCtrl* dvc, bool highlited = false);
// update color mode for panel including all static texts controls // update color mode for panel including all static texts controls

View file

@ -4956,11 +4956,11 @@ enum class LoadType : unsigned char
class ProjectDropDialog : public DPIDialog class ProjectDropDialog : public DPIDialog
{ {
wxRadioBox* m_action{ nullptr }; int m_action { 0 };
public: public:
ProjectDropDialog(const std::string& filename); ProjectDropDialog(const std::string& filename);
int get_action() const { return m_action->GetSelection() + 1; } int get_action() const { return m_action + 1; }
protected: protected:
void on_dpi_changed(const wxRect& suggested_rect) override; void on_dpi_changed(const wxRect& suggested_rect) override;
@ -4981,12 +4981,24 @@ ProjectDropDialog::ProjectDropDialog(const std::string& filename)
main_sizer->Add(new wxStaticText(this, wxID_ANY, main_sizer->Add(new wxStaticText(this, wxID_ANY,
_L("Select an action to apply to the file") + ": " + from_u8(filename)), 0, wxEXPAND | wxALL, 10); _L("Select an action to apply to the file") + ": " + from_u8(filename)), 0, wxEXPAND | wxALL, 10);
m_action = new wxRadioBox(this, wxID_ANY, _L("Action"), wxDefaultPosition, wxDefaultSize,
WXSIZEOF(choices), choices, 0, wxRA_SPECIFY_ROWS);
int action = std::clamp(std::stoi(wxGetApp().app_config->get("drop_project_action")), int action = std::clamp(std::stoi(wxGetApp().app_config->get("drop_project_action")),
static_cast<int>(LoadType::OpenProject), static_cast<int>(LoadType::LoadConfig)) - 1; static_cast<int>(LoadType::OpenProject), static_cast<int>(LoadType::LoadConfig)) - 1;
m_action->SetSelection(action);
main_sizer->Add(m_action, 1, wxEXPAND | wxRIGHT | wxLEFT, 10); wxStaticBox* action_stb = new wxStaticBox(this, wxID_ANY, _L("Action"));
if (!wxOSX) action_stb->SetBackgroundStyle(wxBG_STYLE_PAINT);
action_stb->SetFont(wxGetApp().normal_font());
wxStaticBoxSizer* stb_sizer = new wxStaticBoxSizer(action_stb, wxVERTICAL);
int id = 0;
for (const wxString& label : choices) {
wxRadioButton* btn = new wxRadioButton(this, wxID_ANY, label, wxDefaultPosition, wxDefaultSize, id == 0 ? wxRB_GROUP : 0);
btn->SetValue(id == action);
btn->Bind(wxEVT_RADIOBUTTON, [this, id](wxCommandEvent&) { m_action = id; });
stb_sizer->Add(btn, 0, wxEXPAND | wxTOP, 5);
id++;
}
main_sizer->Add(stb_sizer, 1, wxEXPAND | wxRIGHT | wxLEFT, 10);
wxBoxSizer* bottom_sizer = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* bottom_sizer = new wxBoxSizer(wxHORIZONTAL);
wxCheckBox* check = new wxCheckBox(this, wxID_ANY, _L("Don't show again")); wxCheckBox* check = new wxCheckBox(this, wxID_ANY, _L("Don't show again"));
@ -5000,6 +5012,9 @@ ProjectDropDialog::ProjectDropDialog(const std::string& filename)
SetSizer(main_sizer); SetSizer(main_sizer);
main_sizer->SetSizeHints(this); main_sizer->SetSizeHints(this);
// Update DarkUi just for buttons
wxGetApp().UpdateDlgDarkUI(this, true);
} }
void ProjectDropDialog::on_dpi_changed(const wxRect& suggested_rect) void ProjectDropDialog::on_dpi_changed(const wxRect& suggested_rect)

View file

@ -393,11 +393,9 @@ void PreferencesDialog::build()
sizer->Add(tabs, 1, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 5); sizer->Add(tabs, 1, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 5);
auto buttons = CreateStdDialogButtonSizer(wxOK | wxCANCEL); auto buttons = CreateStdDialogButtonSizer(wxOK | wxCANCEL);
wxButton* btn = static_cast<wxButton*>(FindWindowById(wxID_OK, this)); this->Bind(wxEVT_BUTTON, &PreferencesDialog::accept, this, wxID_OK);
btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { accept(); });
wxGetApp().UpdateDarkUI(btn); wxGetApp().UpdateDlgDarkUI(this, true);
wxGetApp().UpdateDarkUI(static_cast<wxButton*>(this->FindWindowById(wxID_CANCEL, this)));
sizer->Add(buttons, 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM | wxTOP, 10); sizer->Add(buttons, 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM | wxTOP, 10);
@ -406,7 +404,7 @@ void PreferencesDialog::build()
this->CenterOnParent(); this->CenterOnParent();
} }
void PreferencesDialog::accept() void PreferencesDialog::accept(wxEvent&)
{ {
// if (m_values.find("no_defaults") != m_values.end() // if (m_values.find("no_defaults") != m_values.end()
// warning_catcher(this, wxString::Format(_L("You need to restart %s to make the changes effective."), SLIC3R_APP_NAME)); // warning_catcher(this, wxString::Format(_L("You need to restart %s to make the changes effective."), SLIC3R_APP_NAME));
@ -434,11 +432,6 @@ void PreferencesDialog::accept()
} }
} }
if (m_values.empty()) {
EndModal(wxID_CANCEL);
return;
}
auto app_config = get_app_config(); auto app_config = get_app_config();
m_seq_top_layer_only_changed = false; m_seq_top_layer_only_changed = false;

View file

@ -46,7 +46,7 @@ public:
#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER #endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER
bool recreate_GUI() const { return m_recreate_GUI; } bool recreate_GUI() const { return m_recreate_GUI; }
void build(); void build();
void accept(); void accept(wxEvent&);
protected: protected:
void on_dpi_changed(const wxRect &suggested_rect) override; void on_dpi_changed(const wxRect &suggested_rect) override;

View file

@ -170,8 +170,7 @@ SysInfoDialog::SysInfoDialog()
this->Bind(wxEVT_BUTTON, &SysInfoDialog::onCloseDialog, this, wxID_OK); this->Bind(wxEVT_BUTTON, &SysInfoDialog::onCloseDialog, this, wxID_OK);
main_sizer->Add(buttons, 0, wxEXPAND | wxRIGHT | wxBOTTOM, 3); main_sizer->Add(buttons, 0, wxEXPAND | wxRIGHT | wxBOTTOM, 3);
wxGetApp().UpdateDarkUI(static_cast<wxButton*>(this->FindWindowById(wxID_OK, this)), true); wxGetApp().UpdateDlgDarkUI(this, true);
wxGetApp().UpdateDarkUI(m_btn_copy_to_clipboard, true);
// this->Bind(wxEVT_LEFT_DOWN, &SysInfoDialog::onCloseDialog, this); // this->Bind(wxEVT_LEFT_DOWN, &SysInfoDialog::onCloseDialog, this);
// logo->Bind(wxEVT_LEFT_DOWN, &SysInfoDialog::onCloseDialog, this); // logo->Bind(wxEVT_LEFT_DOWN, &SysInfoDialog::onCloseDialog, this);