extend Drag/Drop mechanism
DnDVbox: un-hardcode TargetEntry list, add callback for secondary targets DvDTreeview: return pointer to self
This commit is contained in:
parent
b67892833b
commit
2a55e8b9b3
@ -104,12 +104,11 @@ class /*LIBGTKMM2EXT_API*/ DnDTreeView : public DnDTreeViewBase
|
|||||||
|
|
||||||
} else if (selection_data.get_target() == object_type) {
|
} else if (selection_data.get_target() == object_type) {
|
||||||
|
|
||||||
/* we don't care about the data passed around by DnD, but
|
/* return a pointer to this object, which allows
|
||||||
we have to provide something otherwise it will stop.
|
* the receiver to call on_drag_data_received()
|
||||||
*/
|
*/
|
||||||
|
void *c = this;
|
||||||
guchar c;
|
selection_data.set (8, (guchar*)&c, sizeof(void*));
|
||||||
selection_data.set (8, (guchar*)&c, 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +141,7 @@ class /*LIBGTKMM2EXT_API*/ DnDTreeView : public DnDTreeViewBase
|
|||||||
* object that wants to get the list of dragged items.
|
* object that wants to get the list of dragged items.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void get_object_drag_data (std::list<DataType>& l, Gtk::TreeView** source) {
|
void get_object_drag_data (std::list<DataType>& l, Gtk::TreeView** source) const {
|
||||||
|
|
||||||
if (drag_data.source == 0) {
|
if (drag_data.source == 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -51,9 +51,13 @@ template <class T>
|
|||||||
class /*LIBGTKMM2EXT_API*/ DnDVBox : public Gtk::EventBox
|
class /*LIBGTKMM2EXT_API*/ DnDVBox : public Gtk::EventBox
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DnDVBox () : _active (0), _drag_icon (0), _expecting_unwanted_button_event (false), _placeholder (0)
|
DnDVBox (std::list<Gtk::TargetEntry> targets)
|
||||||
|
: _targets (targets)
|
||||||
|
, _active (0)
|
||||||
|
, _drag_icon (0)
|
||||||
|
, _expecting_unwanted_button_event (false)
|
||||||
|
, _placeholder (0)
|
||||||
{
|
{
|
||||||
_targets.push_back (Gtk::TargetEntry ("processor"));
|
|
||||||
|
|
||||||
add (_internal_vbox);
|
add (_internal_vbox);
|
||||||
add_events (
|
add_events (
|
||||||
@ -220,6 +224,7 @@ public:
|
|||||||
* Parameters are the source DnDVBox, our child which the other one was dropped on (or 0) and the DragContext.
|
* Parameters are the source DnDVBox, our child which the other one was dropped on (or 0) and the DragContext.
|
||||||
*/
|
*/
|
||||||
sigc::signal<void, DnDVBox*, T*, Glib::RefPtr<Gdk::DragContext> const & > DropFromAnotherBox;
|
sigc::signal<void, DnDVBox*, T*, Glib::RefPtr<Gdk::DragContext> const & > DropFromAnotherBox;
|
||||||
|
sigc::signal<void, Gtk::SelectionData const &, T*, Glib::RefPtr<Gdk::DragContext> const & > DropFromExternal;
|
||||||
sigc::signal<void> SelectionChanged;
|
sigc::signal<void> SelectionChanged;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -352,6 +357,12 @@ private:
|
|||||||
/* work out where it was dropped */
|
/* work out where it was dropped */
|
||||||
std::pair<T*, double> const drop = get_child_at_position (y);
|
std::pair<T*, double> const drop = get_child_at_position (y);
|
||||||
|
|
||||||
|
if (selection_data.get_target () != _targets.front ().get_target ()) {
|
||||||
|
DropFromExternal (selection_data, drop.first, context);
|
||||||
|
context->drag_finish (false, false, time);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (_drag_source == this) {
|
if (_drag_source == this) {
|
||||||
|
|
||||||
/* dropped from ourselves onto ourselves */
|
/* dropped from ourselves onto ourselves */
|
||||||
|
Loading…
Reference in New Issue
Block a user