Undo buttons work

This commit is contained in:
YuSanka 2018-03-06 12:34:20 +01:00
parent 4547755221
commit 3caf54c359
5 changed files with 58 additions and 18 deletions

View file

@ -148,8 +148,8 @@ void Tab::update_dirty(){
for (auto opt_key : dirty_options){
Field* field = get_field(opt_key/*, opt_index*/);
if (field != nullptr && find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) == m_dirty_options.end()){
field->m_Label->SetForegroundColour(*get_modified_label_clr());
field->m_Undo_btn->Show();
field->m_Label->SetForegroundColour(*get_modified_label_clr());
field->m_Undo_btn->SetBitmap(wxBitmap(from_u8(wxMSW ? var("action_undo.png") : var("arrow_undo.png")), wxBITMAP_TYPE_PNG));
m_dirty_options.push_back(opt_key);
}
@ -157,13 +157,13 @@ void Tab::update_dirty(){
// Delete undirty options from m_dirty_options
size_t cnt = m_dirty_options.size();
for (auto i = 0; i < /*cnt*/m_dirty_options.size(); ++i)
for (auto i = 0; i < m_dirty_options.size(); ++i)
{
const std::string &opt_key = m_dirty_options[i];
Field* field = get_field(opt_key/*, opt_index*/);
if (field != nullptr && find(dirty_options.begin(), dirty_options.end(), opt_key) == dirty_options.end())
{
field->m_Undo_btn->Hide();
field->m_Undo_btn->SetBitmap(wxBitmap(from_u8(var("Bullet_white.png")), wxBITMAP_TYPE_PNG));
field->m_Label->SetForegroundColour(wxSYS_COLOUR_WINDOWTEXT);
std::vector<std::string>::iterator itr = find(m_dirty_options.begin(), m_dirty_options.end(), opt_key);
if (itr != m_dirty_options.end()){
@ -1774,6 +1774,11 @@ ConfigOptionsGroupShp Page::new_optgroup(wxString title, int noncommon_label_wid
//! });
};
optgroup->m_get_initial_config = [this](){
DynamicPrintConfig config = static_cast<Tab*>(GetParent())->m_presets->get_selected_preset().config;
return config;
};
vsizer()->Add(optgroup->sizer, 0, wxEXPAND | wxALL, 10);
m_optgroups.push_back(optgroup);