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.
20 #include <gtkmm2ext/utils.h>
21 #include <ardour/audioengine.h>
24 #include "mixer_strip.h"
25 #include "ardour_ui.h"
26 #include "selection.h"
27 #include "audio_time_axis.h"
33 Editor::editor_mixer_button_toggled ()
35 Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
37 Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(act);
38 show_editor_mixer (tact->get_active());
43 Editor::cms_deleted ()
45 current_mixer_strip = 0;
49 Editor::show_editor_mixer (bool yn)
51 show_editor_mixer_when_tracks_arrive = false;
55 if (current_mixer_strip == 0) {
57 if (selection->tracks.empty()) {
59 if (track_views.empty()) {
60 show_editor_mixer_when_tracks_arrive = true;
64 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
65 AudioTimeAxisView* atv;
67 if ((atv = dynamic_cast<AudioTimeAxisView*> (*i)) != 0) {
69 current_mixer_strip = new MixerStrip (*ARDOUR_UI::instance()->the_mixer(),
73 current_mixer_strip->GoingAway.connect (mem_fun(*this, &Editor::cms_deleted));
80 sort_track_selection ();
82 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
83 AudioTimeAxisView* atv;
85 if ((atv = dynamic_cast<AudioTimeAxisView*> (*i)) != 0) {
87 current_mixer_strip = new MixerStrip (*ARDOUR_UI::instance()->the_mixer(),
90 current_mixer_strip->GoingAway.connect (mem_fun(*this, &Editor::cms_deleted));
97 if (current_mixer_strip == 0) {
102 if (current_mixer_strip->get_parent() == 0) {
103 current_mixer_strip->set_embedded (true);
104 current_mixer_strip->Hiding.connect (mem_fun(*this, &Editor::current_mixer_strip_hidden));
105 current_mixer_strip->GoingAway.connect (mem_fun(*this, &Editor::current_mixer_strip_removed));
106 current_mixer_strip->set_width (editor_mixer_strip_width);
108 global_hpacker.pack_start (*current_mixer_strip, Gtk::PACK_SHRINK );
109 global_hpacker.reorder_child (*current_mixer_strip, 0);
111 current_mixer_strip->show_all ();
116 if (current_mixer_strip) {
117 editor_mixer_strip_width = current_mixer_strip->get_width ();
118 if (current_mixer_strip->get_parent() != 0) {
119 global_hpacker.remove (*current_mixer_strip);
126 Editor::set_selected_mixer_strip (TimeAxisView& view)
128 AudioTimeAxisView* at;
131 if (!session || (at = dynamic_cast<AudioTimeAxisView*>(&view)) == 0) {
135 if (current_mixer_strip) {
137 /* might be nothing to do */
139 if (current_mixer_strip->route() == at->route()) {
143 if (current_mixer_strip->get_parent()) {
146 delete current_mixer_strip;
147 current_mixer_strip = 0;
150 current_mixer_strip = new MixerStrip (*ARDOUR_UI::instance()->the_mixer(),
153 current_mixer_strip->GoingAway.connect (mem_fun(*this, &Editor::cms_deleted));
156 show_editor_mixer (true);
160 double current = 0.0;
161 bool currentInitialized = 0;
164 Editor::update_current_screen ()
166 if (session && engine.running()) {
170 frame = session->audible_frame();
172 if (_dragging_playhead) {
176 /* only update if the playhead is on screen or we are following it */
178 if (_follow_playhead) {
180 playhead_cursor->canvas_item.show();
182 if (frame != last_update_frame) {
185 #undef CONTINUOUS_SCROLL
186 #ifndef CONTINUOUS_SCROLL
187 if (frame < leftmost_frame || frame > leftmost_frame + current_page_frames()) {
189 if (session->transport_speed() < 0) {
190 if (frame > (current_page_frames()/2)) {
191 center_screen (frame-(current_page_frames()/2));
193 center_screen (current_page_frames()/2);
196 center_screen (frame+(current_page_frames()/2));
200 playhead_cursor->set_position (frame);
202 #else // CONTINUOUS_SCROLL
204 /* don't do continuous scroll till the new position is in the rightmost quarter of the
208 if (session->transport_speed()) {
209 double target = ((double)frame - (double)current_page_frames()/2.0) / frames_per_unit;
210 if (target <= 0.0) target = 0.0;
211 if ( fabs(target - current) < current_page_frames()/frames_per_unit ) {
212 target = (target * 0.15) + (current * 0.85);
216 //printf("frame: %d, cpf: %d, fpu: %6.6f, current: %6.6f, target : %6.6f\n", frame, current_page_frames(), frames_per_unit, current, target );
218 horizontal_adjustment.set_value ( current );
221 playhead_cursor->set_position (frame);
223 #endif // CONTINUOUS_SCROLL
229 if (frame != last_update_frame) {
230 if (frame < leftmost_frame || frame > leftmost_frame + current_page_frames()) {
231 playhead_cursor->canvas_item.hide();
233 playhead_cursor->set_position (frame);
239 last_update_frame = frame;
241 if (current_mixer_strip) {
242 current_mixer_strip->fast_update ();
249 Editor::current_mixer_strip_removed ()
251 if (current_mixer_strip) {
252 /* it is being deleted */
253 current_mixer_strip = 0;
258 Editor::current_mixer_strip_hidden ()
260 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
262 AudioTimeAxisView* tmp;
264 if ((tmp = dynamic_cast<AudioTimeAxisView*>(*i)) != 0) {
265 if (tmp->route() == current_mixer_strip->route()) {
266 (*i)->set_selected (false);
272 Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
274 Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(act);
275 tact->set_active (false);
280 Editor::session_going_away ()
282 for (vector<sigc::connection>::iterator i = session_connections.begin(); i != session_connections.end(); ++i) {
288 cut_buffer->clear ();
290 clicked_regionview = 0;
291 clicked_trackview = 0;
292 clicked_audio_trackview = 0;
293 clicked_crossfadeview = 0;
294 entered_regionview = 0;
296 latest_regionview = 0;
297 last_update_frame = 0;
299 last_canvas_frame = 0;
301 /* hide all tracks */
303 hide_all_tracks (false);
305 /* rip everything out of the list displays */
307 region_list_display.set_model (Glib::RefPtr<Gtk::TreeStore>(0));
308 route_list_display.set_model (Glib::RefPtr<Gtk::TreeStore>(0));
309 named_selection_display.set_model (Glib::RefPtr<Gtk::TreeStore>(0));
310 edit_group_display.set_model (Glib::RefPtr<Gtk::TreeStore>(0));
312 region_list_model->clear ();
313 route_display_model->clear ();
314 named_selection_model->clear ();
315 group_model->clear ();
317 region_list_display.set_model (region_list_model);
318 route_list_display.set_model (route_display_model);
319 named_selection_display.set_model (named_selection_model);
320 edit_group_display.set_model (group_model);
322 edit_cursor_clock.set_session (0);
323 zoom_range_clock.set_session (0);
324 nudge_clock.set_session (0);
326 /* put editor/mixer toggle button in off position and disable until a new session is loaded */
328 editor_mixer_button.set_active(false);
329 editor_mixer_button.set_sensitive(false);
330 /* clear tempo/meter rulers */
332 remove_metric_marks ();
334 clear_marker_display ();
336 if (current_bbt_points) {
337 delete current_bbt_points;
338 current_bbt_points = 0;
341 /* mixer strip will be deleted all by itself
342 when its route is deleted.
345 current_mixer_strip = 0;
347 set_title (_("ardour: editor"));