export range markers patch (revisited), change selection model, copy-drag tempo+meter...
[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     $Id$
19 */
20
21 #include <cstdlib>
22 #include <cmath>
23 #include <string>
24
25 #include <pbd/error.h>
26
27 #include <ardour/session.h>
28 #include <ardour/region.h>
29
30 #include "ardour_ui.h"
31 #include "editor.h"
32 #include "time_axis_view.h"
33 #include "regionview.h"
34 #include "selection.h"
35
36 #include "i18n.h"
37
38 using namespace ARDOUR;
39 using namespace sigc;
40
41 void
42 Editor::keyboard_selection_finish (bool add)
43 {
44         if (session && have_pending_keyboard_selection) {
45                 begin_reversible_command (_("keyboard selection"));
46                 if (add) {
47                         selection->add (pending_keyboard_selection_start, session->audible_frame());
48                 } else {
49                         selection->set (0, pending_keyboard_selection_start, session->audible_frame());
50                 }
51                 commit_reversible_command ();
52                 have_pending_keyboard_selection = false;
53         }
54 }
55
56 void
57 Editor::keyboard_selection_begin ()
58 {
59         if (session) {
60                 pending_keyboard_selection_start = session->audible_frame();
61                 have_pending_keyboard_selection = true;
62         }
63 }
64
65 void
66 Editor::keyboard_duplicate_region ()
67 {
68         if (selection->audio_regions.empty()) {
69                 return;
70         }
71
72         float prefix;
73         bool was_floating;
74
75         if (get_prefix (prefix, was_floating) == 0) {
76                 duplicate_some_regions (selection->audio_regions, prefix);
77         } else {
78                 duplicate_some_regions (selection->audio_regions, 1);
79         }
80 }
81
82 void
83 Editor::keyboard_duplicate_selection ()
84 {
85         float prefix;
86         bool was_floating;
87
88         if (get_prefix (prefix, was_floating) == 0) {
89                 duplicate_selection (prefix);
90         } else {
91                 duplicate_selection (1);
92         }
93 }
94
95 void
96 Editor::keyboard_paste ()
97 {
98         float prefix;
99         bool was_floating;
100
101         if (get_prefix (prefix, was_floating) == 0) {
102                 paste (prefix);
103         } else {
104                 paste (1);
105         }
106 }
107
108 void
109 Editor::keyboard_insert_region_list_selection ()
110 {
111         float prefix;
112         bool was_floating;
113
114         if (get_prefix (prefix, was_floating) == 0) {
115                 insert_region_list_selection (prefix);
116         } else {
117                 insert_region_list_selection (1);
118         }
119 }
120
121 int
122 Editor::get_prefix (float& val, bool& was_floating)
123 {
124         return Keyboard::the_keyboard().get_prefix (val, was_floating);
125 }
126