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)
54 if (current_mixer_strip == 0) {
56 if (selection->tracks.empty()) {
58 if (track_views.empty()) {
62 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
63 AudioTimeAxisView* atv;
65 if ((atv = dynamic_cast<AudioTimeAxisView*> (*i)) != 0) {
67 current_mixer_strip = new MixerStrip (*ARDOUR_UI::instance()->the_mixer(),
71 current_mixer_strip->GoingAway.connect (mem_fun(*this, &Editor::cms_deleted));
77 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
78 AudioTimeAxisView* atv;
80 if ((atv = dynamic_cast<AudioTimeAxisView*> (*i)) != 0) {
82 current_mixer_strip = new MixerStrip (*ARDOUR_UI::instance()->the_mixer(),
85 current_mixer_strip->GoingAway.connect (mem_fun(*this, &Editor::cms_deleted));
92 if (current_mixer_strip == 0) {
97 if (current_mixer_strip->get_parent() == 0) {
98 current_mixer_strip->set_embedded (true);
99 current_mixer_strip->Hiding.connect (mem_fun(*this, &Editor::current_mixer_strip_hidden));
100 current_mixer_strip->GoingAway.connect (mem_fun(*this, &Editor::current_mixer_strip_removed));
101 current_mixer_strip->set_width (editor_mixer_strip_width);
103 global_hpacker.pack_start (*current_mixer_strip, Gtk::PACK_SHRINK );
104 global_hpacker.reorder_child (*current_mixer_strip, 0);
106 current_mixer_strip->show_all ();
111 if (current_mixer_strip) {
112 editor_mixer_strip_width = current_mixer_strip->get_width ();
113 if (current_mixer_strip->get_parent() != 0) {
114 global_hpacker.remove (*current_mixer_strip);
121 Editor::set_selected_mixer_strip (TimeAxisView& view)
123 AudioTimeAxisView* at;
126 if (!session || (at = dynamic_cast<AudioTimeAxisView*>(&view)) == 0) {
130 if (current_mixer_strip) {
132 /* might be nothing to do */
134 if (current_mixer_strip->route() == at->route()) {
138 if (current_mixer_strip->get_parent()) {
141 delete current_mixer_strip;
142 current_mixer_strip = 0;
145 current_mixer_strip = new MixerStrip (*ARDOUR_UI::instance()->the_mixer(),
148 current_mixer_strip->GoingAway.connect (mem_fun(*this, &Editor::cms_deleted));
151 show_editor_mixer (true);
156 Editor::update_current_screen ()
158 if (session && engine.running()) {
160 jack_nframes_t frame;
162 frame = session->audible_frame();
164 /* only update if the playhead is on screen or we are following it */
166 if (_follow_playhead) {
169 playhead_cursor->canvas_item.show();
170 if (frame != last_update_frame) {
171 const jack_nframes_t page_width = current_page_frames();
173 // Percentage width of the visible range to use as a scroll interval
174 // Idea: snap this to the nearest bar/beat/tick/etc, would make scrolling much
175 // less jarring when zoomed in.. and it would be fun to watch :)
176 static const double scroll_pct = 3.0/4.0;
178 const jack_nframes_t rightmost_frame = leftmost_frame + page_width;
179 const jack_nframes_t scroll_interval = (jack_nframes_t)(page_width * scroll_pct);
180 const jack_nframes_t padding = (jack_nframes_t)floor((page_width-scroll_interval) / 2.0);
182 if (frame < leftmost_frame + padding || frame > rightmost_frame - padding) {
184 if (session->transport_speed() < 0) {
185 if (frame > scroll_interval) {
186 center_screen (frame - scroll_interval/2);
188 center_screen (scroll_interval);
191 center_screen(frame + scroll_interval/2);
195 playhead_cursor->set_position (frame);
200 if (frame != last_update_frame) {
201 if (frame < leftmost_frame || frame > leftmost_frame + current_page_frames()) {
202 playhead_cursor->canvas_item.hide();
204 playhead_cursor->set_position (frame);
209 last_update_frame = frame;
211 if (current_mixer_strip) {
212 current_mixer_strip->fast_update ();
219 Editor::current_mixer_strip_removed ()
221 if (current_mixer_strip) {
222 /* it is being deleted */
223 current_mixer_strip = 0;
228 Editor::current_mixer_strip_hidden ()
230 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
232 AudioTimeAxisView* tmp;
234 if ((tmp = dynamic_cast<AudioTimeAxisView*>(*i)) != 0) {
235 if (tmp->route() == current_mixer_strip->route()) {
236 (*i)->set_selected (false);
242 Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
244 Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(act);
245 tact->set_active (false);
250 Editor::session_going_away ()
252 for (vector<sigc::connection>::iterator i = session_connections.begin(); i != session_connections.end(); ++i) {
258 cut_buffer->clear ();
260 clicked_regionview = 0;
261 clicked_axisview = 0;
262 clicked_routeview = 0;
263 clicked_crossfadeview = 0;
264 entered_regionview = 0;
266 latest_regionview = 0;
267 last_update_frame = 0;
269 last_canvas_frame = 0;
271 /* hide all tracks */
273 hide_all_tracks (false);
275 /* rip everything out of the list displays */
277 region_list_clear (); // no clear() method in gtkmm 1.2
278 route_display_model->clear ();
279 named_selection_model->clear ();
280 group_model->clear ();
282 edit_cursor_clock.set_session (0);
283 zoom_range_clock.set_session (0);
284 nudge_clock.set_session (0);
286 /* put editor/mixer toggle button in off position and disable until a new session is loaded */
288 editor_mixer_button.set_active(false);
289 editor_mixer_button.set_sensitive(false);
290 /* clear tempo/meter rulers */
292 remove_metric_marks ();
294 clear_marker_display ();
296 if (current_bbt_points) {
297 delete current_bbt_points;
298 current_bbt_points = 0;
301 /* mixer strip will be deleted all by itself
302 when its route is deleted.
305 current_mixer_strip = 0;
307 set_title (_("ardour: editor"));