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));
81 sort_track_selection ();
83 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
84 AudioTimeAxisView* atv;
86 if ((atv = dynamic_cast<AudioTimeAxisView*> (*i)) != 0) {
88 current_mixer_strip = new MixerStrip (*ARDOUR_UI::instance()->the_mixer(),
91 current_mixer_strip->GoingAway.connect (mem_fun(*this, &Editor::cms_deleted));
98 if (current_mixer_strip == 0) {
103 if (current_mixer_strip->get_parent() == 0) {
104 current_mixer_strip->set_embedded (true);
105 current_mixer_strip->Hiding.connect (mem_fun(*this, &Editor::current_mixer_strip_hidden));
106 current_mixer_strip->GoingAway.connect (mem_fun(*this, &Editor::current_mixer_strip_removed));
107 current_mixer_strip->set_width (editor_mixer_strip_width);
109 global_hpacker.pack_start (*current_mixer_strip, Gtk::PACK_SHRINK );
110 global_hpacker.reorder_child (*current_mixer_strip, 0);
112 current_mixer_strip->show_all ();
117 if (current_mixer_strip) {
118 editor_mixer_strip_width = current_mixer_strip->get_width ();
119 if (current_mixer_strip->get_parent() != 0) {
120 global_hpacker.remove (*current_mixer_strip);
127 Editor::set_selected_mixer_strip (TimeAxisView& view)
129 AudioTimeAxisView* at;
132 if (!session || (at = dynamic_cast<AudioTimeAxisView*>(&view)) == 0) {
136 if (current_mixer_strip) {
138 /* might be nothing to do */
140 if (current_mixer_strip->route() == at->route()) {
144 if (current_mixer_strip->get_parent()) {
147 delete current_mixer_strip;
148 current_mixer_strip = 0;
151 current_mixer_strip = new MixerStrip (*ARDOUR_UI::instance()->the_mixer(),
154 current_mixer_strip->GoingAway.connect (mem_fun(*this, &Editor::cms_deleted));
157 show_editor_mixer (true);
161 double current = 0.0;
162 bool currentInitialized = 0;
165 Editor::update_current_screen ()
167 if (session && engine.running()) {
171 frame = session->audible_frame();
173 if (_dragging_playhead) {
177 /* only update if the playhead is on screen or we are following it */
179 if (_follow_playhead) {
181 playhead_cursor->canvas_item.show();
183 if (frame != last_update_frame) {
186 #undef CONTINUOUS_SCROLL
187 #ifndef CONTINUOUS_SCROLL
188 if (frame < leftmost_frame || frame > leftmost_frame + current_page_frames()) {
190 if (session->transport_speed() < 0) {
191 if (frame > (current_page_frames()/2)) {
192 center_screen (frame-(current_page_frames()/2));
194 center_screen (current_page_frames()/2);
197 center_screen (frame+(current_page_frames()/2));
201 playhead_cursor->set_position (frame);
203 #else // CONTINUOUS_SCROLL
205 /* don't do continuous scroll till the new position is in the rightmost quarter of the
209 if (session->transport_speed()) {
210 double target = ((double)frame - (double)current_page_frames()/2.0) / frames_per_unit;
211 if (target <= 0.0) target = 0.0;
212 if ( fabs(target - current) < current_page_frames()/frames_per_unit ) {
213 target = (target * 0.15) + (current * 0.85);
217 //printf("frame: %d, cpf: %d, fpu: %6.6f, current: %6.6f, target : %6.6f\n", frame, current_page_frames(), frames_per_unit, current, target );
219 horizontal_adjustment.set_value ( current );
222 playhead_cursor->set_position (frame);
224 #endif // CONTINUOUS_SCROLL
230 if (frame != last_update_frame) {
231 if (frame < leftmost_frame || frame > leftmost_frame + current_page_frames()) {
232 playhead_cursor->canvas_item.hide();
234 playhead_cursor->set_position (frame);
240 last_update_frame = frame;
242 if (current_mixer_strip) {
243 current_mixer_strip->fast_update ();
250 Editor::current_mixer_strip_removed ()
252 if (current_mixer_strip) {
253 /* it is being deleted */
254 current_mixer_strip = 0;
259 Editor::current_mixer_strip_hidden ()
261 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
263 AudioTimeAxisView* tmp;
265 if ((tmp = dynamic_cast<AudioTimeAxisView*>(*i)) != 0) {
266 if (tmp->route() == current_mixer_strip->route()) {
267 (*i)->set_selected (false);
273 Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
275 Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(act);
276 tact->set_active (false);
281 Editor::session_going_away ()
283 for (vector<sigc::connection>::iterator i = session_connections.begin(); i != session_connections.end(); ++i) {
289 cut_buffer->clear ();
291 clicked_regionview = 0;
292 clicked_trackview = 0;
293 clicked_audio_trackview = 0;
294 clicked_crossfadeview = 0;
295 entered_regionview = 0;
297 latest_regionview = 0;
298 last_update_frame = 0;
300 last_canvas_frame = 0;
302 /* hide all tracks */
304 hide_all_tracks (false);
306 /* rip everything out of the list displays */
308 region_list_display.set_model (Glib::RefPtr<Gtk::TreeStore>(0));
309 route_list_display.set_model (Glib::RefPtr<Gtk::TreeStore>(0));
310 named_selection_display.set_model (Glib::RefPtr<Gtk::TreeStore>(0));
311 edit_group_display.set_model (Glib::RefPtr<Gtk::TreeStore>(0));
313 region_list_model->clear ();
314 route_display_model->clear ();
315 named_selection_model->clear ();
316 group_model->clear ();
318 region_list_display.set_model (region_list_model);
319 route_list_display.set_model (route_display_model);
320 named_selection_display.set_model (named_selection_model);
321 edit_group_display.set_model (group_model);
323 edit_cursor_clock.set_session (0);
324 zoom_range_clock.set_session (0);
325 nudge_clock.set_session (0);
327 /* put editor/mixer toggle button in off position and disable until a new session is loaded */
329 editor_mixer_button.set_active(false);
330 editor_mixer_button.set_sensitive(false);
331 /* clear tempo/meter rulers */
333 remove_metric_marks ();
335 clear_marker_display ();
337 if (current_bbt_points) {
338 delete current_bbt_points;
339 current_bbt_points = 0;
342 /* mixer strip will be deleted all by itself
343 when its route is deleted.
346 current_mixer_strip = 0;
348 set_title (_("ardour: editor"));