Fixed broken DnD on GTK
+ show "Object menu" for each FullInstance instead of FullObject
This commit is contained in:
parent
2c8bc7283e
commit
27f5df5fbd
@ -451,6 +451,8 @@ void ObjectList::OnBeginDrag(wxDataViewEvent &event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_dragged_data.init(m_objects_model->GetObjectIdByItem(item), m_objects_model->GetVolumeIdByItem(item));
|
||||||
|
|
||||||
/* Under MSW or OSX, DnD moves an item to the place of another selected item
|
/* Under MSW or OSX, DnD moves an item to the place of another selected item
|
||||||
* But under GTK, DnD moves an item between another two items.
|
* But under GTK, DnD moves an item between another two items.
|
||||||
* And as a result - call EVT_CHANGE_SELECTION to unselect all items.
|
* And as a result - call EVT_CHANGE_SELECTION to unselect all items.
|
||||||
@ -458,9 +460,13 @@ void ObjectList::OnBeginDrag(wxDataViewEvent &event)
|
|||||||
**/
|
**/
|
||||||
m_prevent_list_events = true;//it's needed for GTK
|
m_prevent_list_events = true;//it's needed for GTK
|
||||||
|
|
||||||
m_dragged_data.init(m_objects_model->GetObjectIdByItem(item), m_objects_model->GetVolumeIdByItem(item));
|
/* Under GTK, DnD requires to the wxTextDataObject been initialized with some valid value,
|
||||||
|
* so set some nonempty string
|
||||||
|
*/
|
||||||
|
wxTextDataObject* obj = new wxTextDataObject;
|
||||||
|
obj->SetText("Some text");//it's needed for GTK
|
||||||
|
|
||||||
event.SetDataObject(new wxTextDataObject);
|
event.SetDataObject(obj);
|
||||||
event.SetDragFlags(wxDrag_DefaultMove); // allows both copy and move;
|
event.SetDragFlags(wxDrag_DefaultMove); // allows both copy and move;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -491,15 +497,16 @@ void ObjectList::OnDrop(wxDataViewEvent &event)
|
|||||||
const int from_volume_id = m_dragged_data.vol_idx();
|
const int from_volume_id = m_dragged_data.vol_idx();
|
||||||
int to_volume_id = m_objects_model->GetVolumeIdByItem(item);
|
int to_volume_id = m_objects_model->GetVolumeIdByItem(item);
|
||||||
|
|
||||||
#ifdef __WXGTK__
|
// It looks like a fixed in current version of the wxWidgets
|
||||||
/* Under GTK, DnD moves an item between another two items.
|
// #ifdef __WXGTK__
|
||||||
* And event.GetItem() return item, which is under "insertion line"
|
// /* Under GTK, DnD moves an item between another two items.
|
||||||
* So, if we move item down we should to decrease the to_volume_id value
|
// * And event.GetItem() return item, which is under "insertion line"
|
||||||
**/
|
// * So, if we move item down we should to decrease the to_volume_id value
|
||||||
if (to_volume_id > from_volume_id) to_volume_id--;
|
// **/
|
||||||
#endif // __WXGTK__
|
// if (to_volume_id > from_volume_id) to_volume_id--;
|
||||||
|
// #endif // __WXGTK__
|
||||||
|
|
||||||
auto& volumes = (*m_objects)[m_selected_object_id]->volumes;
|
auto& volumes = (*m_objects)[/*m_selected_object_id*/m_dragged_data.obj_idx()]->volumes;
|
||||||
auto delta = to_volume_id < from_volume_id ? -1 : 1;
|
auto delta = to_volume_id < from_volume_id ? -1 : 1;
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
for (int id = from_volume_id; cnt < abs(from_volume_id - to_volume_id); id += delta, cnt++)
|
for (int id = from_volume_id; cnt < abs(from_volume_id - to_volume_id); id += delta, cnt++)
|
||||||
@ -509,7 +516,7 @@ void ObjectList::OnDrop(wxDataViewEvent &event)
|
|||||||
m_objects_model->GetParent(item)));
|
m_objects_model->GetParent(item)));
|
||||||
|
|
||||||
m_parts_changed = true;
|
m_parts_changed = true;
|
||||||
parts_changed(m_selected_object_id);
|
parts_changed(/*m_selected_object_id*/m_dragged_data.obj_idx());
|
||||||
|
|
||||||
m_dragged_data.clear();
|
m_dragged_data.clear();
|
||||||
}
|
}
|
||||||
|
@ -2473,7 +2473,8 @@ void Plater::priv::on_right_click(Vec2dEvent& evt)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
wxMenu* menu = printer_technology == ptSLA ? &sla_object_menu :
|
wxMenu* menu = printer_technology == ptSLA ? &sla_object_menu :
|
||||||
get_selection().is_single_full_object() ? &object_menu : &part_menu;
|
get_selection().is_single_full_instance/*object*/() ? // show "Object menu" for each FullInstance instead of FullObject
|
||||||
|
&object_menu : &part_menu;
|
||||||
|
|
||||||
sidebar->obj_list()->append_menu_item_settings(menu);
|
sidebar->obj_list()->append_menu_item_settings(menu);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user