Back out big shared_ptr change. Moving to a branch. Apologies all.
[ardour.git] / gtk2_ardour / editor_keys.cc
1 /*
2     Copyright (C) 2000 Paul Davis 
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include <cstdlib>
21 #include <cmath>
22 #include <string>
23
24 #include "pbd/error.h"
25
26 #include "ardour/session.h"
27 #include "ardour/region.h"
28 #include <gtkmm/treeview.h>
29
30 #include "ardour_ui.h"
31 #include "editor.h"
32 #include "time_axis_view.h"
33 #include "region_view.h"
34 #include "selection.h"
35
36 #include "i18n.h"
37
38 using namespace ARDOUR;
39 using namespace PBD;
40 using namespace sigc;
41
42 void
43 Editor::keyboard_selection_finish (bool add)
44 {
45         if (session && have_pending_keyboard_selection) {
46
47                 nframes64_t end;
48                 bool ignored;
49
50                 if (session->transport_rolling()) {
51                         end = session->audible_frame();
52                 } else {
53                         if (!mouse_frame (end, ignored)) {
54                                 return;
55                         }
56                 }
57
58                 if (add) {
59                         selection->add (pending_keyboard_selection_start, end);
60                 } else {
61                         selection->set (0, pending_keyboard_selection_start, end);
62                 }
63
64                 have_pending_keyboard_selection = false;
65         }
66 }
67
68 void
69 Editor::keyboard_selection_begin ()
70 {
71         if (session) {
72                 if (session->transport_rolling()) {
73                         pending_keyboard_selection_start = session->audible_frame();
74                         have_pending_keyboard_selection = true;
75                 } else {
76                         bool ignored;
77                         nframes64_t where; // XXX fix me
78
79                         if (mouse_frame (where, ignored)) {
80                                 pending_keyboard_selection_start = where;
81                                 have_pending_keyboard_selection = true;
82                         }
83                                 
84                 }
85         }
86 }
87
88 void
89 Editor::keyboard_paste ()
90 {
91         ensure_entered_track_selected (true);
92         paste (1);
93 }
94
95 void
96 Editor::keyboard_insert_region_list_selection ()
97 {
98         insert_region_list_selection (1);
99 }
100
101 int
102 Editor::get_prefix (float& val, bool& was_floating)
103 {
104         was_floating = false;
105         return 1;
106 }
107