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 "gtk2ardour-config.h"
24 #include <glibmm/miscutils.h>
25 #include <gtkmm/messagedialog.h>
26 #include <gtkmm2ext/utils.h>
27 #include <gtkmm2ext/window_title.h>
29 #include "pbd/enumwriter.h"
31 #include "ardour/rc_configuration.h"
34 #include "ardour_ui.h"
35 #include "audio_time_axis.h"
36 #include "automation_time_axis.h"
38 #include "editor_route_groups.h"
39 #include "editor_regions.h"
40 #include "gui_thread.h"
41 #include "midi_time_axis.h"
42 #include "mixer_strip.h"
44 #include "selection.h"
49 using namespace Gtkmm2ext;
53 Editor::editor_mixer_button_toggled ()
55 Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
57 Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(act);
58 show_editor_mixer (tact->get_active());
63 Editor::editor_list_button_toggled ()
65 Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-list"));
67 Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(act);
68 show_editor_list (tact->get_active());
73 Editor::show_editor_mixer (bool yn)
75 boost::shared_ptr<ARDOUR::Route> r;
77 show_editor_mixer_when_tracks_arrive = false;
80 Glib::RefPtr<Gdk::Window> win = get_window ();
81 Glib::RefPtr<Gdk::Screen> screen;
84 screen = win->get_screen();
86 screen = Gdk::Screen::get_default();
89 if (screen && screen->get_height() < 700) {
90 Gtk::MessageDialog msg (_("This screen is not tall enough to display the editor mixer"));
97 show_editor_mixer_when_tracks_arrive = yn;
103 if (selection->tracks.empty()) {
105 if (track_views.empty()) {
106 show_editor_mixer_when_tracks_arrive = true;
110 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
111 RouteTimeAxisView* atv;
113 if ((atv = dynamic_cast<RouteTimeAxisView*> (*i)) != 0) {
120 sort_track_selection (selection->tracks);
122 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
123 RouteTimeAxisView* atv;
125 if ((atv = dynamic_cast<RouteTimeAxisView*> (*i)) != 0) {
133 if (current_mixer_strip == 0) {
134 create_editor_mixer ();
137 current_mixer_strip->set_route (r);
138 current_mixer_strip->set_width_enum (editor_mixer_strip_width, (void*) this);
141 if (current_mixer_strip->get_parent() == 0) {
142 global_hpacker.pack_start (*current_mixer_strip, Gtk::PACK_SHRINK );
143 global_hpacker.reorder_child (*current_mixer_strip, 0);
144 current_mixer_strip->show ();
149 if (current_mixer_strip) {
150 if (current_mixer_strip->get_parent() != 0) {
151 global_hpacker.remove (*current_mixer_strip);
157 /* XXX gtk problem here */
158 ensure_all_elements_drawn();
164 Editor::ensure_all_elements_drawn ()
166 controls_layout.queue_draw ();
167 ruler_label_event_box.queue_draw ();
168 time_button_event_box.queue_draw ();
173 Editor::create_editor_mixer ()
175 current_mixer_strip = new MixerStrip (*ARDOUR_UI::instance()->the_mixer(),
178 current_mixer_strip->Hiding.connect (sigc::mem_fun(*this, &Editor::current_mixer_strip_hidden));
179 current_mixer_strip->WidthChanged.connect (sigc::mem_fun (*this, &Editor::mixer_strip_width_changed));
182 current_mixer_strip->WidthChanged.connect (sigc::mem_fun(*this, &Editor::ensure_all_elements_drawn));
184 current_mixer_strip->set_embedded (true);
188 Editor::set_selected_mixer_strip (TimeAxisView& view)
194 Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
197 Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(act);
198 if (!tact || !tact->get_active()) {
199 /* not showing mixer strip presently */
204 if (current_mixer_strip == 0) {
205 create_editor_mixer ();
209 // if this is an automation track, then we shold the mixer strip should
212 boost::shared_ptr<ARDOUR::Route> route;
213 AutomationTimeAxisView* atv;
215 if ((atv = dynamic_cast<AutomationTimeAxisView*>(&view)) != 0) {
217 AudioTimeAxisView *parent = dynamic_cast<AudioTimeAxisView*>(view.get_parent());
220 route = parent->route ();
225 AudioTimeAxisView* at = dynamic_cast<AudioTimeAxisView*> (&view);
230 MidiTimeAxisView* mt = dynamic_cast<MidiTimeAxisView*> (&view);
237 if (current_mixer_strip->route() == route) {
242 current_mixer_strip->set_route (route);
243 current_mixer_strip->set_width_enum (editor_mixer_strip_width, (void*) this);
248 Editor::current_mixer_strip_hidden ()
250 Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
252 Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(act);
253 tact->set_active (false);
258 Editor::maybe_add_mixer_strip_width (XMLNode& node)
260 if (current_mixer_strip) {
261 node.add_property ("mixer-width", enum_2_string (editor_mixer_strip_width));
266 Editor::mixer_strip_width_changed ()
269 ensure_all_elements_drawn ();
272 editor_mixer_strip_width = current_mixer_strip->get_width_enum ();
276 Editor::track_mixer_selection ()
278 Mixer_UI::instance()->selection().RoutesChanged.connect (sigc::mem_fun (*this, &Editor::follow_mixer_selection));
282 Editor::follow_mixer_selection ()
284 if (!ARDOUR::Config->get_link_editor_and_mixer_selection() || _following_mixer_selection) {
288 _following_mixer_selection = true;
289 selection->block_tracks_changed (true);
291 RouteUISelection& s (Mixer_UI::instance()->selection().routes);
293 selection->clear_tracks ();
295 for (RouteUISelection::iterator i = s.begin(); i != s.end(); ++i) {
296 TimeAxisView* tav = get_route_view_by_route_id ((*i)->route()->id());
298 selection->add (tav);
302 _following_mixer_selection = false;
303 selection->block_tracks_changed (false);
304 selection->TracksChanged (); /* EMIT SIGNAL */