Finally fix for settings item selection
This commit is contained in:
parent
6826e31e2a
commit
4d8a028262
3 changed files with 49 additions and 14 deletions
|
@ -2183,6 +2183,7 @@ SettingsBundle ObjectList::get_item_settings_bundle(const DynamicPrintConfig* co
|
||||||
return bundle;
|
return bundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add new SettingsItem for parent_item if it doesn't exist, or just update a digest according to new config
|
||||||
wxDataViewItem ObjectList::add_settings_item(wxDataViewItem parent_item, const DynamicPrintConfig* config)
|
wxDataViewItem ObjectList::add_settings_item(wxDataViewItem parent_item, const DynamicPrintConfig* config)
|
||||||
{
|
{
|
||||||
wxDataViewItem ret = wxDataViewItem(0);
|
wxDataViewItem ret = wxDataViewItem(0);
|
||||||
|
@ -3100,6 +3101,7 @@ bool ObjectList::has_multi_part_objects()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* #lm_FIXME_delete_after_testing
|
||||||
void ObjectList::update_settings_items()
|
void ObjectList::update_settings_items()
|
||||||
{
|
{
|
||||||
m_prevent_canvas_selection_update = true;
|
m_prevent_canvas_selection_update = true;
|
||||||
|
@ -3125,22 +3127,52 @@ void ObjectList::update_settings_items()
|
||||||
SetSelections(sel);
|
SetSelections(sel);
|
||||||
m_prevent_canvas_selection_update = false;
|
m_prevent_canvas_selection_update = false;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
void ObjectList::update_and_show_object_settings_item()
|
||||||
|
{
|
||||||
|
const wxDataViewItem item = GetSelection();
|
||||||
|
if (!item) return;
|
||||||
|
|
||||||
|
const wxDataViewItem& obj_item = m_objects_model->IsSettingsItem(item) ? m_objects_model->GetParent(item) : item;
|
||||||
|
select_item(add_settings_item(obj_item, &get_item_config(obj_item)));
|
||||||
|
}
|
||||||
|
|
||||||
// Update settings item for item had it
|
// Update settings item for item had it
|
||||||
void ObjectList::update_settings_item_and_selection(wxDataViewItem item, wxDataViewItemArray& selections)
|
void ObjectList::update_settings_item_and_selection(wxDataViewItem item, wxDataViewItemArray& selections)
|
||||||
{
|
{
|
||||||
const wxDataViewItem& settings_item = m_objects_model->GetSettingsItem(item);
|
const wxDataViewItem old_settings_item = m_objects_model->GetSettingsItem(item);
|
||||||
select_item(settings_item ? settings_item : m_objects_model->AddSettingsChild(item));
|
const wxDataViewItem new_settings_item = add_settings_item(item, &get_item_config(item));
|
||||||
|
|
||||||
|
if (!new_settings_item && old_settings_item)
|
||||||
|
m_objects_model->Delete(old_settings_item);
|
||||||
|
|
||||||
|
// if ols settings item was is selected area
|
||||||
|
if (selections.Index(old_settings_item) != wxNOT_FOUND)
|
||||||
|
{
|
||||||
|
// If settings item was just updated
|
||||||
|
if (old_settings_item == new_settings_item)
|
||||||
|
{
|
||||||
|
Sidebar& panel = wxGetApp().sidebar();
|
||||||
|
panel.Freeze();
|
||||||
|
|
||||||
|
// update settings list
|
||||||
|
wxGetApp().obj_settings()->UpdateAndShow(true);
|
||||||
|
|
||||||
|
panel.Layout();
|
||||||
|
panel.Thaw();
|
||||||
|
}
|
||||||
|
else
|
||||||
// If settings item was deleted from the list,
|
// If settings item was deleted from the list,
|
||||||
// it's need to be deleted from selection array, if it was there
|
// it's need to be deleted from selection array, if it was there
|
||||||
if (settings_item != m_objects_model->GetSettingsItem(item) &&
|
{
|
||||||
selections.Index(settings_item) != wxNOT_FOUND) {
|
selections.Remove(old_settings_item);
|
||||||
selections.Remove(settings_item);
|
|
||||||
|
|
||||||
// Select item, if settings_item doesn't exist for item anymore, but was selected
|
// Select item, if settings_item doesn't exist for item anymore, but was selected
|
||||||
if (selections.Index(item) == wxNOT_FOUND)
|
if (selections.Index(item) == wxNOT_FOUND) {
|
||||||
selections.Add(item);
|
selections.Add(item);
|
||||||
|
select_item(item); // to correct update of the SettingsList and ManipulationPanel sizers
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -319,6 +319,7 @@ public:
|
||||||
void last_volume_is_deleted(const int obj_idx);
|
void last_volume_is_deleted(const int obj_idx);
|
||||||
bool has_multi_part_objects();
|
bool has_multi_part_objects();
|
||||||
void update_settings_items();
|
void update_settings_items();
|
||||||
|
void update_and_show_object_settings_item();
|
||||||
void update_settings_item_and_selection(wxDataViewItem item, wxDataViewItemArray& selections);
|
void update_settings_item_and_selection(wxDataViewItem item, wxDataViewItemArray& selections);
|
||||||
void update_object_list_by_printer_technology();
|
void update_object_list_by_printer_technology();
|
||||||
void update_object_menu();
|
void update_object_menu();
|
||||||
|
|
|
@ -928,10 +928,12 @@ RENDER_AGAIN:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value_changed) { // Update side panel
|
if (value_changed) { // Update side panel
|
||||||
wxTheApp->CallAfter([]() {
|
/* wxTheApp->CallAfter([]() {
|
||||||
wxGetApp().obj_settings()->UpdateAndShow(true);
|
* wxGetApp().obj_settings()->UpdateAndShow(true);
|
||||||
wxGetApp().obj_list()->update_settings_items();
|
* wxGetApp().obj_list()->update_settings_items();
|
||||||
});
|
* });
|
||||||
|
* #lm_FIXME_delete_after_testing */
|
||||||
|
wxGetApp().obj_list()->update_and_show_object_settings_item();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool generate = m_imgui->button(m_desc.at("auto_generate"));
|
bool generate = m_imgui->button(m_desc.at("auto_generate"));
|
||||||
|
|
Loading…
Reference in a new issue