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"
34 Editor::editor_mixer_button_toggled ()
36 Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
38 Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(act);
39 show_editor_mixer (tact->get_active());
44 Editor::cms_deleted ()
46 current_mixer_strip = 0;
50 Editor::show_editor_mixer (bool yn)
52 show_editor_mixer_when_tracks_arrive = false;
56 if (current_mixer_strip == 0) {
58 if (selection->tracks.empty()) {
60 if (track_views.empty()) {
61 show_editor_mixer_when_tracks_arrive = true;
65 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
66 AudioTimeAxisView* atv;
68 if ((atv = dynamic_cast<AudioTimeAxisView*> (*i)) != 0) {
70 current_mixer_strip = new MixerStrip (*ARDOUR_UI::instance()->the_mixer(),
74 current_mixer_strip->GoingAway.connect (mem_fun(*this, &Editor::cms_deleted));
80 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
81 AudioTimeAxisView* atv;
83 if ((atv = dynamic_cast<AudioTimeAxisView*> (*i)) != 0) {
85 current_mixer_strip = new MixerStrip (*ARDOUR_UI::instance()->the_mixer(),
88 current_mixer_strip->GoingAway.connect (mem_fun(*this, &Editor::cms_deleted));
95 if (current_mixer_strip == 0) {
100 if (current_mixer_strip->get_parent() == 0) {
101 current_mixer_strip->set_embedded (true);
102 current_mixer_strip->Hiding.connect (mem_fun(*this, &Editor::current_mixer_strip_hidden));
103 current_mixer_strip->GoingAway.connect (mem_fun(*this, &Editor::current_mixer_strip_removed));
104 current_mixer_strip->set_width (editor_mixer_strip_width);
106 global_hpacker.pack_start (*current_mixer_strip, Gtk::PACK_SHRINK );
107 global_hpacker.reorder_child (*current_mixer_strip, 0);
109 current_mixer_strip->show_all ();
114 if (current_mixer_strip) {
115 editor_mixer_strip_width = current_mixer_strip->get_width ();
116 if (current_mixer_strip->get_parent() != 0) {
117 global_hpacker.remove (*current_mixer_strip);
124 Editor::set_selected_mixer_strip (TimeAxisView& view)
126 AudioTimeAxisView* at;
129 if (!session || (at = dynamic_cast<AudioTimeAxisView*>(&view)) == 0) {
133 if (current_mixer_strip) {
135 /* might be nothing to do */
137 if (current_mixer_strip->route() == at->route()) {
141 if (current_mixer_strip->get_parent()) {
144 delete current_mixer_strip;
145 current_mixer_strip = 0;
148 current_mixer_strip = new MixerStrip (*ARDOUR_UI::instance()->the_mixer(),
151 current_mixer_strip->GoingAway.connect (mem_fun(*this, &Editor::cms_deleted));
154 show_editor_mixer (true);
159 Editor::update_current_screen ()
161 if (session && engine.running()) {
165 frame = session->audible_frame();
167 /* only update if the playhead is on screen or we are following it */
169 if (_follow_playhead) {
171 playhead_cursor->canvas_item.show();
172 if (frame != last_update_frame) {
174 if (frame < leftmost_frame || frame > leftmost_frame + current_page_frames()) {
176 if (session->transport_speed() < 0) {
177 if (frame > (current_page_frames()/2)) {
178 center_screen (frame-(current_page_frames()/2));
180 center_screen (current_page_frames()/2);
183 center_screen (frame+(current_page_frames()/2));
187 playhead_cursor->set_position (frame);
192 if (frame != last_update_frame) {
193 if (frame < leftmost_frame || frame > leftmost_frame + current_page_frames()) {
194 playhead_cursor->canvas_item.hide();
196 playhead_cursor->set_position (frame);
201 last_update_frame = frame;
203 if (current_mixer_strip) {
204 current_mixer_strip->fast_update ();
211 Editor::current_mixer_strip_removed ()
213 if (current_mixer_strip) {
214 /* it is being deleted */
215 current_mixer_strip = 0;
220 Editor::current_mixer_strip_hidden ()
222 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
224 AudioTimeAxisView* tmp;
226 if ((tmp = dynamic_cast<AudioTimeAxisView*>(*i)) != 0) {
227 if (tmp->route() == current_mixer_strip->route()) {
228 (*i)->set_selected (false);
234 Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
236 Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(act);
237 tact->set_active (false);
242 Editor::session_going_away ()
244 for (vector<sigc::connection>::iterator i = session_connections.begin(); i != session_connections.end(); ++i) {
250 cut_buffer->clear ();
252 clicked_regionview = 0;
253 clicked_trackview = 0;
254 clicked_audio_trackview = 0;
255 clicked_crossfadeview = 0;
256 entered_regionview = 0;
258 latest_regionview = 0;
259 last_update_frame = 0;
261 last_canvas_frame = 0;
263 /* hide all tracks */
265 hide_all_tracks (false);
267 /* rip everything out of the list displays */
269 region_list_clear (); // no clear() method in gtkmm 1.2
270 route_display_model->clear ();
271 named_selection_model->clear ();
272 group_model->clear ();
274 edit_cursor_clock.set_session (0);
275 zoom_range_clock.set_session (0);
276 nudge_clock.set_session (0);
278 /* put editor/mixer toggle button in off position and disable until a new session is loaded */
280 editor_mixer_button.set_active(false);
281 editor_mixer_button.set_sensitive(false);
282 /* clear tempo/meter rulers */
284 remove_metric_marks ();
286 clear_marker_display ();
288 if (current_bbt_points) {
289 delete current_bbt_points;
290 current_bbt_points = 0;
293 /* mixer strip will be deleted all by itself
294 when its route is deleted.
297 current_mixer_strip = 0;
299 set_title (_("ardour: editor"));