Preferences/Config changes for image-surface settings
[ardour.git] / gtk2_ardour / editor_canvas_events.cc
index 132f6f870b931f0644a3b6644763c84a36d01e18..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"
@@ -48,6 +55,7 @@
 #include "editor_drag.h"
 #include "midi_time_axis.h"
 #include "editor_regions.h"
+#include "editor_sources.h"
 #include "ui_config.h"
 #include "verbose_cursor.h"
 
@@ -171,7 +179,7 @@ Editor::track_canvas_button_press_event (GdkEventButton *event)
                begin_reversible_selection_op (X_("Clear Selection Click (track canvas)"));
                selection->clear ();
                commit_reversible_selection_op();
-        }
+       }
        return false;
 }
 
@@ -179,10 +187,10 @@ bool
 Editor::track_canvas_button_release_event (GdkEventButton *event)
 {
        if (!Keyboard::is_context_menu_event (event)) {
-                if (_drags->active ()) {
-                        _drags->end_grab ((GdkEvent*) event);
-                }
-        }
+               if (_drags->active ()) {
+                       _drags->end_grab ((GdkEvent*) event);
+               }
+       }
        return false;
 }
 
@@ -641,9 +649,9 @@ Editor::canvas_fade_out_handle_event (GdkEvent *event, ArdourCanvas::Item* item,
 }
 
 struct DescendingRegionLayerSorter {
-    bool operator()(boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) {
-           return a->layer() > b->layer();
-    }
+       bool operator()(boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) {
+               return a->layer() > b->layer();
+       }
 };
 
 bool
@@ -1080,18 +1088,6 @@ Editor::canvas_ruler_event (GdkEvent *event, ArdourCanvas::Item* item, ItemType
                return handled;
        }
 
-       switch (event->type) {
-       case GDK_BUTTON_PRESS:
-               if (UIConfiguration::instance ().get_use_time_rulers_to_zoom_with_vertical_drag () &&
-                   Keyboard::no_modifier_keys_pressed (&event->button) && event->button.button == 1) {
-                       _drags->set(new RulerZoomDrag(this, item), event);
-                       return true;
-               }
-               break;
-       default:
-               break;
-       }
-
        return typed_event (item, event, type);
 }
 
@@ -1208,14 +1204,17 @@ Editor::track_canvas_drag_motion (Glib::RefPtr<Gdk::DragContext> const& context,
        }
 
        if (can_drop) {
-               region = _regions->get_dragged_region ();
+
+               if (target == X_("regions")) {
+                       region = _regions->get_dragged_region ();
+               }
 
                if (region) {
 
                        if (tv.first == 0
                            && (
-                               boost::dynamic_pointer_cast<AudioRegion> (region) != 0 ||
-                               boost::dynamic_pointer_cast<MidiRegion> (region) != 0
+                               boost::dynamic_pointer_cast<AudioRegion> (region) != 0 ||
+                               boost::dynamic_pointer_cast<MidiRegion> (region) != 0
                               )
                           )
                        {
@@ -1263,9 +1262,10 @@ Editor::track_canvas_drag_motion (Glib::RefPtr<Gdk::DragContext> const& context,
 
 void
 Editor::drop_regions (const Glib::RefPtr<Gdk::DragContext>& /*context*/,
-                     int x, int y,
-                     const SelectionData& /*data*/,
-                     guint /*info*/, guint /*time*/)
+                      int x, int y,
+                      const SelectionData& /*data*/,
+                      guint /*info*/, guint /*time*/,
+                      bool from_region_list)
 {
        GdkEvent event;
        double px;
@@ -1276,9 +1276,16 @@ Editor::drop_regions (const Glib::RefPtr<Gdk::DragContext>& /*context*/,
        event.button.y = y;
        /* assume we're dragging with button 1 */
        event.motion.state = Gdk::BUTTON1_MASK;
-       framepos_t const pos = window_event_sample (&event, &px, &py);
+       samplepos_t const pos = window_event_sample (&event, &px, &py);
+
+       boost::shared_ptr<Region> region;
+
+       if (from_region_list) {
+               region = _regions->get_dragged_region ();
+       } else {
+               region = _sources->get_dragged_region ();
+       }
 
-       boost::shared_ptr<Region> region = _regions->get_dragged_region ();
        if (!region) { return; }
 
        RouteTimeAxisView* rtav = 0;
@@ -1295,7 +1302,7 @@ Editor::drop_regions (const Glib::RefPtr<Gdk::DragContext>& /*context*/,
                                }
                                list<boost::shared_ptr<AudioTrack> > audio_tracks;
                                audio_tracks = session()->new_audio_track (region->n_channels(), output_chan, 0, 1, region->name(), PresentationInfo::max_order);
-                               rtav = dynamic_cast<RouteTimeAxisView*> (axis_view_from_stripable (audio_tracks.front()));
+                               rtav = dynamic_cast<RouteTimeAxisView*> (time_axis_view_from_stripable (audio_tracks.front()));
                        } else if (boost::dynamic_pointer_cast<MidiRegion> (region)) {
                                ChanCount one_midi_port (DataType::MIDI, 1);
                                list<boost::shared_ptr<MidiTrack> > midi_tracks;
@@ -1304,7 +1311,7 @@ Editor::drop_regions (const Glib::RefPtr<Gdk::DragContext>& /*context*/,
                                                                         boost::shared_ptr<ARDOUR::PluginInfo>(),
                                                                         (ARDOUR::Plugin::PresetRecord*) 0,
                                                                         (ARDOUR::RouteGroup*) 0, 1, region->name(), PresentationInfo::max_order);
-                               rtav = dynamic_cast<RouteTimeAxisView*> (axis_view_from_stripable (midi_tracks.front()));
+                               rtav = dynamic_cast<RouteTimeAxisView*> (time_axis_view_from_stripable (midi_tracks.front()));
                        } else {
                                return;
                        }
@@ -1366,4 +1373,3 @@ Editor::key_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType
 
        return handled;
 }
-