2 Copyright (C) 2003-2004 Paul Davis
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.
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.
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.
21 #include <gtkmm2ext/utils.h>
22 #include <ardour/audioengine.h>
25 #include "mixer_strip.h"
26 #include "ardour_ui.h"
27 #include "selection.h"
28 #include "audio_time_axis.h"
33 Editor::editor_mixer_button_toggled ()
35 show_editor_mixer (editor_mixer_button.get_active());
39 Editor::cms_deleted ()
41 current_mixer_strip = 0;
45 Editor::show_editor_mixer (bool yn)
49 if (current_mixer_strip == 0) {
51 if (selection->tracks.empty()) {
53 if (track_views.empty()) {
57 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
58 AudioTimeAxisView* atv;
60 if ((atv = dynamic_cast<AudioTimeAxisView*> (*i)) != 0) {
62 current_mixer_strip = new MixerStrip (*ARDOUR_UI::instance()->the_mixer(),
66 current_mixer_strip->GoingAway.connect (mem_fun(*this, &Editor::cms_deleted));
72 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
73 AudioTimeAxisView* atv;
75 if ((atv = dynamic_cast<AudioTimeAxisView*> (*i)) != 0) {
77 current_mixer_strip = new MixerStrip (*ARDOUR_UI::instance()->the_mixer(),
80 current_mixer_strip->GoingAway.connect (mem_fun(*this, &Editor::cms_deleted));
87 if (current_mixer_strip == 0) {
92 if (current_mixer_strip->get_parent() == 0) {
94 current_mixer_strip->set_embedded (true);
95 current_mixer_strip->Hiding.connect (mem_fun(*this, &Editor::current_mixer_strip_hidden));
96 current_mixer_strip->GoingAway.connect (mem_fun(*this, &Editor::current_mixer_strip_removed));
97 current_mixer_strip->set_width (editor_mixer_strip_width);
98 current_mixer_strip->show_all ();
100 global_hpacker.pack_start (*current_mixer_strip, false, false);
101 global_hpacker.reorder_child (*current_mixer_strip, 0);
106 if (current_mixer_strip) {
107 editor_mixer_strip_width = current_mixer_strip->get_width ();
108 if (current_mixer_strip->get_parent() != 0) {
109 global_hpacker.remove (*current_mixer_strip);
116 Editor::set_selected_mixer_strip (TimeAxisView& view)
118 AudioTimeAxisView* at;
121 if (!session || (at = dynamic_cast<AudioTimeAxisView*>(&view)) == 0) {
125 if (current_mixer_strip) {
127 /* might be nothing to do */
129 if (¤t_mixer_strip->route() == &at->route()) {
133 if (current_mixer_strip->get_parent()) {
137 delete current_mixer_strip;
138 current_mixer_strip = 0;
141 current_mixer_strip = new MixerStrip (*ARDOUR_UI::instance()->the_mixer(),
144 current_mixer_strip->GoingAway.connect (mem_fun(*this, &Editor::cms_deleted));
147 show_editor_mixer (true);
152 Editor::update_current_screen ()
154 if (session && engine.running()) {
156 jack_nframes_t frame;
158 frame = session->audible_frame();
160 /* only update if the playhead is on screen or we are following it */
162 if (_follow_playhead) {
164 playhead_cursor->canvas_item.show();
165 if (frame != last_update_frame) {
167 if (frame < leftmost_frame || frame > leftmost_frame + current_page_frames()) {
169 if (session->transport_speed() < 0) {
170 if (frame > (current_page_frames()/2)) {
171 center_screen (frame-(current_page_frames()/2));
173 center_screen (current_page_frames()/2);
176 center_screen (frame+(current_page_frames()/2));
180 playhead_cursor->set_position (frame);
185 if (frame != last_update_frame) {
186 if (frame < leftmost_frame || frame > leftmost_frame + current_page_frames()) {
187 playhead_cursor->canvas_item.hide();
189 playhead_cursor->set_position (frame);
194 last_update_frame = frame;
196 if (current_mixer_strip) {
197 current_mixer_strip->fast_update ();
204 Editor::update_slower ()
206 if (current_mixer_strip) {
207 current_mixer_strip->update ();
212 Editor::current_mixer_strip_removed ()
214 if (current_mixer_strip) {
215 /* it is being deleted */
216 current_mixer_strip = 0;
221 Editor::current_mixer_strip_hidden ()
223 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
225 AudioTimeAxisView* tmp;
227 if ((tmp = dynamic_cast<AudioTimeAxisView*>(*i)) != 0) {
228 if (&(tmp->route()) == &(current_mixer_strip->route())) {
229 (*i)->set_selected (false);
234 global_hpacker.remove (*current_mixer_strip);
238 Editor::session_going_away ()
240 for (vector<sigc::connection>::iterator i = session_connections.begin(); i != session_connections.end(); ++i) {
246 cut_buffer->clear ();
248 clicked_regionview = 0;
249 clicked_trackview = 0;
250 clicked_audio_trackview = 0;
251 clicked_crossfadeview = 0;
252 entered_regionview = 0;
254 latest_regionview = 0;
255 last_update_frame = 0;
257 last_audition_region = 0;
259 /* hide all tracks */
261 hide_all_tracks (false);
263 /* rip everything out of the list displays */
265 region_list_clear (); // no clear() method in gtkmm 1.2
266 route_display_model->clear ();
267 named_selection_model->clear ();
268 group_model->clear ();
270 edit_cursor_clock.set_session (0);
271 selection_start_clock.set_session (0);
272 selection_end_clock.set_session (0);
273 zoom_range_clock.set_session (0);
274 nudge_clock.set_session (0);
276 /* put editor/mixer toggle button in off position and disable until a new session is loaded */
278 editor_mixer_button.set_active(false);
279 editor_mixer_button.set_sensitive(false);
280 /* clear tempo/meter rulers */
282 remove_metric_marks ();
284 clear_marker_display ();
286 if (current_bbt_points) {
287 delete current_bbt_points;
288 current_bbt_points = 0;
291 /* mixer strip will be deleted all by itself
292 when its route is deleted.
295 current_mixer_strip = 0;
297 set_title (_("ardour: editor"));