mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-03 12:19:33 +01:00
drag-n-drop to canvas from region list works
git-svn-id: svn://localhost/trunk/ardour2@218 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
d766adcec1
commit
9d44c3b971
4 changed files with 68 additions and 12 deletions
|
|
@ -902,7 +902,7 @@ class Editor : public PublicEditor
|
|||
void amplitude_zoom (gdouble scale);
|
||||
void amplitude_zoom_step (bool in);
|
||||
|
||||
void insert_region_list_drag (ARDOUR::AudioRegion&);
|
||||
void insert_region_list_drag (ARDOUR::AudioRegion&, int x, int y);
|
||||
void insert_region_list_selection (float times);
|
||||
|
||||
void insert_sndfile (bool as_tracks);
|
||||
|
|
@ -1547,6 +1547,20 @@ class Editor : public PublicEditor
|
|||
guint time);
|
||||
|
||||
|
||||
void drop_paths (const Glib::RefPtr<Gdk::DragContext>& context,
|
||||
gint x,
|
||||
gint y,
|
||||
const Gtk::SelectionData& data,
|
||||
guint info,
|
||||
guint time);
|
||||
|
||||
void drop_regions (const Glib::RefPtr<Gdk::DragContext>& context,
|
||||
gint x,
|
||||
gint y,
|
||||
const Gtk::SelectionData& data,
|
||||
guint info,
|
||||
guint time);
|
||||
|
||||
/* audio export */
|
||||
|
||||
ExportDialog *export_dialog;
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@
|
|||
#include <libgnomecanvasmm/init.h>
|
||||
#include <jack/types.h>
|
||||
|
||||
#include <ardour/audioregion.h>
|
||||
|
||||
#include "ardour_ui.h"
|
||||
#include "editor.h"
|
||||
#include "waveview.h"
|
||||
|
|
@ -95,9 +97,12 @@ Editor::initialize_canvas ()
|
|||
track_canvas.signal_leave_notify_event().connect (mem_fun(*this, &Editor::left_track_canvas));
|
||||
|
||||
/* set up drag-n-drop */
|
||||
|
||||
vector<TargetEntry> target_table;
|
||||
|
||||
target_table.push_back (TargetEntry ("STRING"));
|
||||
// Drag-N-Drop from the region list can generate this target
|
||||
target_table.push_back (TargetEntry ("regions"));
|
||||
|
||||
target_table.push_back (TargetEntry ("text/plain"));
|
||||
target_table.push_back (TargetEntry ("text/uri-list"));
|
||||
target_table.push_back (TargetEntry ("application/x-rootwin-drop"));
|
||||
|
|
@ -404,6 +409,19 @@ Editor::track_canvas_drag_data_received (const RefPtr<Gdk::DragContext>& context
|
|||
int x, int y,
|
||||
const SelectionData& data,
|
||||
guint info, guint time)
|
||||
{
|
||||
if (data.get_target() == "regions") {
|
||||
drop_regions (context, x, y, data, info, time);
|
||||
} else {
|
||||
drop_paths (context, x, y, data, info, time);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Editor::drop_paths (const RefPtr<Gdk::DragContext>& context,
|
||||
int x, int y,
|
||||
const SelectionData& data,
|
||||
guint info, guint time)
|
||||
{
|
||||
TimeAxisView* tvp;
|
||||
AudioTimeAxisView* tv;
|
||||
|
|
@ -457,3 +475,23 @@ Editor::track_canvas_drag_data_received (const RefPtr<Gdk::DragContext>& context
|
|||
context->drag_finish (true, false, time);
|
||||
}
|
||||
|
||||
void
|
||||
Editor::drop_regions (const RefPtr<Gdk::DragContext>& context,
|
||||
int x, int y,
|
||||
const SelectionData& data,
|
||||
guint info, guint time)
|
||||
{
|
||||
const DnDTreeView::SerializedObjectPointers* sr = reinterpret_cast<const DnDTreeView::SerializedObjectPointers*> (data.get_data());
|
||||
|
||||
for (uint32_t i = 0; i < sr->cnt; ++i) {
|
||||
|
||||
Region* r = reinterpret_cast<Region*> (sr->ptr[i]);
|
||||
AudioRegion* ar;
|
||||
|
||||
if ((ar = dynamic_cast<AudioRegion*>(r)) != 0) {
|
||||
insert_region_list_drag (*ar, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
context->drag_finish (true, false, time);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1458,9 +1458,8 @@ Editor::clear_locations ()
|
|||
/* INSERT/REPLACE */
|
||||
|
||||
void
|
||||
Editor::insert_region_list_drag (AudioRegion& region)
|
||||
Editor::insert_region_list_drag (AudioRegion& region, int x, int y)
|
||||
{
|
||||
int x, y;
|
||||
double wx, wy;
|
||||
double cx, cy;
|
||||
TimeAxisView *tv;
|
||||
|
|
@ -1468,7 +1467,6 @@ Editor::insert_region_list_drag (AudioRegion& region)
|
|||
AudioTimeAxisView *atv = 0;
|
||||
Playlist *playlist;
|
||||
|
||||
track_canvas.get_pointer (x, y);
|
||||
track_canvas.window_to_world (x, y, wx, wy);
|
||||
|
||||
GdkEvent event;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,19 @@ class DnDTreeView : public Gtk::TreeView
|
|||
public:
|
||||
DnDTreeView ();
|
||||
~DnDTreeView() {}
|
||||
|
||||
/* this is the structure pointed to if add_object_drag() is called
|
||||
and a drop happens on a destination which has declared itself
|
||||
willing to accept a target of the type named in the call
|
||||
to add_object_drag().
|
||||
*/
|
||||
|
||||
struct SerializedObjectPointers {
|
||||
uint32_t size;
|
||||
uint32_t cnt;
|
||||
char type[32];
|
||||
void* ptr[0];
|
||||
};
|
||||
|
||||
void add_drop_targets (std::list<Gtk::TargetEntry>&);
|
||||
void add_object_drag (int column, std::string type_name);
|
||||
|
|
@ -51,13 +64,6 @@ class DnDTreeView : public Gtk::TreeView
|
|||
Gdk::DragAction suggested_action;
|
||||
int data_column;
|
||||
|
||||
struct SerializedObjectPointers {
|
||||
uint32_t size;
|
||||
uint32_t cnt;
|
||||
char type[32];
|
||||
void* ptr[0];
|
||||
};
|
||||
|
||||
SerializedObjectPointers* serialize_pointers (Glib::RefPtr<Gtk::TreeModel> m,
|
||||
Gtk::TreeSelection::ListHandle_Path*,
|
||||
Glib::ustring type);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue