2 Copyright (C) 2005 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 "pbd/convert.h"
21 #include "pbd/stacktrace.h"
23 #include <gtkmm2ext/utils.h>
25 #include "ardour/configuration.h"
26 #include "ardour/session.h"
27 #include "ardour/audioengine.h"
30 #include "ardour/osc.h"
33 #include "ardour_ui.h"
35 #include "gui_thread.h"
36 #include "public_editor.h"
41 using namespace Gtkmm2ext;
42 using namespace ARDOUR;
47 ARDOUR_UI::toggle_time_master ()
49 ActionManager::toggle_config_state_foo ("Transport", "ToggleTimeMaster", mem_fun (session->config, &SessionConfiguration::set_jack_time_master), mem_fun (session->config, &SessionConfiguration::get_jack_time_master));
53 ARDOUR_UI::toggle_send_mtc ()
55 ActionManager::toggle_config_state ("options", "SendMTC", &RCConfiguration::set_send_mtc, &RCConfiguration::get_send_mtc);
59 ARDOUR_UI::toggle_send_mmc ()
61 ActionManager::toggle_config_state ("options", "SendMMC", &RCConfiguration::set_send_mmc, &RCConfiguration::get_send_mmc);
65 ARDOUR_UI::toggle_send_midi_clock ()
67 ActionManager::toggle_config_state ("options", "SendMidiClock", &RCConfiguration::set_send_midi_clock, &RCConfiguration::get_send_midi_clock);
71 ARDOUR_UI::toggle_use_mmc ()
73 ActionManager::toggle_config_state ("options", "UseMMC", &RCConfiguration::set_mmc_control, &RCConfiguration::get_mmc_control);
77 ARDOUR_UI::toggle_send_midi_feedback ()
79 ActionManager::toggle_config_state ("options", "SendMIDIfeedback", &RCConfiguration::set_midi_feedback, &RCConfiguration::get_midi_feedback);
83 ARDOUR_UI::toggle_auto_input ()
85 ActionManager::toggle_config_state_foo ("Transport", "ToggleAutoInput", mem_fun (session->config, &SessionConfiguration::set_auto_input), mem_fun (session->config, &SessionConfiguration::get_auto_input));
89 ARDOUR_UI::toggle_auto_play ()
91 ActionManager::toggle_config_state_foo ("Transport", "ToggleAutoPlay", mem_fun (session->config, &SessionConfiguration::set_auto_play), mem_fun (session->config, &SessionConfiguration::get_auto_play));
95 ARDOUR_UI::toggle_auto_return ()
97 ActionManager::toggle_config_state_foo ("Transport", "ToggleAutoReturn", mem_fun (session->config, &SessionConfiguration::set_auto_return), mem_fun (session->config, &SessionConfiguration::get_auto_return));
101 ARDOUR_UI::toggle_click ()
103 ActionManager::toggle_config_state ("Transport", "ToggleClick", &RCConfiguration::set_clicking, &RCConfiguration::get_clicking);
107 ARDOUR_UI::toggle_session_auto_loop ()
110 if (session->get_play_loop()) {
111 if (session->transport_rolling()) {
114 session->request_play_loop (false);
117 session->request_play_loop (true);
123 ARDOUR_UI::unset_dual_punch ()
125 Glib::RefPtr<Action> action = ActionManager::get_action ("Transport", "TogglePunch");
128 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(action);
130 ignore_dual_punch = true;
131 tact->set_active (false);
132 ignore_dual_punch = false;
138 ARDOUR_UI::toggle_punch ()
140 if (ignore_dual_punch) {
144 Glib::RefPtr<Action> action = ActionManager::get_action ("Transport", "TogglePunch");
148 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(action);
154 /* drive the other two actions from this one */
156 Glib::RefPtr<Action> in_action = ActionManager::get_action ("Transport", "TogglePunchIn");
157 Glib::RefPtr<Action> out_action = ActionManager::get_action ("Transport", "TogglePunchOut");
159 if (in_action && out_action) {
160 Glib::RefPtr<ToggleAction> tiact = Glib::RefPtr<ToggleAction>::cast_dynamic(in_action);
161 Glib::RefPtr<ToggleAction> toact = Glib::RefPtr<ToggleAction>::cast_dynamic(out_action);
162 tiact->set_active (tact->get_active());
163 toact->set_active (tact->get_active());
169 ARDOUR_UI::toggle_punch_in ()
171 ActionManager::toggle_config_state_foo ("Transport", "TogglePunchIn", mem_fun (session->config, &SessionConfiguration::set_punch_in), mem_fun (session->config, &SessionConfiguration::get_punch_in));
175 ARDOUR_UI::toggle_punch_out ()
177 ActionManager::toggle_config_state_foo ("Transport", "TogglePunchOut", mem_fun (session->config, &SessionConfiguration::set_punch_out), mem_fun (session->config, &SessionConfiguration::get_punch_out));
181 ARDOUR_UI::toggle_video_sync()
183 Glib::RefPtr<Action> act = ActionManager::get_action ("Transport", "ToggleVideoSync");
185 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
186 session->config.set_use_video_sync (tact->get_active());
191 ARDOUR_UI::toggle_editing_space()
193 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMaximalEditor");
195 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
196 if (tact->get_active()) {
197 maximise_editing_space ();
199 restore_editing_space ();
205 ARDOUR_UI::mtc_port_changed ()
208 bool have_midi_clock;
211 if (session->mtc_port()) {
216 if (session->midi_clock_port()) {
217 have_midi_clock = true;
219 have_midi_clock = false;
223 have_midi_clock = false;
226 positional_sync_strings.clear ();
227 positional_sync_strings.push_back (slave_source_to_string (None));
229 positional_sync_strings.push_back (slave_source_to_string (MTC));
231 if (have_midi_clock) {
232 positional_sync_strings.push_back (slave_source_to_string (MIDIClock));
234 positional_sync_strings.push_back (slave_source_to_string (JACK));
236 set_popdown_strings (sync_option_combo, positional_sync_strings);
240 ARDOUR_UI::setup_session_options ()
244 Config->ParameterChanged.connect (mem_fun (*this, &ARDOUR_UI::parameter_changed));
248 ARDOUR_UI::parameter_changed (std::string p)
250 ENSURE_GUI_THREAD (bind (mem_fun (*this, &ARDOUR_UI::parameter_changed), p));
252 if (p == "slave-source") {
254 sync_option_combo.set_active_text (slave_source_to_string (Config->get_slave_source()));
256 switch (Config->get_slave_source()) {
258 ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (true);
259 ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (true);
263 /* XXX need to make auto-play is off as well as insensitive */
264 ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (false);
265 ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (false);
269 } else if (p == "send-mtc") {
271 ActionManager::map_some_state ("options", "SendMTC", &RCConfiguration::get_send_mtc);
273 } else if (p == "send-mmc") {
275 ActionManager::map_some_state ("options", "SendMMC", &RCConfiguration::get_send_mmc);
277 } else if (p == "use-osc") {
280 if (Config->get_use_osc()) {
287 } else if (p == "mmc-control") {
288 ActionManager::map_some_state ("options", "UseMMC", &RCConfiguration::get_mmc_control);
289 } else if (p == "midi-feedback") {
290 ActionManager::map_some_state ("options", "SendMIDIfeedback", &RCConfiguration::get_midi_feedback);
291 } else if (p == "auto-play") {
292 ActionManager::map_some_state ("Transport", "ToggleAutoPlay", mem_fun (session->config, &SessionConfiguration::get_auto_play));
293 } else if (p == "auto-return") {
294 ActionManager::map_some_state ("Transport", "ToggleAutoReturn", mem_fun (session->config, &SessionConfiguration::get_auto_return));
295 } else if (p == "auto-input") {
296 ActionManager::map_some_state ("Transport", "ToggleAutoInput", mem_fun (session->config, &SessionConfiguration::get_auto_input));
297 } else if (p == "punch-out") {
298 ActionManager::map_some_state ("Transport", "TogglePunchOut", mem_fun (session->config, &SessionConfiguration::get_punch_out));
299 if (!session->config.get_punch_out()) {
302 } else if (p == "punch-in") {
303 ActionManager::map_some_state ("Transport", "TogglePunchIn", mem_fun (session->config, &SessionConfiguration::get_punch_in));
304 if (!session->config.get_punch_in()) {
307 } else if (p == "clicking") {
308 ActionManager::map_some_state ("Transport", "ToggleClick", &RCConfiguration::get_clicking);
309 } else if (p == "jack-time-master") {
310 ActionManager::map_some_state ("Transport", "ToggleTimeMaster", mem_fun (session->config, &SessionConfiguration::get_jack_time_master));
311 } else if (p == "use-video-sync") {
312 ActionManager::map_some_state ("Transport", "ToggleVideoSync", mem_fun (session->config, &SessionConfiguration::get_use_video_sync));
313 } else if (p == "shuttle-behaviour") {
315 switch (Config->get_shuttle_behaviour ()) {
317 shuttle_style_button.set_active_text (_("sprung"));
319 shuttle_box.queue_draw ();
321 if (session->transport_rolling()) {
322 shuttle_fract = SHUTTLE_FRACT_SPEED1;
323 session->request_transport_speed (1.0);
328 shuttle_style_button.set_active_text (_("wheel"));
332 } else if (p == "shuttle-units") {
334 switch (Config->get_shuttle_units()) {
336 shuttle_units_button.set_label("% ");
339 shuttle_units_button.set_label(_("ST"));
342 } else if (p == "video-pullup" || p == "smpte-format") {
344 primary_clock.set (session->audible_frame(), true);
345 secondary_clock.set (session->audible_frame(), true);
347 primary_clock.set (0, true);
348 secondary_clock.set (0, true);
350 } else if (p == "show-track-meters") {
351 editor->toggle_meter_updating();