fix inverse solo push to work properly in both exclusive and non-exclusive solo modes
[ardour2.git] / gtk2_ardour / editor_mixer.cc
blob8cffd5c64b357368045662f6486db103a8dc83a8
1 /*
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 <glibmm/miscutils.h>
21 #include <gtkmm2ext/utils.h>
22 #include <gtkmm2ext/window_title.h>
24 #include "pbd/enumwriter.h"
26 #include "editor.h"
27 #include "mixer_strip.h"
28 #include "ardour_ui.h"
29 #include "selection.h"
30 #include "audio_time_axis.h"
31 #include "actions.h"
32 #include "editor_routes.h"
33 #include "editor_route_groups.h"
34 #include "editor_regions.h"
35 #include "gui_thread.h"
37 #include "i18n.h"
39 using namespace std;
40 using namespace Gtkmm2ext;
41 using namespace PBD;
43 void
44 Editor::editor_mixer_button_toggled ()
46 Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
47 if (act) {
48 Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(act);
49 show_editor_mixer (tact->get_active());
53 void
54 Editor::editor_list_button_toggled ()
56 Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-list"));
57 if (act) {
58 Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(act);
59 show_editor_list (tact->get_active());
63 void
64 Editor::show_editor_mixer (bool yn)
66 boost::shared_ptr<ARDOUR::Route> r;
68 show_editor_mixer_when_tracks_arrive = false;
70 if (!_session) {
71 show_editor_mixer_when_tracks_arrive = yn;
72 return;
75 if (yn) {
77 if (selection->tracks.empty()) {
79 if (track_views.empty()) {
80 show_editor_mixer_when_tracks_arrive = true;
81 return;
84 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
85 RouteTimeAxisView* atv;
87 if ((atv = dynamic_cast<RouteTimeAxisView*> (*i)) != 0) {
88 r = atv->route();
89 break;
93 } else {
94 sort_track_selection ();
96 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
97 RouteTimeAxisView* atv;
99 if ((atv = dynamic_cast<RouteTimeAxisView*> (*i)) != 0) {
100 r = atv->route();
101 break;
106 if (r) {
107 if (current_mixer_strip == 0) {
108 create_editor_mixer ();
111 current_mixer_strip->set_route (r);
112 current_mixer_strip->set_width_enum (editor_mixer_strip_width, (void*) this);
115 if (current_mixer_strip->get_parent() == 0) {
116 global_hpacker.pack_start (*current_mixer_strip, Gtk::PACK_SHRINK );
117 global_hpacker.reorder_child (*current_mixer_strip, 0);
118 current_mixer_strip->show_all ();
121 } else {
123 if (current_mixer_strip) {
124 if (current_mixer_strip->get_parent() != 0) {
125 global_hpacker.remove (*current_mixer_strip);
130 #ifdef GTKOSX
131 /* XXX gtk problem here */
132 ensure_all_elements_drawn();
133 #endif
136 #ifdef GTKOSX
137 void
138 Editor::ensure_all_elements_drawn ()
140 controls_layout.queue_draw ();
141 ruler_label_event_box.queue_draw ();
142 time_button_event_box.queue_draw ();
144 #endif
146 void
147 Editor::create_editor_mixer ()
149 current_mixer_strip = new MixerStrip (*ARDOUR_UI::instance()->the_mixer(),
150 _session,
151 false);
152 current_mixer_strip->Hiding.connect (sigc::mem_fun(*this, &Editor::current_mixer_strip_hidden));
154 #ifdef GTKOSX
155 current_mixer_strip->WidthChanged.connect (sigc::mem_fun(*this, &Editor::ensure_all_elements_drawn));
156 #endif
157 current_mixer_strip->set_embedded (true);
160 void
161 Editor::set_selected_mixer_strip (TimeAxisView& view)
163 RouteTimeAxisView* at;
165 if (!_session || (at = dynamic_cast<RouteTimeAxisView*>(&view)) == 0) {
166 return;
169 Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
171 if (act) {
172 Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(act);
173 if (!tact || !tact->get_active()) {
174 /* not showing mixer strip presently */
175 return;
179 if (current_mixer_strip == 0) {
180 create_editor_mixer ();
183 /* might be nothing to do */
185 if (current_mixer_strip->route() == at->route()) {
186 return;
189 current_mixer_strip->set_route (at->route());
190 current_mixer_strip->set_width_enum (editor_mixer_strip_width, (void*) this);
193 void
194 Editor::current_mixer_strip_hidden ()
196 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
198 RouteTimeAxisView* tmp;
200 if ((tmp = dynamic_cast<RouteTimeAxisView*>(*i)) != 0) {
201 if (tmp->route() == current_mixer_strip->route()) {
202 (*i)->set_selected (false);
203 break;
208 Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
209 if (act) {
210 Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(act);
211 tact->set_active (false);
215 void
216 Editor::maybe_add_mixer_strip_width (XMLNode& node)
218 if (current_mixer_strip) {
219 node.add_property ("mixer-width", enum_2_string (current_mixer_strip->get_width_enum()));