Move text color selection from ButtonsDescription to Preferences dialog (related to #5489)

This commit is contained in:
YuSanka 2020-12-30 11:55:26 +01:00
parent 0331bcefd9
commit 6effa30322
6 changed files with 75 additions and 18 deletions

View File

@ -1024,6 +1024,12 @@ void GUI_App::update_label_colours_from_appconfig()
} }
} }
void GUI_App::update_label_colours()
{
for (Tab* tab : tabs_list)
tab->update_label_colours();
}
void GUI_App::init_fonts() void GUI_App::init_fonts()
{ {
m_small_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); m_small_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
@ -1057,7 +1063,10 @@ void GUI_App::update_fonts(const MainFrame *main_frame)
m_code_font.SetPointSize(m_normal_font.GetPointSize()); m_code_font.SetPointSize(m_normal_font.GetPointSize());
} }
void GUI_App::set_label_clr_modified(const wxColour& clr) { void GUI_App::set_label_clr_modified(const wxColour& clr)
{
if (m_color_label_modified == clr)
return;
m_color_label_modified = clr; m_color_label_modified = clr;
auto clr_str = wxString::Format(wxT("#%02X%02X%02X"), clr.Red(), clr.Green(), clr.Blue()); auto clr_str = wxString::Format(wxT("#%02X%02X%02X"), clr.Red(), clr.Green(), clr.Blue());
std::string str = clr_str.ToStdString(); std::string str = clr_str.ToStdString();
@ -1065,7 +1074,10 @@ void GUI_App::set_label_clr_modified(const wxColour& clr) {
app_config->save(); app_config->save();
} }
void GUI_App::set_label_clr_sys(const wxColour& clr) { void GUI_App::set_label_clr_sys(const wxColour& clr)
{
if (m_color_label_sys == clr)
return;
m_color_label_sys = clr; m_color_label_sys = clr;
auto clr_str = wxString::Format(wxT("#%02X%02X%02X"), clr.Red(), clr.Green(), clr.Blue()); auto clr_str = wxString::Format(wxT("#%02X%02X%02X"), clr.Red(), clr.Green(), clr.Blue());
std::string str = clr_str.ToStdString(); std::string str = clr_str.ToStdString();
@ -1220,6 +1232,7 @@ void fatal_error(wxWindow* parent)
// Update the UI based on the current preferences. // Update the UI based on the current preferences.
void GUI_App::update_ui_from_settings(bool apply_free_camera_correction) void GUI_App::update_ui_from_settings(bool apply_free_camera_correction)
{ {
update_label_colours();
mainframe->update_ui_from_settings(apply_free_camera_correction); mainframe->update_ui_from_settings(apply_free_camera_correction);
} }

View File

@ -167,6 +167,7 @@ public:
static bool dark_mode(); static bool dark_mode();
void init_label_colours(); void init_label_colours();
void update_label_colours_from_appconfig(); void update_label_colours_from_appconfig();
void update_label_colours();
void init_fonts(); void init_fonts();
void update_fonts(const MainFrame *main_frame = nullptr); void update_fonts(const MainFrame *main_frame = nullptr);
void set_label_clr_modified(const wxColour& clr); void set_label_clr_modified(const wxColour& clr);

View File

@ -312,6 +312,7 @@ void PreferencesDialog::build()
m_icon_size_sizer->ShowItems(app_config->get("use_custom_toolbar_size") == "1"); m_icon_size_sizer->ShowItems(app_config->get("use_custom_toolbar_size") == "1");
create_settings_mode_widget(); create_settings_mode_widget();
create_settings_text_color_widget();
} }
#if ENABLE_ENVIRONMENT_MAP #if ENABLE_ENVIRONMENT_MAP
@ -379,6 +380,10 @@ void PreferencesDialog::accept()
app_config->set(it->first, it->second); app_config->set(it->first, it->second);
app_config->save(); app_config->save();
wxGetApp().set_label_clr_sys(m_sys_colour->GetColour());
wxGetApp().set_label_clr_modified(m_mod_colour->GetColour());
EndModal(wxID_OK); EndModal(wxID_OK);
if (m_settings_layout_changed) if (m_settings_layout_changed)
@ -498,6 +503,42 @@ void PreferencesDialog::create_settings_mode_widget()
m_optgroup_gui->sizer->Add(sizer, 0, wxEXPAND); m_optgroup_gui->sizer->Add(sizer, 0, wxEXPAND);
} }
void PreferencesDialog::create_settings_text_color_widget()
{
wxWindow* parent = m_optgroup_gui->parent();
wxStaticBox* stb = new wxStaticBox(parent, wxID_ANY, _L("Text color Settings"));
if (!wxOSX) stb->SetBackgroundStyle(wxBG_STYLE_PAINT);
wxSizer* sizer = new wxStaticBoxSizer(stb, wxVERTICAL);
wxFlexGridSizer* grid_sizer = new wxFlexGridSizer(2, 10, 20);
sizer->Add(grid_sizer, 0, wxEXPAND);
auto sys_label = new wxStaticText(parent, wxID_ANY, _L("Value is the same as the system value"));
sys_label->SetForegroundColour(wxGetApp().get_label_clr_sys());
m_sys_colour = new wxColourPickerCtrl(parent, wxID_ANY, wxGetApp().get_label_clr_sys());
m_sys_colour->Bind(wxEVT_COLOURPICKER_CHANGED, [this, sys_label](wxCommandEvent&) {
sys_label->SetForegroundColour(m_sys_colour->GetColour());
sys_label->Refresh();
});
grid_sizer->Add(m_sys_colour, -1, wxALIGN_CENTRE_VERTICAL);
grid_sizer->Add(sys_label, -1, wxALIGN_CENTRE_VERTICAL | wxEXPAND);
auto mod_label = new wxStaticText(parent, wxID_ANY, _L("Value was changed and is not equal to the system value or the last saved preset"));
mod_label->SetForegroundColour(wxGetApp().get_label_clr_modified());
m_mod_colour = new wxColourPickerCtrl(parent, wxID_ANY, wxGetApp().get_label_clr_modified());
m_mod_colour->Bind(wxEVT_COLOURPICKER_CHANGED, [this, mod_label](wxCommandEvent&) {
mod_label->SetForegroundColour(m_mod_colour->GetColour());
mod_label->Refresh();
});
grid_sizer->Add(m_mod_colour, -1, wxALIGN_CENTRE_VERTICAL);
grid_sizer->Add(mod_label, -1, wxALIGN_CENTRE_VERTICAL | wxEXPAND);
m_optgroup_gui->sizer->Add(sizer, 0, wxEXPAND | wxTOP, em_unit());
}
} // GUI } // GUI
} // Slic3r } // Slic3r

