mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-08 15:54:57 +01:00
Highlight Drop Trigger Slot
This commit is contained in:
parent
5f810843bb
commit
fde1b3d27e
2 changed files with 56 additions and 3 deletions
|
|
@ -330,6 +330,8 @@ TriggerBoxUI::TriggerBoxUI (ArdourCanvas::Item* parent, TriggerBox& tb)
|
||||||
GtkCanvas* gtkcanvas = static_cast<GtkCanvas*> (canvas());
|
GtkCanvas* gtkcanvas = static_cast<GtkCanvas*> (canvas());
|
||||||
assert (gtkcanvas);
|
assert (gtkcanvas);
|
||||||
gtkcanvas->drag_dest_set (target_table);
|
gtkcanvas->drag_dest_set (target_table);
|
||||||
|
gtkcanvas->signal_drag_motion().connect (sigc::mem_fun(*this, &TriggerBoxUI::drag_motion));
|
||||||
|
gtkcanvas->signal_drag_leave().connect (sigc::mem_fun(*this, &TriggerBoxUI::drag_leave));
|
||||||
gtkcanvas->signal_drag_data_received().connect (sigc::mem_fun(*this, &TriggerBoxUI::drag_data_received));
|
gtkcanvas->signal_drag_data_received().connect (sigc::mem_fun(*this, &TriggerBoxUI::drag_data_received));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -744,17 +746,64 @@ TriggerBoxUI::sample_chosen (int response, uint64_t n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
uint64_t
|
||||||
TriggerBoxUI::drag_data_received (Glib::RefPtr<Gdk::DragContext> const& context, int /*x*/, int y, Gtk::SelectionData const& data, guint /*info*/, guint time)
|
TriggerBoxUI::slot_at_y (int y) const
|
||||||
{
|
{
|
||||||
uint64_t n = 0; // TODO pick slot depending in Y coordinate
|
uint64_t n = 0;
|
||||||
for (auto& slot : _slots) {
|
for (auto& slot : _slots) {
|
||||||
if (slot->height () < y) {
|
if (slot->height () < y) {
|
||||||
++n;
|
++n;
|
||||||
y -= slot->height ();
|
y -= slot->height ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
TriggerBoxUI::drag_motion (Glib::RefPtr<Gdk::DragContext>const& context, int, int y, guint time)
|
||||||
|
{
|
||||||
|
bool can_drop = true;
|
||||||
|
uint64_t n = slot_at_y (y);
|
||||||
|
if (n >= _slots.size ()) {
|
||||||
|
assert (0);
|
||||||
|
can_drop = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (can_drop) {
|
||||||
|
context->drag_status(Gdk::ACTION_COPY, time);
|
||||||
|
/* prelight */
|
||||||
|
GdkEventCrossing ev;
|
||||||
|
ev.detail = GDK_NOTIFY_ANCESTOR;
|
||||||
|
for (size_t i = 0; i < _slots.size (); ++i) {
|
||||||
|
ev.type = (i == n) ? GDK_ENTER_NOTIFY : GDK_LEAVE_NOTIFY;
|
||||||
|
text_button_event ((GdkEvent*)&ev, i);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
context->drag_status (Gdk::DragAction (0), time);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TriggerBoxUI::drag_leave (Glib::RefPtr<Gdk::DragContext>const&, guint)
|
||||||
|
{
|
||||||
|
GdkEventCrossing ev;
|
||||||
|
ev.type = GDK_LEAVE_NOTIFY;
|
||||||
|
ev.detail = GDK_NOTIFY_ANCESTOR;
|
||||||
|
for (size_t i = 0; i < _slots.size (); ++i) {
|
||||||
|
text_button_event ((GdkEvent*)&ev, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TriggerBoxUI::drag_data_received (Glib::RefPtr<Gdk::DragContext> const& context, int /*x*/, int y, Gtk::SelectionData const& data, guint /*info*/, guint time)
|
||||||
|
{
|
||||||
|
uint64_t n = slot_at_y (y);
|
||||||
|
if (n >= _slots.size ()) {
|
||||||
|
context->drag_finish (false, false, time);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (data.get_target() == X_("regions")) {
|
if (data.get_target() == X_("regions")) {
|
||||||
#if 0
|
#if 0
|
||||||
/* TODO -- get access to Editor::_regions */
|
/* TODO -- get access to Editor::_regions */
|
||||||
|
|
|
||||||
|
|
@ -131,8 +131,12 @@ private:
|
||||||
|
|
||||||
void selection_changed ();
|
void selection_changed ();
|
||||||
|
|
||||||
|
bool drag_motion (Glib::RefPtr<Gdk::DragContext>const&, int, int, guint);
|
||||||
|
void drag_leave (Glib::RefPtr<Gdk::DragContext>const&, guint);
|
||||||
void drag_data_received (Glib::RefPtr<Gdk::DragContext> const&, int, int, Gtk::SelectionData const&, guint, guint);
|
void drag_data_received (Glib::RefPtr<Gdk::DragContext> const&, int, int, Gtk::SelectionData const&, guint, guint);
|
||||||
|
|
||||||
|
uint64_t slot_at_y (int) const;
|
||||||
|
|
||||||
sigc::connection update_connection;
|
sigc::connection update_connection;
|
||||||
sigc::connection selection_connection;
|
sigc::connection selection_connection;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue