X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_canvas_events.cc;h=acf00fdfdbdd5d82d7d6fdf767ed6b14887df4ca;hb=46bbe834009d51a652e03a7fd4fa57bfb6457e38;hp=e821254c9b5f78150430ca1880db6ba04d7f8f86;hpb=6ba6cce79905ea1fa831ca7525c16ca1878623a7;p=ardour.git diff --git a/gtk2_ardour/editor_canvas_events.cc b/gtk2_ardour/editor_canvas_events.cc index e821254c9b..acf00fdfdb 100644 --- a/gtk2_ardour/editor_canvas_events.cc +++ b/gtk2_ardour/editor_canvas_events.cc @@ -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 + * Copyright (C) 2005 Taybin Rutkin + * Copyright (C) 2006-2012 David Robillard + * Copyright (C) 2008 Hans Baier + * Copyright (C) 2009-2012 Carl Hetherington + * Copyright (C) 2013-2019 Robin Gareus + * Copyright (C) 2015-2016 Tim Mayberry + * Copyright (C) 2015-2017 Nick Mainsbridge + * Copyright (C) 2015-2019 Ben Loftis + * + * 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 #include @@ -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,10 +55,11 @@ #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" -#include "i18n.h" +#include "pbd/i18n.h" using namespace std; using namespace ARDOUR; @@ -75,8 +83,11 @@ Editor::track_canvas_scroll (GdkEventScroll* ev) switch (direction) { case GDK_SCROLL_UP: if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollZoomHorizontalModifier)) { - //for mouse-wheel zoom, force zoom-focus to mouse - temporal_zoom_step_mouse_focus (false); + if (UIConfiguration::instance().get_use_mouse_position_as_zoom_focus_on_scroll()) { + temporal_zoom_step_mouse_focus (false); + } else { + temporal_zoom_step (false); + } return true; } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollHorizontalModifier)) { scroll_left_step (); @@ -101,8 +112,11 @@ Editor::track_canvas_scroll (GdkEventScroll* ev) case GDK_SCROLL_DOWN: if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollZoomHorizontalModifier)) { - //for mouse-wheel zoom, force zoom-focus to mouse - temporal_zoom_step_mouse_focus (true); + if (UIConfiguration::instance().get_use_mouse_position_as_zoom_focus_on_scroll()) { + temporal_zoom_step_mouse_focus (true); + } else { + temporal_zoom_step (true); + } return true; } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollHorizontalModifier)) { scroll_right_step (); @@ -165,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; } @@ -173,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; } @@ -192,6 +206,10 @@ Editor::track_canvas_motion_notify_event (GdkEventMotion */*event*/) bool Editor::typed_event (ArdourCanvas::Item* item, GdkEvent *event, ItemType type) { + if (!session () || session()->loading () || session()->deletion_in_progress ()) { + return false; + } + gint ret = FALSE; switch (event->type) { @@ -526,7 +544,6 @@ Editor::canvas_fade_in_handle_event (GdkEvent *event, ArdourCanvas::Item* item, case GDK_BUTTON_RELEASE: ret = button_release_handler (item, event, trim ? FadeInTrimHandleItem : FadeInHandleItem); - maybe_locate_with_edit_preroll ( rv->region()->position() ); break; case GDK_MOTION_NOTIFY: @@ -610,7 +627,6 @@ Editor::canvas_fade_out_handle_event (GdkEvent *event, ArdourCanvas::Item* item, case GDK_BUTTON_RELEASE: ret = button_release_handler (item, event, trim ? FadeOutTrimHandleItem : FadeOutHandleItem); - maybe_locate_with_edit_preroll ( rv->region()->last_frame() - rv->get_fade_out_shape_width() ); break; case GDK_MOTION_NOTIFY: @@ -633,9 +649,9 @@ Editor::canvas_fade_out_handle_event (GdkEvent *event, ArdourCanvas::Item* item, } struct DescendingRegionLayerSorter { - bool operator()(boost::shared_ptr a, boost::shared_ptr b) { - return a->layer() > b->layer(); - } + bool operator()(boost::shared_ptr a, boost::shared_ptr b) { + return a->layer() > b->layer(); + } }; bool @@ -671,10 +687,14 @@ Editor::canvas_line_event (GdkEvent *event, ArdourCanvas::Item* item, Automation AudioRegionGainLine* gl; if ((gl = dynamic_cast (al)) != 0) { type = GainLineItem; - clicked_regionview = &gl->region_view (); + if (event->type == GDK_BUTTON_PRESS) { + clicked_regionview = &gl->region_view (); + } } else { type = AutomationLineItem; - clicked_regionview = 0; + if (event->type == GDK_BUTTON_PRESS) { + clicked_regionview = 0; + } } clicked_control_point = 0; @@ -998,11 +1018,17 @@ Editor::canvas_videotl_bar_event (GdkEvent *event, ArdourCanvas::Item* item) } bool -Editor::canvas_tempo_marker_event (GdkEvent *event, ArdourCanvas::Item* item, TempoMarker* /*marker*/) +Editor::canvas_tempo_marker_event (GdkEvent *event, ArdourCanvas::Item* item, TempoMarker* marker) { return typed_event (item, event, TempoMarkerItem); } +bool +Editor::canvas_tempo_curve_event (GdkEvent *event, ArdourCanvas::Item* item, TempoCurve* /*marker*/) +{ + return typed_event (item, event, TempoCurveItem); +} + bool Editor::canvas_meter_marker_event (GdkEvent *event, ArdourCanvas::Item* item, MeterMarker* /*marker*/) { @@ -1024,9 +1050,8 @@ Editor::canvas_ruler_event (GdkEvent *event, ArdourCanvas::Item* item, ItemType case GDK_SCROLL_UP: if (Keyboard::modifier_state_equals(event->scroll.state, Keyboard::ScrollHorizontalModifier)) { - scroll_left_half_page (); - } else if (Profile->get_mixbus()) { - //for mouse-wheel zoom, force zoom-focus to mouse + scroll_left_step (); + } else if (UIConfiguration::instance().get_use_mouse_position_as_zoom_focus_on_scroll()) { temporal_zoom_step_mouse_focus (false); } else { temporal_zoom_step (false); @@ -1037,9 +1062,8 @@ Editor::canvas_ruler_event (GdkEvent *event, ArdourCanvas::Item* item, ItemType case GDK_SCROLL_DOWN: if (Keyboard::modifier_state_equals(event->scroll.state, Keyboard::ScrollHorizontalModifier)) { - scroll_right_half_page (); - } else if (Profile->get_mixbus()) { - //for mouse-wheel zoom, force zoom-focus to mouse + scroll_right_step (); + } else if (UIConfiguration::instance().get_use_mouse_position_as_zoom_focus_on_scroll()) { temporal_zoom_step_mouse_focus (true); } else { temporal_zoom_step (true); @@ -1180,14 +1204,17 @@ Editor::track_canvas_drag_motion (Glib::RefPtr 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 (region) != 0 || - boost::dynamic_pointer_cast (region) != 0 + boost::dynamic_pointer_cast (region) != 0 || + boost::dynamic_pointer_cast (region) != 0 ) ) { @@ -1215,7 +1242,7 @@ Editor::track_canvas_drag_motion (Glib::RefPtr const& context, * TODO: check if file is audio/midi, allow drops on same track-type only, * currently: if audio is dropped on a midi-track, it is only added to the region-list */ - if (Profile->get_sae() || UIConfiguration::instance().get_only_copy_imported_files()) { + if (UIConfiguration::instance().get_only_copy_imported_files()) { context->drag_status(Gdk::ACTION_COPY, time); } else { if ((context->get_actions() & (Gdk::ACTION_COPY | Gdk::ACTION_LINK | Gdk::ACTION_MOVE)) == Gdk::ACTION_COPY) { @@ -1235,9 +1262,10 @@ Editor::track_canvas_drag_motion (Glib::RefPtr const& context, void Editor::drop_regions (const Glib::RefPtr& /*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; @@ -1248,9 +1276,16 @@ Editor::drop_regions (const Glib::RefPtr& /*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; + + if (from_region_list) { + region = _regions->get_dragged_region (); + } else { + region = _sources->get_dragged_region (); + } - boost::shared_ptr region = _regions->get_dragged_region (); if (!region) { return; } RouteTimeAxisView* rtav = 0; @@ -1266,13 +1301,17 @@ Editor::drop_regions (const Glib::RefPtr& /*context*/, output_chan = session()->master_out()->n_inputs().n_audio(); } list > audio_tracks; - audio_tracks = session()->new_audio_track (region->n_channels(), output_chan, ARDOUR::Normal, 0, 1, region->name()); - rtav = axis_view_from_route (audio_tracks.front()); + audio_tracks = session()->new_audio_track (region->n_channels(), output_chan, 0, 1, region->name(), PresentationInfo::max_order); + rtav = dynamic_cast (time_axis_view_from_stripable (audio_tracks.front())); } else if (boost::dynamic_pointer_cast (region)) { ChanCount one_midi_port (DataType::MIDI, 1); list > midi_tracks; - midi_tracks = session()->new_midi_track (one_midi_port, one_midi_port, boost::shared_ptr(), ARDOUR::Normal, 0, 1, region->name()); - rtav = axis_view_from_route (midi_tracks.front()); + midi_tracks = session()->new_midi_track (one_midi_port, one_midi_port, + Config->get_strict_io () || Profile->get_mixbus (), + boost::shared_ptr(), + (ARDOUR::Plugin::PresetRecord*) 0, + (ARDOUR::RouteGroup*) 0, 1, region->name(), PresentationInfo::max_order); + rtav = dynamic_cast (time_axis_view_from_stripable (midi_tracks.front())); } else { return; } @@ -1288,7 +1327,7 @@ Editor::drop_regions (const Glib::RefPtr& /*context*/, if ((boost::dynamic_pointer_cast (region_copy) != 0 && dynamic_cast (rtav) != 0) || (boost::dynamic_pointer_cast (region_copy) != 0 && dynamic_cast (rtav) != 0)) { _drags->set (new RegionInsertDrag (this, region_copy, rtav, pos), &event); - _drags->end_grab (0); + _drags->end_grab (&event); } } } @@ -1334,4 +1373,3 @@ Editor::key_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType return handled; } -