2 * Copyright (C) 2005-2008 Nick Mainsbridge <mainsbridge@gmail.com>
3 * Copyright (C) 2005-2017 Paul Davis <paul@linuxaudiosystems.com>
4 * Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com>
5 * Copyright (C) 2006-2011 David Robillard <d@drobilla.net>
6 * Copyright (C) 2007-2011 Carl Hetherington <carl@carlh.net>
7 * Copyright (C) 2014-2017 Robin Gareus <robin@gareus.org>
8 * Copyright (C) 2014 Ben Loftis <ben@harrisonconsoles.com>
9 * Copyright (C) 2015-2016 Tim Mayberry <mojofunk@gmail.com>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include "gtk2ardour-config.h"
30 #include <glibmm/miscutils.h>
31 #include <gtkmm/messagedialog.h>
32 #include <gtkmm2ext/utils.h>
33 #include <gtkmm2ext/window_title.h>
35 #include "pbd/enumwriter.h"
37 #include "ardour/rc_configuration.h"
39 #include "control_protocol/control_protocol.h"
42 #include "ardour_ui.h"
43 #include "audio_time_axis.h"
44 #include "automation_time_axis.h"
46 #include "editor_route_groups.h"
47 #include "editor_regions.h"
48 #include "enums_convert.h"
49 #include "gui_thread.h"
50 #include "midi_time_axis.h"
51 #include "mixer_strip.h"
53 #include "selection.h"
54 #include "ui_config.h"
59 using namespace Gtkmm2ext;
63 Editor::editor_mixer_button_toggled ()
65 Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
67 Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(act);
68 show_editor_mixer (tact->get_active());
73 Editor::editor_list_button_toggled ()
75 Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-list"));
77 Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(act);
78 show_editor_list (tact->get_active());
83 Editor::show_editor_mixer (bool yn)
85 boost::shared_ptr<ARDOUR::Route> r;
87 show_editor_mixer_when_tracks_arrive = false;
90 Gtk::Window* toplevel = current_toplevel();
91 Glib::RefPtr<Gdk::Window> win;
92 Glib::RefPtr<Gdk::Screen> screen;
95 win = toplevel->get_window();
99 screen = win->get_screen();
101 screen = Gdk::Screen::get_default();
104 if (g_getenv ("ARDOUR_LOVES_STUPID_TINY_SCREENS") == 0 && screen && screen->get_height() < 700) {
105 Gtk::MessageDialog msg (_("This screen is not tall enough to display the editor mixer"));
112 show_editor_mixer_when_tracks_arrive = yn;
118 if (selection->tracks.empty()) {
120 if (track_views.empty()) {
121 show_editor_mixer_when_tracks_arrive = true;
125 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
126 RouteTimeAxisView* atv;
128 if ((atv = dynamic_cast<RouteTimeAxisView*> (*i)) != 0) {
135 sort_track_selection (selection->tracks);
137 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
138 RouteTimeAxisView* atv;
140 if ((atv = dynamic_cast<RouteTimeAxisView*> (*i)) != 0) {
148 if (current_mixer_strip == 0) {
149 create_editor_mixer ();
153 if (current_mixer_strip && current_mixer_strip->get_parent() == 0) {
154 global_hpacker.pack_start (*current_mixer_strip, Gtk::PACK_SHRINK );
155 global_hpacker.reorder_child (*current_mixer_strip, 0);
156 current_mixer_strip->show ();
160 current_mixer_strip->set_route (r);
161 current_mixer_strip->set_width_enum (editor_mixer_strip_width, (void*) this);
166 if (current_mixer_strip) {
167 if (current_mixer_strip->get_parent() != 0) {
168 global_hpacker.remove (*current_mixer_strip);
174 /* XXX gtk problem here */
175 ensure_all_elements_drawn();
181 Editor::ensure_all_elements_drawn ()
183 controls_layout.queue_draw ();
184 time_bars_event_box.queue_draw ();
189 Editor::create_editor_mixer ()
191 current_mixer_strip = new MixerStrip (*ARDOUR_UI::instance()->the_mixer(), _session, false);
192 current_mixer_strip->Hiding.connect (sigc::mem_fun(*this, &Editor::current_mixer_strip_hidden));
193 current_mixer_strip->WidthChanged.connect (sigc::mem_fun (*this, &Editor::mixer_strip_width_changed));
196 current_mixer_strip->WidthChanged.connect (sigc::mem_fun(*this, &Editor::ensure_all_elements_drawn));
198 current_mixer_strip->set_embedded (true);
203 Editor::set_selected_mixer_strip (TimeAxisView& view)
209 // if this is an automation track, then we shold the mixer strip should
212 boost::shared_ptr<ARDOUR::Stripable> stripable;
213 AutomationTimeAxisView* atv;
215 if ((atv = dynamic_cast<AutomationTimeAxisView*>(&view)) != 0) {
216 AudioTimeAxisView *parent = dynamic_cast<AudioTimeAxisView*>(view.get_parent());
218 stripable = parent->stripable ();
221 StripableTimeAxisView* stav = dynamic_cast<StripableTimeAxisView*> (&view);
223 stripable = stav->stripable();
227 /* Typically this is set by changing the TAV selection but if for any
228 * reason we decide to show a different strip for some reason, make
229 * sure that control surfaces can find it.
231 ARDOUR::ControlProtocol::set_first_selected_stripable (stripable);
233 Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
236 Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(act);
237 if (!tact || !tact->get_active()) {
238 /* not showing mixer strip presently */
243 if (current_mixer_strip == 0) {
244 create_editor_mixer ();
247 boost::shared_ptr<ARDOUR::Route> route = boost::dynamic_pointer_cast<ARDOUR::Route> (stripable);
248 if (current_mixer_strip->route() == route) {
253 current_mixer_strip->set_route (route);
254 current_mixer_strip->set_width_enum (editor_mixer_strip_width, (void*) this);
259 Editor::current_mixer_strip_hidden ()
261 Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
263 Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(act);
264 tact->set_active (false);
269 Editor::maybe_add_mixer_strip_width (XMLNode& node)
271 if (current_mixer_strip) {
272 node.set_property ("mixer-width", editor_mixer_strip_width);
277 Editor::mixer_strip_width_changed ()
280 ensure_all_elements_drawn ();
283 editor_mixer_strip_width = current_mixer_strip->get_width_enum ();