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"
33 #include "control_protocol/control_protocol.h"
36 #include "ardour_ui.h"
37 #include "audio_time_axis.h"
38 #include "automation_time_axis.h"
40 #include "editor_route_groups.h"
41 #include "editor_regions.h"
42 #include "gui_thread.h"
43 #include "midi_time_axis.h"
44 #include "mixer_strip.h"
46 #include "selection.h"
47 #include "ui_config.h"
52 using namespace Gtkmm2ext;
56 Editor::editor_mixer_button_toggled ()
58 Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
60 Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(act);
61 show_editor_mixer (tact->get_active());
66 Editor::editor_list_button_toggled ()
68 Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-list"));
70 Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(act);
71 show_editor_list (tact->get_active());
76 Editor::show_editor_mixer (bool yn)
78 boost::shared_ptr<ARDOUR::Route> r;
80 show_editor_mixer_when_tracks_arrive = false;
83 Gtk::Window* toplevel = current_toplevel();
84 Glib::RefPtr<Gdk::Window> win;
85 Glib::RefPtr<Gdk::Screen> screen;
88 win = toplevel->get_window();
92 screen = win->get_screen();
94 screen = Gdk::Screen::get_default();
97 if (g_getenv ("ARDOUR_LOVES_STUPID_TINY_SCREENS") == 0 && screen && screen->get_height() < 700) {
98 Gtk::MessageDialog msg (_("This screen is not tall enough to display the editor mixer"));
105 show_editor_mixer_when_tracks_arrive = yn;
111 if (selection->tracks.empty()) {
113 if (track_views.empty()) {
114 show_editor_mixer_when_tracks_arrive = true;
118 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
119 RouteTimeAxisView* atv;
121 if ((atv = dynamic_cast<RouteTimeAxisView*> (*i)) != 0) {
128 sort_track_selection (selection->tracks);
130 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
131 RouteTimeAxisView* atv;
133 if ((atv = dynamic_cast<RouteTimeAxisView*> (*i)) != 0) {
141 if (current_mixer_strip == 0) {
142 create_editor_mixer ();
146 if (current_mixer_strip && current_mixer_strip->get_parent() == 0) {
147 global_hpacker.pack_start (*current_mixer_strip, Gtk::PACK_SHRINK );
148 global_hpacker.reorder_child (*current_mixer_strip, 0);
149 current_mixer_strip->show ();
153 current_mixer_strip->set_route (r);
154 current_mixer_strip->set_width_enum (editor_mixer_strip_width, (void*) this);
159 if (current_mixer_strip) {
160 if (current_mixer_strip->get_parent() != 0) {
161 global_hpacker.remove (*current_mixer_strip);
167 /* XXX gtk problem here */
168 ensure_all_elements_drawn();
174 Editor::ensure_all_elements_drawn ()
176 controls_layout.queue_draw ();
177 time_bars_event_box.queue_draw ();
182 Editor::create_editor_mixer ()
184 current_mixer_strip = new MixerStrip (*ARDOUR_UI::instance()->the_mixer(), _session, false);
185 current_mixer_strip->Hiding.connect (sigc::mem_fun(*this, &Editor::current_mixer_strip_hidden));
186 current_mixer_strip->WidthChanged.connect (sigc::mem_fun (*this, &Editor::mixer_strip_width_changed));
189 current_mixer_strip->WidthChanged.connect (sigc::mem_fun(*this, &Editor::ensure_all_elements_drawn));
191 current_mixer_strip->set_embedded (true);
196 Editor::set_selected_mixer_strip (TimeAxisView& view)
202 // if this is an automation track, then we shold the mixer strip should
205 boost::shared_ptr<ARDOUR::Route> route;
206 AutomationTimeAxisView* atv;
208 if ((atv = dynamic_cast<AutomationTimeAxisView*>(&view)) != 0) {
210 AudioTimeAxisView *parent = dynamic_cast<AudioTimeAxisView*>(view.get_parent());
213 route = parent->route ();
218 AudioTimeAxisView* at = dynamic_cast<AudioTimeAxisView*> (&view);
223 MidiTimeAxisView* mt = dynamic_cast<MidiTimeAxisView*> (&view);
230 /* Typically this is set by changing the TAV selection but if for any
231 reason we decide to show a different strip for some reason, make
232 sure that control surfaces can find it.
234 ARDOUR::ControlProtocol::set_first_selected_stripable (route);
236 Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
239 Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(act);
240 if (!tact || !tact->get_active()) {
241 /* not showing mixer strip presently */
246 if (current_mixer_strip == 0) {
247 create_editor_mixer ();
250 if (current_mixer_strip->route() == route) {
255 current_mixer_strip->set_route (route);
256 current_mixer_strip->set_width_enum (editor_mixer_strip_width, (void*) this);
261 Editor::current_mixer_strip_hidden ()
263 Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
265 Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(act);
266 tact->set_active (false);
271 Editor::maybe_add_mixer_strip_width (XMLNode& node)
273 if (current_mixer_strip) {
274 node.add_property ("mixer-width", enum_2_string (editor_mixer_strip_width));
279 Editor::mixer_strip_width_changed ()
282 ensure_all_elements_drawn ();
285 editor_mixer_strip_width = current_mixer_strip->get_width_enum ();
289 Editor::track_mixer_selection ()
291 Mixer_UI::instance()->selection().RoutesChanged.connect (sigc::mem_fun (*this, &Editor::follow_mixer_selection));
295 Editor::follow_mixer_selection ()
297 if (_following_mixer_selection) {
301 _following_mixer_selection = true;
302 selection->block_tracks_changed (true);
304 AxisViewSelection& s (Mixer_UI::instance()->selection().axes);
306 selection->clear_tracks ();
308 for (AxisViewSelection::iterator i = s.begin(); i != s.end(); ++i) {
309 TimeAxisView* tav = axis_view_from_stripable ((*i)->stripable());
311 selection->add (tav);
315 _following_mixer_selection = false;
316 selection->block_tracks_changed (false);
317 selection->TracksChanged (); /* EMIT SIGNAL */