Fix formatting samplecnt_t (aka int64_t aka long long int)
[ardour.git] / gtk2_ardour / editor_canvas_events.cc
index dc23d699573305f2fc067b318ed95cad22537549..acf00fdfdbdd5d82d7d6fdf767ed6b14887df4ca 100644 (file)
@@ -1,21 +1,28 @@
 /*
-    Copyright (C) 2000 Paul Davis
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
+ * Copyright (C) 2005-2018 Paul Davis <paul@linuxaudiosystems.com>
+ * Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com>
+ * Copyright (C) 2006-2012 David Robillard <d@drobilla.net>
+ * Copyright (C) 2008 Hans Baier <hansfbaier@googlemail.com>
+ * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
+ * Copyright (C) 2013-2019 Robin Gareus <robin@gareus.org>
+ * Copyright (C) 2015-2016 Tim Mayberry <mojofunk@gmail.com>
+ * Copyright (C) 2015-2017 Nick Mainsbridge <mainsbridge@gmail.com>
+ * Copyright (C) 2015-2019 Ben Loftis <ben@harrisonconsoles.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
 
 #include <cstdlib>
 #include <cmath>
@@ -27,8 +34,8 @@
 #include "ardour/audio_track.h"
 #include "ardour/midi_track.h"
 #include "ardour/midi_region.h"
-#include "ardour/region_factory.h"
 #include "ardour/profile.h"
+#include "ardour/region_factory.h"
 
 #include "canvas/canvas.h"
 #include "canvas/text.h"
@@ -1115,7 +1122,6 @@ Editor::canvas_note_event (GdkEvent *event, ArdourCanvas::Item* item)
 bool
 Editor::canvas_drop_zone_event (GdkEvent* event)
 {
-printf("canvas_drop_zone_event\n");
        GdkEventScroll scroll;
        ArdourCanvas::Duple winpos;
 
@@ -1169,8 +1175,6 @@ Editor::track_canvas_drag_motion (Glib::RefPtr<Gdk::DragContext> const& context,
                return false;
        }
 
-printf("Paul:  DRAGGING:  track_canvas_drag_motion\n");
-
        event.type = GDK_MOTION_NOTIFY;
        event.button.x = x;
        event.button.y = y;
@@ -1200,10 +1204,9 @@ printf("Paul:  DRAGGING:  track_canvas_drag_motion\n");
        }
 
        if (can_drop) {
-               region = _regions->get_dragged_region ();
-               if (!region) {
-                       boost::shared_ptr<ARDOUR::Source> src = _sources->get_dragged_source ();
-                       region = RegionFactory::get_whole_region_for_source (src);
+
+               if (target == X_("regions")) {
+                       region = _regions->get_dragged_region ();
                }
 
                if (region) {
@@ -1261,7 +1264,8 @@ void
 Editor::drop_regions (const Glib::RefPtr<Gdk::DragContext>& /*context*/,
                       int x, int y,
                       const SelectionData& /*data*/,
-                      guint /*info*/, guint /*time*/)
+                      guint /*info*/, guint /*time*/,
+                      bool from_region_list)
 {
        GdkEvent event;
        double px;
@@ -1274,10 +1278,12 @@ Editor::drop_regions (const Glib::RefPtr<Gdk::DragContext>& /*context*/,
        event.motion.state = Gdk::BUTTON1_MASK;
        samplepos_t const pos = window_event_sample (&event, &px, &py);
 
-       boost::shared_ptr<Region> region = _regions->get_dragged_region ();
-       if (!region) {
-               boost::shared_ptr<ARDOUR::Source> src = _sources->get_dragged_source ();
-               region = RegionFactory::get_whole_region_for_source (src);
+       boost::shared_ptr<Region> region;
+
+       if (from_region_list) {
+               region = _regions->get_dragged_region ();
+       } else {
+               region = _sources->get_dragged_region ();
        }
 
        if (!region) { return; }
@@ -1367,4 +1373,3 @@ Editor::key_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType
 
        return handled;
 }
-