mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Drag&Drop test on Linux and OSX
This commit is contained in:
parent
9df6804835
commit
73ba96381e
2 changed files with 64 additions and 0 deletions
|
@ -323,6 +323,9 @@ wxBoxSizer* content_objects_list(wxWindow *win)
|
||||||
});
|
});
|
||||||
#endif //__WXMSW__
|
#endif //__WXMSW__
|
||||||
|
|
||||||
|
m_objects_ctrl->Bind(wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, [](wxDataViewEvent& e) {on_begin_drag(e);});
|
||||||
|
m_objects_ctrl->Bind(wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE, [](wxDataViewEvent& e) {on_drop_possible(e); });
|
||||||
|
m_objects_ctrl->Bind(wxEVT_DATAVIEW_ITEM_DROP, [](wxDataViewEvent& e) {on_drop(e);});
|
||||||
return objects_sz;
|
return objects_sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1528,5 +1531,61 @@ void update_rotation_value(const double angle, const std::string& axis)
|
||||||
og->set_value("rotation_"+axis, deg);
|
og->set_value("rotation_"+axis, deg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void on_begin_drag(wxDataViewEvent &event)
|
||||||
|
{
|
||||||
|
wxDataViewItem item(event.GetItem());
|
||||||
|
|
||||||
|
// only allow drags for item, not containers
|
||||||
|
if (m_objects_model->GetParent(item) == wxDataViewItem(0))
|
||||||
|
{
|
||||||
|
event.Veto();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PrusaObjectDataViewModelNode *node = (PrusaObjectDataViewModelNode*)item.GetID();
|
||||||
|
wxTextDataObject *obj = new wxTextDataObject;
|
||||||
|
obj->SetText(node->m_name);
|
||||||
|
event.SetDataObject(obj);
|
||||||
|
event.SetDragFlags(wxDrag_AllowMove); // allows both copy and move;
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_drop_possible(wxDataViewEvent &event)
|
||||||
|
{
|
||||||
|
wxDataViewItem item(event.GetItem());
|
||||||
|
|
||||||
|
// only allow drags for item or background, not containers
|
||||||
|
if (item.IsOk() && m_objects_model->GetParent(item) == wxDataViewItem(0))
|
||||||
|
event.Veto();
|
||||||
|
|
||||||
|
if (event.GetDataFormat() != wxDF_UNICODETEXT)
|
||||||
|
event.Veto();
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_drop(wxDataViewEvent &event)
|
||||||
|
{
|
||||||
|
wxDataViewItem item(event.GetItem());
|
||||||
|
|
||||||
|
// only allow drops for item, not containers
|
||||||
|
if (item.IsOk() && m_objects_model->GetParent(item) == wxDataViewItem(0))
|
||||||
|
{
|
||||||
|
event.Veto();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.GetDataFormat() != wxDF_UNICODETEXT)
|
||||||
|
{
|
||||||
|
event.Veto();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxTextDataObject obj;
|
||||||
|
obj.SetData(wxDF_UNICODETEXT, event.GetDataSize(), event.GetDataBuffer());
|
||||||
|
|
||||||
|
if (item.IsOk())
|
||||||
|
wxMessageBox(wxString::Format("Text dropped on item %s: %s", m_objects_model->GetName(item), obj.GetText()));
|
||||||
|
else
|
||||||
|
wxMessageBox(wxString::Format("Text dropped on background: %s", obj.GetText()));
|
||||||
|
}
|
||||||
|
|
||||||
} //namespace GUI
|
} //namespace GUI
|
||||||
} //namespace Slic3r
|
} //namespace Slic3r
|
|
@ -7,6 +7,7 @@ class wxBoxSizer;
|
||||||
class wxString;
|
class wxString;
|
||||||
class wxArrayString;
|
class wxArrayString;
|
||||||
class wxMenu;
|
class wxMenu;
|
||||||
|
class wxDataViewEvent;
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
class ModelObject;
|
class ModelObject;
|
||||||
|
@ -109,6 +110,10 @@ void update_rotation_values();
|
||||||
// update rotation value after "gizmos"
|
// update rotation value after "gizmos"
|
||||||
void update_rotation_value(const double angle, const std::string& axis);
|
void update_rotation_value(const double angle, const std::string& axis);
|
||||||
|
|
||||||
|
void on_begin_drag(wxDataViewEvent &event);
|
||||||
|
void on_drop_possible(wxDataViewEvent &event);
|
||||||
|
void on_drop(wxDataViewEvent &event);
|
||||||
|
|
||||||
} //namespace GUI
|
} //namespace GUI
|
||||||
} //namespace Slic3r
|
} //namespace Slic3r
|
||||||
#endif //slic3r_GUI_ObjectParts_hpp_
|
#endif //slic3r_GUI_ObjectParts_hpp_
|
Loading…
Add table
Add a link
Reference in a new issue