Remove debug output and move meter option to root menu for now
[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 "ardour_ui.h"
24 #include "editor.h"
25 #include "editing.h"
26 #include "audio_time_axis.h"
27 #include "region_view.h"
28 #include "selection.h"
29
30 #include "i18n.h"
31
32 using namespace ARDOUR;
33 using namespace PBD;
34
35 void
36 Editor::set_loop_from_selection (bool play)
37 {
38         if (session == 0 || selection->time.empty()) {
39                 return;
40         }
41
42         nframes_t start = selection->time[clicked_selection].start;
43         nframes_t end = selection->time[clicked_selection].end;
44         
45         set_loop_range (start, end,  _("set loop range from selection"));
46
47         if (play) {
48                 session->request_play_loop (true);
49                 session->request_locate (start, true);
50         }
51 }
52
53 void
54 Editor::set_punch_from_selection ()
55 {
56         if (session == 0 || selection->time.empty()) {
57                 return;
58         }
59
60         nframes_t start = selection->time[clicked_selection].start;
61         nframes_t end = selection->time[clicked_selection].end;
62         
63         set_punch_range (start, end,  _("set punch range from selection"));
64 }
65
66 void
67 Editor::set_show_waveforms (bool yn)
68 {
69         AudioTimeAxisView* atv;
70
71         if (_show_waveforms != yn) {
72                 _show_waveforms = yn;
73                 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
74                         if ((atv = dynamic_cast<AudioTimeAxisView*>(*i)) != 0) {
75                                 atv->set_show_waveforms (yn);
76                         }
77                 }
78         }
79 }
80
81 void
82 Editor::set_show_waveforms_recording (bool yn)
83 {
84         AudioTimeAxisView* atv;
85
86         if (_show_waveforms_recording != yn) {
87                 _show_waveforms_recording = yn;
88                 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
89                         if ((atv = dynamic_cast<AudioTimeAxisView*>(*i)) != 0) {
90                                 atv->set_show_waveforms_recording (yn);
91                         }
92                 }
93         }
94 }
95
96 gint
97 Editor::start_updating ()
98 {
99         AudioTimeAxisView* atv;
100
101         //cerr << "Editor::start_updating () called" << endl;//DEBUG
102         if (is_mapped() && session) {
103                 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
104                         if ((atv = dynamic_cast<AudioTimeAxisView*>(*i)) != 0) {
105                                 atv->show_meter ();
106                         }
107                 }
108         }
109     fast_screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (mem_fun(*this, &Editor::fast_update_strips));
110     return 0;
111 }
112
113 gint
114 Editor::stop_updating ()
115 {
116
117         fast_screen_update_connection.disconnect();
118         AudioTimeAxisView* atv;
119
120         //cerr << "Editor::stop_updating () called" << endl;//DEBUG
121         if (is_mapped() && session) {
122                 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
123                         if ((atv = dynamic_cast<AudioTimeAxisView*>(*i)) != 0) {
124                                 atv->hide_meter ();
125                         }
126                 }
127         }
128
129     return 0;
130 }
131
132 void
133 Editor::toggle_meter_updating()
134 {
135         if (Config->get_show_track_meters()) {
136                 start_updating();
137         } else {
138                 stop_updating ();
139         }
140 }
141
142 void
143 Editor::fast_update_strips ()
144 {
145         AudioTimeAxisView* atv;
146
147         if (is_mapped() && session) {
148                 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
149                         if ((atv = dynamic_cast<AudioTimeAxisView*>(*i)) != 0) {
150                                 atv->fast_update ();
151                         }
152                 }
153         }
154 }
155