merge from 2.0-ongoing by hand, minus key binding editor
[ardour.git] / gtk2_ardour / editor_audiotrack.cc
1 /*
2     Copyright (C) 2000-2007 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 <ardour/location.h>
21 #include <ardour/audio_diskstream.h>
22
23 #include "editor.h"
24 #include "editing.h"
25 #include "audio_time_axis.h"
26 #include "audio_region_view.h"
27 #include "selection.h"
28
29 #include "i18n.h"
30
31 using namespace ARDOUR;
32 using namespace PBD;
33
34 void
35 Editor::set_loop_from_selection (bool play)
36 {
37         if (session == 0 || selection->time.empty()) {
38                 return;
39         }
40
41         nframes_t start = selection->time[clicked_selection].start;
42         nframes_t end = selection->time[clicked_selection].end;
43         
44         set_loop_range (start, end,  _("set loop range from selection"));
45
46         if (play) {
47                 session->request_play_loop (true);
48                 session->request_locate (start, true);
49         }
50 }
51
52 void
53 Editor::set_punch_from_selection ()
54 {
55         if (session == 0 || selection->time.empty()) {
56                 return;
57         }
58
59         nframes_t start = selection->time[clicked_selection].start;
60         nframes_t end = selection->time[clicked_selection].end;
61         
62         set_punch_range (start, end,  _("set punch range from selection"));
63 }
64
65 void
66 Editor::set_show_waveforms (bool yn)
67 {
68         AudioTimeAxisView* atv;
69
70         if (_show_waveforms != yn) {
71                 _show_waveforms = yn;
72                 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
73                         if ((atv = dynamic_cast<AudioTimeAxisView*>(*i)) != 0) {
74                                 atv->set_show_waveforms (yn);
75                         }
76                 }
77         }
78 }
79
80 void
81 Editor::set_show_waveforms_recording (bool yn)
82 {
83         AudioTimeAxisView* atv;
84
85         if (_show_waveforms_recording != yn) {
86                 _show_waveforms_recording = yn;
87                 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
88                         if ((atv = dynamic_cast<AudioTimeAxisView*>(*i)) != 0) {
89                                 atv->set_show_waveforms_recording (yn);
90                         }
91                 }
92         }
93 }