ButtonsDescription files: Some code refactoring
ButtonsDescription class is splitted to separated items and put to the namespace GUI_Descriptions
This commit is contained in:
parent
0c72adf867
commit
3cb1386990
@ -83,8 +83,9 @@ wxBitmapBundle * ModePaletteComboBox::get_bmp(const std::vector<std::string> &pa
|
||||
return bmp_bndl;
|
||||
}
|
||||
|
||||
namespace GUI_Descriptions {
|
||||
|
||||
void ButtonsDescription::FillSizerWithTextColorDescriptions(wxSizer* sizer, wxWindow* parent, wxColourPickerCtrl** sys_colour, wxColourPickerCtrl** mod_colour)
|
||||
void FillSizerWithTextColorDescriptions(wxSizer* sizer, wxWindow* parent, wxColourPickerCtrl** sys_colour, wxColourPickerCtrl** mod_colour)
|
||||
{
|
||||
wxFlexGridSizer* grid_sizer = new wxFlexGridSizer(3, 5, 5);
|
||||
sizer->Add(grid_sizer, 0, wxEXPAND);
|
||||
@ -127,7 +128,7 @@ void ButtonsDescription::FillSizerWithTextColorDescriptions(wxSizer* sizer, wxWi
|
||||
add_color(mod_colour, wxGetApp().get_label_clr_modified(),wxGetApp().get_label_default_clr_modified(), _L("Value was changed and is not equal to the system value or the last saved preset"));
|
||||
}
|
||||
|
||||
void ButtonsDescription::FillSizerWithModeColorDescriptions(
|
||||
void FillSizerWithModeColorDescriptions(
|
||||
wxSizer* sizer, wxWindow* parent,
|
||||
std::vector<wxColourPickerCtrl**> clr_pickers,
|
||||
std::vector<wxColour>& mode_palette)
|
||||
@ -195,7 +196,7 @@ void ButtonsDescription::FillSizerWithModeColorDescriptions(
|
||||
}
|
||||
}
|
||||
|
||||
ButtonsDescription::ButtonsDescription(wxWindow* parent, const std::vector<Entry> &entries) :
|
||||
Dialog::Dialog(wxWindow* parent, const std::vector<ButtonEntry> &entries) :
|
||||
wxDialog(parent, wxID_ANY, _(L("Buttons And Text Colors Description")), wxDefaultPosition, wxDefaultSize),
|
||||
m_entries(entries)
|
||||
{
|
||||
@ -207,7 +208,7 @@ ButtonsDescription::ButtonsDescription(wxWindow* parent, const std::vector<Entry
|
||||
main_sizer->Add(grid_sizer, 0, wxEXPAND | wxALL, 20);
|
||||
|
||||
// Icon description
|
||||
for (const Entry &entry : m_entries)
|
||||
for (const ButtonEntry &entry : m_entries)
|
||||
{
|
||||
auto icon = new wxStaticBitmap(this, wxID_ANY, entry.bitmap->bmp());
|
||||
grid_sizer->Add(icon, -1, wxALIGN_CENTRE_VERTICAL);
|
||||
@ -219,14 +220,14 @@ ButtonsDescription::ButtonsDescription(wxWindow* parent, const std::vector<Entry
|
||||
|
||||
// Text color description
|
||||
wxSizer* sizer = new wxBoxSizer(wxVERTICAL);
|
||||
FillSizerWithTextColorDescriptions(sizer, this, &sys_colour, &mod_colour);
|
||||
GUI_Descriptions::FillSizerWithTextColorDescriptions(sizer, this, &sys_colour, &mod_colour);
|
||||
main_sizer->Add(sizer, 0, wxEXPAND | wxALL, 20);
|
||||
|
||||
// Mode color markers description
|
||||
mode_palette = wxGetApp().get_mode_palette();
|
||||
|
||||
wxSizer* mode_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
FillSizerWithModeColorDescriptions(mode_sizer, this, { &simple, &advanced, &expert }, mode_palette);
|
||||
GUI_Descriptions::FillSizerWithModeColorDescriptions(mode_sizer, this, { &simple, &advanced, &expert }, mode_palette);
|
||||
main_sizer->Add(mode_sizer, 0, wxEXPAND | wxALL, 20);
|
||||
|
||||
auto buttons = CreateStdDialogButtonSizer(wxOK|wxCANCEL);
|
||||
@ -248,6 +249,7 @@ ButtonsDescription::ButtonsDescription(wxWindow* parent, const std::vector<Entry
|
||||
main_sizer->SetSizeHints(this);
|
||||
}
|
||||
|
||||
} // GUI_Descriptions
|
||||
} // GUI
|
||||
} // Slic3r
|
||||
|
||||
|
@ -35,9 +35,20 @@ protected:
|
||||
wxBitmapBundle* get_bmp( const std::vector<std::string>& palette);
|
||||
};
|
||||
|
||||
namespace GUI_Descriptions {
|
||||
|
||||
class ButtonsDescription : public wxDialog
|
||||
struct ButtonEntry {
|
||||
ButtonEntry(ScalableBitmap *bitmap, const std::string &symbol, const std::string &explanation) : bitmap(bitmap), symbol(symbol), explanation(explanation) {}
|
||||
|
||||
ScalableBitmap *bitmap;
|
||||
std::string symbol;
|
||||
std::string explanation;
|
||||
};
|
||||
|
||||
class Dialog : public wxDialog
|
||||
{
|
||||
std::vector<ButtonEntry> m_entries;
|
||||
|
||||
wxColourPickerCtrl* sys_colour{ nullptr };
|
||||
wxColourPickerCtrl* mod_colour{ nullptr };
|
||||
|
||||
@ -47,25 +58,16 @@ class ButtonsDescription : public wxDialog
|
||||
|
||||
std::vector<wxColour> mode_palette;
|
||||
public:
|
||||
struct Entry {
|
||||
Entry(ScalableBitmap *bitmap, const std::string &symbol, const std::string &explanation) : bitmap(bitmap), symbol(symbol), explanation(explanation) {}
|
||||
|
||||
ScalableBitmap *bitmap;
|
||||
std::string symbol;
|
||||
std::string explanation;
|
||||
};
|
||||
Dialog(wxWindow* parent, const std::vector<ButtonEntry> &entries);
|
||||
~Dialog() {}
|
||||
};
|
||||
|
||||
ButtonsDescription(wxWindow* parent, const std::vector<Entry> &entries);
|
||||
~ButtonsDescription() {}
|
||||
|
||||
static void FillSizerWithTextColorDescriptions(wxSizer* sizer, wxWindow* parent, wxColourPickerCtrl** sys_colour, wxColourPickerCtrl** mod_colour);
|
||||
static void FillSizerWithModeColorDescriptions(wxSizer* sizer, wxWindow* parent,
|
||||
extern void FillSizerWithTextColorDescriptions(wxSizer* sizer, wxWindow* parent, wxColourPickerCtrl** sys_colour, wxColourPickerCtrl** mod_colour);
|
||||
extern void FillSizerWithModeColorDescriptions(wxSizer* sizer, wxWindow* parent,
|
||||
std::vector<wxColourPickerCtrl**> clr_pickers,
|
||||
std::vector<wxColour>& mode_palette);
|
||||
|
||||
private:
|
||||
std::vector<Entry> m_entries;
|
||||
};
|
||||
} // GUI_Descriptions
|
||||
|
||||
} // GUI
|
||||
} // Slic3r
|
||||
|
@ -1041,7 +1041,7 @@ void PreferencesDialog::create_settings_text_color_widget()
|
||||
m_blinkers[opt_key] = new BlinkingBitmap(parent);
|
||||
|
||||
wxSizer* stb_sizer = new wxStaticBoxSizer(stb, wxVERTICAL);
|
||||
ButtonsDescription::FillSizerWithTextColorDescriptions(stb_sizer, parent, &m_sys_colour, &m_mod_colour);
|
||||
GUI_Descriptions::FillSizerWithTextColorDescriptions(stb_sizer, parent, &m_sys_colour, &m_mod_colour);
|
||||
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(m_blinkers[opt_key], 0, wxRIGHT, 2);
|
||||
@ -1068,7 +1068,7 @@ void PreferencesDialog::create_settings_mode_color_widget()
|
||||
|
||||
// Mode color markers description
|
||||
m_mode_palette = wxGetApp().get_mode_palette();
|
||||
ButtonsDescription::FillSizerWithModeColorDescriptions(stb_sizer, parent, { &m_mode_simple, &m_mode_advanced, &m_mode_expert }, m_mode_palette);
|
||||
GUI_Descriptions::FillSizerWithModeColorDescriptions(stb_sizer, parent, { &m_mode_simple, &m_mode_advanced, &m_mode_expert }, m_mode_palette);
|
||||
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(m_blinkers[opt_key], 0, wxRIGHT, 2);
|
||||
|
@ -194,7 +194,7 @@ void Tab::create_preset_tab()
|
||||
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_question_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent) {
|
||||
ButtonsDescription dlg(this, m_icon_descriptions);
|
||||
GUI_Descriptions::Dialog dlg(this, m_icon_descriptions);
|
||||
if (dlg.ShowModal() == wxID_OK)
|
||||
wxGetApp().update_label_colours();
|
||||
});
|
||||
|
@ -254,7 +254,7 @@ protected:
|
||||
std::map<std::string, int> m_options_list;
|
||||
int m_opt_status_value = 0;
|
||||
|
||||
std::vector<ButtonsDescription::Entry> m_icon_descriptions = {};
|
||||
std::vector<GUI_Descriptions::ButtonEntry> m_icon_descriptions = {};
|
||||
|
||||
bool m_is_modified_values{ false };
|
||||
bool m_is_nonsys_values{ true };
|
||||
|
Loading…
Reference in New Issue
Block a user