2 * Copyright (C) 2005-2017 Paul Davis <paul@linuxaudiosystems.com>
3 * Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com>
4 * Copyright (C) 2006-2012 David Robillard <d@drobilla.net>
5 * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
6 * Copyright (C) 2014-2018 Ben Loftis <ben@harrisonconsoles.com>
7 * Copyright (C) 2015-2016 Robin Gareus <robin@gareus.org>
8 * Copyright (C) 2016-2017 Nick Mainsbridge <mainsbridge@gmail.com>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include <gtkmm/treeview.h>
31 #include "pbd/error.h"
33 #include "ardour/session.h"
36 #include "region_view.h"
37 #include "selection.h"
38 #include "time_axis_view.h"
42 using namespace ARDOUR;
44 using namespace Editing;
47 Editor::keyboard_selection_finish (bool /*add*/, Editing::EditIgnoreOption ign)
51 MusicSample start (selection->time.start(), 0);
53 if ((_edit_point == EditAtPlayhead) && _session->transport_rolling()) {
54 end = _session->audible_sample();
56 end = get_preferred_edit_position(ign);
59 //if no tracks are selected and we're working from the keyboard, enable all tracks (_something_ has to be selected for any range selection)
60 if ( (_edit_point == EditAtPlayhead) && selection->tracks.empty() )
63 selection->set (start.sample, end);
65 //if session is playing a range, cancel that
66 if (_session->get_play_range())
67 _session->request_cancel_play_range();
73 Editor::keyboard_selection_begin (Editing::EditIgnoreOption ign)
77 MusicSample start (0, 0);
78 MusicSample end (selection->time.end_sample(), 0);
79 if ((_edit_point == EditAtPlayhead) && _session->transport_rolling()) {
80 start.sample = _session->audible_sample();
82 start.sample = get_preferred_edit_position(ign);
85 //if there's not already a sensible selection endpoint, go "forever"
86 if (start.sample > end.sample) {
89 // This works around a visual glitch in red-bordered selection rect.
90 end.sample = start.sample + _session->nominal_sample_rate() * 60 * 60 * 4;
92 end.sample = max_samplepos;
96 //if no tracks are selected and we're working from the keyboard, enable all tracks (_something_ has to be selected for any range selection)
97 if ( selection->tracks.empty() )
100 selection->set (start.sample, end.sample);
102 //if session is playing a range, cancel that
103 if (_session->get_play_range())
104 _session->request_cancel_play_range();
109 Editor::keyboard_paste ()