(Source List) Fix drag-n-drop.
This commit is contained in:
parent
be7ebbb7ba
commit
b409c58ee6
|
@ -1979,7 +1979,8 @@ private:
|
||||||
gint y,
|
gint y,
|
||||||
const Gtk::SelectionData& data,
|
const Gtk::SelectionData& data,
|
||||||
guint info,
|
guint info,
|
||||||
guint time);
|
guint time,
|
||||||
|
bool from_region_list);
|
||||||
|
|
||||||
void drop_routes (
|
void drop_routes (
|
||||||
const Glib::RefPtr<Gdk::DragContext>& context,
|
const Glib::RefPtr<Gdk::DragContext>& context,
|
||||||
|
|
|
@ -249,9 +249,15 @@ Editor::initialize_canvas ()
|
||||||
|
|
||||||
vector<TargetEntry> target_table;
|
vector<TargetEntry> target_table;
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
// Drag-N-Drop from the region list can generate this target
|
// Drag-N-Drop from the region list can generate this target
|
||||||
target_table.push_back (TargetEntry ("regions"));
|
target_table.push_back (TargetEntry ("regions"));
|
||||||
|
|
||||||
|
=======
|
||||||
|
target_table.push_back (TargetEntry ("regions")); // DnD from the region list will generate this target
|
||||||
|
target_table.push_back (TargetEntry ("sources")); // DnD from the source list will generate this target
|
||||||
|
target_table.push_back (TargetEntry ("text/plain"));
|
||||||
|
>>>>>>> Source list: Fix drag-n-drop.
|
||||||
target_table.push_back (TargetEntry ("text/uri-list"));
|
target_table.push_back (TargetEntry ("text/uri-list"));
|
||||||
target_table.push_back (TargetEntry ("text/plain"));
|
target_table.push_back (TargetEntry ("text/plain"));
|
||||||
target_table.push_back (TargetEntry ("application/x-rootwin-drop"));
|
target_table.push_back (TargetEntry ("application/x-rootwin-drop"));
|
||||||
|
@ -376,8 +382,10 @@ Editor::track_canvas_drag_data_received (const RefPtr<Gdk::DragContext>& context
|
||||||
if (!ARDOUR_UI_UTILS::engine_is_running ()) {
|
if (!ARDOUR_UI_UTILS::engine_is_running ()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (data.get_target() == "regions") {
|
if (data.get_target() == X_("regions")) {
|
||||||
drop_regions (context, x, y, data, info, time);
|
drop_regions (context, x, y, data, info, time, true);
|
||||||
|
} else if (data.get_target() == X_("sources")) {
|
||||||
|
drop_regions (context, x, y, data, info, time, false);
|
||||||
} else {
|
} else {
|
||||||
drop_paths (context, x, y, data, info, time);
|
drop_paths (context, x, y, data, info, time);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,8 @@
|
||||||
#include "ardour/audio_track.h"
|
#include "ardour/audio_track.h"
|
||||||
#include "ardour/midi_track.h"
|
#include "ardour/midi_track.h"
|
||||||
#include "ardour/midi_region.h"
|
#include "ardour/midi_region.h"
|
||||||
#include "ardour/region_factory.h"
|
|
||||||
#include "ardour/profile.h"
|
#include "ardour/profile.h"
|
||||||
|
#include "ardour/region_factory.h"
|
||||||
|
|
||||||
#include "canvas/canvas.h"
|
#include "canvas/canvas.h"
|
||||||
#include "canvas/text.h"
|
#include "canvas/text.h"
|
||||||
|
@ -1169,8 +1169,6 @@ Editor::track_canvas_drag_motion (Glib::RefPtr<Gdk::DragContext> const& context,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Paul: DRAGGING: track_canvas_drag_motion\n");
|
|
||||||
|
|
||||||
event.type = GDK_MOTION_NOTIFY;
|
event.type = GDK_MOTION_NOTIFY;
|
||||||
event.button.x = x;
|
event.button.x = x;
|
||||||
event.button.y = y;
|
event.button.y = y;
|
||||||
|
@ -1200,8 +1198,10 @@ printf("Paul: DRAGGING: track_canvas_drag_motion\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (can_drop) {
|
if (can_drop) {
|
||||||
|
|
||||||
|
if (target == X_("regions")) {
|
||||||
region = _regions->get_dragged_region ();
|
region = _regions->get_dragged_region ();
|
||||||
if (!region) {
|
} else if (target == X_("sources")) {
|
||||||
boost::shared_ptr<ARDOUR::Source> src = _sources->get_dragged_source ();
|
boost::shared_ptr<ARDOUR::Source> src = _sources->get_dragged_source ();
|
||||||
region = RegionFactory::get_whole_region_for_source (src);
|
region = RegionFactory::get_whole_region_for_source (src);
|
||||||
}
|
}
|
||||||
|
@ -1261,7 +1261,8 @@ void
|
||||||
Editor::drop_regions (const Glib::RefPtr<Gdk::DragContext>& /*context*/,
|
Editor::drop_regions (const Glib::RefPtr<Gdk::DragContext>& /*context*/,
|
||||||
int x, int y,
|
int x, int y,
|
||||||
const SelectionData& /*data*/,
|
const SelectionData& /*data*/,
|
||||||
guint /*info*/, guint /*time*/)
|
guint /*info*/, guint /*time*/,
|
||||||
|
bool from_region_list)
|
||||||
{
|
{
|
||||||
GdkEvent event;
|
GdkEvent event;
|
||||||
double px;
|
double px;
|
||||||
|
@ -1274,11 +1275,16 @@ Editor::drop_regions (const Glib::RefPtr<Gdk::DragContext>& /*context*/,
|
||||||
event.motion.state = Gdk::BUTTON1_MASK;
|
event.motion.state = Gdk::BUTTON1_MASK;
|
||||||
samplepos_t const pos = window_event_sample (&event, &px, &py);
|
samplepos_t const pos = window_event_sample (&event, &px, &py);
|
||||||
|
|
||||||
boost::shared_ptr<Region> region = _regions->get_dragged_region ();
|
boost::shared_ptr<Region> region;
|
||||||
if (!region) {
|
|
||||||
|
if (from_region_list) {
|
||||||
|
region = _regions->get_dragged_region ();
|
||||||
|
} else {
|
||||||
boost::shared_ptr<ARDOUR::Source> src = _sources->get_dragged_source ();
|
boost::shared_ptr<ARDOUR::Source> src = _sources->get_dragged_source ();
|
||||||
|
if (src) {
|
||||||
region = RegionFactory::get_whole_region_for_source (src);
|
region = RegionFactory::get_whole_region_for_source (src);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!region) { return; }
|
if (!region) { return; }
|
||||||
|
|
||||||
|
@ -1367,4 +1373,3 @@ Editor::key_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType
|
||||||
|
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -173,18 +173,18 @@ EditorSources::EditorSources (Editor* e)
|
||||||
tv_col->set_expand (true);
|
tv_col->set_expand (true);
|
||||||
|
|
||||||
_display.get_selection()->set_mode (SELECTION_MULTIPLE);
|
_display.get_selection()->set_mode (SELECTION_MULTIPLE);
|
||||||
_display.add_object_drag (_columns.source.index(), "regions");
|
_display.add_object_drag (_columns.source.index(), "sources");
|
||||||
_display.set_drag_column (_columns.name.index());
|
_display.set_drag_column (_columns.name.index());
|
||||||
|
|
||||||
/* setup DnD handling */
|
/* setup DnD handling */
|
||||||
|
|
||||||
list<TargetEntry> region_list_target_table;
|
list<TargetEntry> source_list_target_table;
|
||||||
|
|
||||||
region_list_target_table.push_back (TargetEntry ("text/plain"));
|
source_list_target_table.push_back (TargetEntry ("text/plain"));
|
||||||
region_list_target_table.push_back (TargetEntry ("text/uri-list"));
|
source_list_target_table.push_back (TargetEntry ("text/uri-list"));
|
||||||
region_list_target_table.push_back (TargetEntry ("application/x-rootwin-drop"));
|
source_list_target_table.push_back (TargetEntry ("application/x-rootwin-drop"));
|
||||||
|
|
||||||
_display.add_drop_targets (region_list_target_table);
|
_display.add_drop_targets (source_list_target_table);
|
||||||
_display.signal_drag_data_received().connect (sigc::mem_fun(*this, &EditorSources::drag_data_received));
|
_display.signal_drag_data_received().connect (sigc::mem_fun(*this, &EditorSources::drag_data_received));
|
||||||
|
|
||||||
_scroller.add (_display);
|
_scroller.add (_display);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user