View File

@ -8,6 +8,7 @@
#include <map> #include <map>
class wxRadioBox; class wxRadioBox;
class wxColourPickerCtrl;
namespace Slic3r { namespace Slic3r {
namespace GUI { namespace GUI {
@ -25,6 +26,8 @@ class PreferencesDialog : public DPIDialog
#endif // ENABLE_ENVIRONMENT_MAP #endif // ENABLE_ENVIRONMENT_MAP
wxSizer* m_icon_size_sizer; wxSizer* m_icon_size_sizer;
wxRadioBox* m_layout_mode_box; wxRadioBox* m_layout_mode_box;
wxColourPickerCtrl* m_sys_colour {nullptr};
wxColourPickerCtrl* m_mod_colour {nullptr};
bool isOSX {false}; bool isOSX {false};
bool m_settings_layout_changed {false}; bool m_settings_layout_changed {false};
bool m_seq_top_layer_only_changed{ false }; bool m_seq_top_layer_only_changed{ false };
@ -43,6 +46,7 @@ protected:
void layout(); void layout();
void create_icon_size_slider(); void create_icon_size_slider();
void create_settings_mode_widget(); void create_settings_mode_widget();
void create_settings_text_color_widget();
}; };
} // GUI } // GUI

View File

@ -235,18 +235,11 @@ void Tab::create_preset_tab()
m_undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { on_roll_back_value(); })); m_undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { on_roll_back_value(); }));
m_undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { on_roll_back_value(true); })); m_undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { on_roll_back_value(true); }));
m_question_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) m_question_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent) {
{
ButtonsDescription dlg(this, m_icon_descriptions); ButtonsDescription dlg(this, m_icon_descriptions);
if (dlg.ShowModal() == wxID_OK) { if (dlg.ShowModal() == wxID_OK)
// Colors for ui "decoration" wxGetApp().update_label_colours();
for (Tab *tab : wxGetApp().tabs_list) { });
tab->m_sys_label_clr = wxGetApp().get_label_clr_sys();
tab->m_modified_label_clr = wxGetApp().get_label_clr_modified();
tab->update_labels_colour();
}
}
}));
m_search_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent) { wxGetApp().plater()->search(false); }); m_search_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent) { wxGetApp().plater()->search(false); });
// Colors for ui "decoration" // Colors for ui "decoration"
@ -482,8 +475,13 @@ void Tab::OnActivate()
Refresh(); Refresh();
} }
void Tab::update_labels_colour() void Tab::update_label_colours()
{ {
if (m_sys_label_clr == wxGetApp().get_label_clr_sys() && m_modified_label_clr == wxGetApp().get_label_clr_modified())
return;
m_sys_label_clr = wxGetApp().get_label_clr_sys();
m_modified_label_clr = wxGetApp().get_label_clr_modified();
//update options "decoration" //update options "decoration"
for (const auto opt : m_options_list) for (const auto opt : m_options_list)
{ {
@ -529,6 +527,8 @@ void Tab::update_labels_colour()
} }
cur_item = m_treectrl->GetNextVisible(cur_item); cur_item = m_treectrl->GetNextVisible(cur_item);
} }
decorate();
} }
void Tab::decorate() void Tab::decorate()
@ -992,9 +992,7 @@ void Tab::sys_color_changed()
m_treectrl->AssignImageList(m_icons); m_treectrl->AssignImageList(m_icons);
// Colors for ui "decoration" // Colors for ui "decoration"
m_sys_label_clr = wxGetApp().get_label_clr_sys(); update_label_colours();
m_modified_label_clr = wxGetApp().get_label_clr_modified();
update_labels_colour();
// update options_groups // update options_groups
if (m_active_page) if (m_active_page)

View File

@ -295,7 +295,7 @@ public:
void toggle_show_hide_incompatible(); void toggle_show_hide_incompatible();
void update_show_hide_incompatible_button(); void update_show_hide_incompatible_button();
void update_ui_from_settings(); void update_ui_from_settings();
void update_labels_colour(); void update_label_colours();
void decorate(); void decorate();
void update_changed_ui(); void update_changed_ui();
void get_sys_and_mod_flags(const std::string& opt_key, bool& sys_page, bool& modified_page); void get_sys_and_mod_flags(const std::string& opt_key, bool& sys_page, bool& modified_page);