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.
21 #include "gtk2ardour-config.h"
24 #include "pbd/convert.h"
25 #include "pbd/stacktrace.h"
27 #include <gtkmm2ext/utils.h>
29 #include "ardour/configuration.h"
30 #include "ardour/session.h"
31 #include "ardour/audioengine.h"
34 #include "ardour/osc.h"
37 #include "ardour_ui.h"
39 #include "gui_thread.h"
40 #include "public_editor.h"
45 using namespace Gtkmm2ext;
46 using namespace ARDOUR;
51 ARDOUR_UI::toggle_time_master ()
53 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));
57 ARDOUR_UI::toggle_send_mtc ()
59 ActionManager::toggle_config_state ("options", "SendMTC", &RCConfiguration::set_send_mtc, &RCConfiguration::get_send_mtc);
63 ARDOUR_UI::toggle_send_mmc ()
65 ActionManager::toggle_config_state ("options", "SendMMC", &RCConfiguration::set_send_mmc, &RCConfiguration::get_send_mmc);
69 ARDOUR_UI::toggle_send_midi_clock ()
71 ActionManager::toggle_config_state ("options", "SendMidiClock", &RCConfiguration::set_send_midi_clock, &RCConfiguration::get_send_midi_clock);
75 ARDOUR_UI::toggle_use_mmc ()
77 ActionManager::toggle_config_state ("options", "UseMMC", &RCConfiguration::set_mmc_control, &RCConfiguration::get_mmc_control);
81 ARDOUR_UI::toggle_send_midi_feedback ()
83 ActionManager::toggle_config_state ("options", "SendMIDIfeedback", &RCConfiguration::set_midi_feedback, &RCConfiguration::get_midi_feedback);
87 ARDOUR_UI::toggle_auto_input ()
89 ActionManager::toggle_config_state_foo ("Transport", "ToggleAutoInput", mem_fun (session->config, &SessionConfiguration::set_auto_input), mem_fun (session->config, &SessionConfiguration::get_auto_input));
93 ARDOUR_UI::toggle_auto_play ()
95 ActionManager::toggle_config_state_foo ("Transport", "ToggleAutoPlay", mem_fun (session->config, &SessionConfiguration::set_auto_play), mem_fun (session->config, &SessionConfiguration::get_auto_play));
99 ARDOUR_UI::toggle_auto_return ()
101 ActionManager::toggle_config_state_foo ("Transport", "ToggleAutoReturn", mem_fun (session->config, &SessionConfiguration::set_auto_return), mem_fun (session->config, &SessionConfiguration::get_auto_return));
105 ARDOUR_UI::toggle_click ()
107 ActionManager::toggle_config_state ("Transport", "ToggleClick", &RCConfiguration::set_clicking, &RCConfiguration::get_clicking);
111 ARDOUR_UI::toggle_session_auto_loop ()
114 if (session->get_play_loop()) {
115 if (session->transport_rolling()) {
118 session->request_play_loop (false);
121 session->request_play_loop (true);
127 ARDOUR_UI::unset_dual_punch ()
129 Glib::RefPtr<Action> action = ActionManager::get_action ("Transport", "TogglePunch");
132 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(action);
134 ignore_dual_punch = true;
135 tact->set_active (false);
136 ignore_dual_punch = false;
142 ARDOUR_UI::toggle_punch ()
144 if (ignore_dual_punch) {
148 Glib::RefPtr<Action> action = ActionManager::get_action ("Transport", "TogglePunch");
152 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(action);
158 /* drive the other two actions from this one */
160 Glib::RefPtr<Action> in_action = ActionManager::get_action ("Transport", "TogglePunchIn");
161 Glib::RefPtr<Action> out_action = ActionManager::get_action ("Transport", "TogglePunchOut");
163 if (in_action && out_action) {
164 Glib::RefPtr<ToggleAction> tiact = Glib::RefPtr<ToggleAction>::cast_dynamic(in_action);
165 Glib::RefPtr<ToggleAction> toact = Glib::RefPtr<ToggleAction>::cast_dynamic(out_action);
166 tiact->set_active (tact->get_active());
167 toact->set_active (tact->get_active());
173 ARDOUR_UI::toggle_punch_in ()
175 ActionManager::toggle_config_state_foo ("Transport", "TogglePunchIn", mem_fun (session->config, &SessionConfiguration::set_punch_in), mem_fun (session->config, &SessionConfiguration::get_punch_in));
179 ARDOUR_UI::toggle_punch_out ()
181 ActionManager::toggle_config_state_foo ("Transport", "TogglePunchOut", mem_fun (session->config, &SessionConfiguration::set_punch_out), mem_fun (session->config, &SessionConfiguration::get_punch_out));
185 ARDOUR_UI::toggle_video_sync()
187 Glib::RefPtr<Action> act = ActionManager::get_action ("Transport", "ToggleVideoSync");
189 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
190 session->config.set_use_video_sync (tact->get_active());
195 ARDOUR_UI::toggle_editing_space()
197 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMaximalEditor");
199 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
200 if (tact->get_active()) {
201 maximise_editing_space ();
203 restore_editing_space ();
209 ARDOUR_UI::mtc_port_changed ()
212 bool have_midi_clock;
215 if (session->mtc_port()) {
220 if (session->midi_clock_port()) {
221 have_midi_clock = true;
223 have_midi_clock = false;
227 have_midi_clock = false;
230 positional_sync_strings.clear ();
231 positional_sync_strings.push_back (slave_source_to_string (None));
233 positional_sync_strings.push_back (slave_source_to_string (MTC));
235 if (have_midi_clock) {
236 positional_sync_strings.push_back (slave_source_to_string (MIDIClock));
238 positional_sync_strings.push_back (slave_source_to_string (JACK));
240 set_popdown_strings (sync_option_combo, positional_sync_strings);
244 ARDOUR_UI::setup_session_options ()
248 Config->ParameterChanged.connect (mem_fun (*this, &ARDOUR_UI::parameter_changed));
252 ARDOUR_UI::parameter_changed (std::string p)
254 ENSURE_GUI_THREAD (bind (mem_fun (*this, &ARDOUR_UI::parameter_changed), p));
256 if (p == "slave-source") {
258 sync_option_combo.set_active_text (slave_source_to_string (Config->get_slave_source()));
260 switch (Config->get_slave_source()) {
262 ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (true);
263 ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (true);
267 /* XXX need to make auto-play is off as well as insensitive */
268 ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (false);
269 ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (false);
273 } else if (p == "send-mtc") {
275 ActionManager::map_some_state ("options", "SendMTC", &RCConfiguration::get_send_mtc);
277 } else if (p == "send-mmc") {
279 ActionManager::map_some_state ("options", "SendMMC", &RCConfiguration::get_send_mmc);
281 } else if (p == "use-osc") {
284 if (Config->get_use_osc()) {
291 } else if (p == "mmc-control") {
292 ActionManager::map_some_state ("options", "UseMMC", &RCConfiguration::get_mmc_control);
293 } else if (p == "midi-feedback") {
294 ActionManager::map_some_state ("options", "SendMIDIfeedback", &RCConfiguration::get_midi_feedback);
295 } else if (p == "auto-play") {
296 ActionManager::map_some_state ("Transport", "ToggleAutoPlay", mem_fun (session->config, &SessionConfiguration::get_auto_play));
297 } else if (p == "auto-return") {
298 ActionManager::map_some_state ("Transport", "ToggleAutoReturn", mem_fun (session->config, &SessionConfiguration::get_auto_return));
299 } else if (p == "auto-input") {
300 ActionManager::map_some_state ("Transport", "ToggleAutoInput", mem_fun (session->config, &SessionConfiguration::get_auto_input));
301 } else if (p == "punch-out") {
302 ActionManager::map_some_state ("Transport", "TogglePunchOut", mem_fun (session->config, &SessionConfiguration::get_punch_out));
303 if (!session->config.get_punch_out()) {
306 } else if (p == "punch-in") {
307 ActionManager::map_some_state ("Transport", "TogglePunchIn", mem_fun (session->config, &SessionConfiguration::get_punch_in));
308 if (!session->config.get_punch_in()) {
311 } else if (p == "clicking") {
312 ActionManager::map_some_state ("Transport", "ToggleClick", &RCConfiguration::get_clicking);
313 } else if (p == "jack-time-master") {
314 ActionManager::map_some_state ("Transport", "ToggleTimeMaster", mem_fun (session->config, &SessionConfiguration::get_jack_time_master));
315 } else if (p == "use-video-sync") {
316 ActionManager::map_some_state ("Transport", "ToggleVideoSync", mem_fun (session->config, &SessionConfiguration::get_use_video_sync));
317 } else if (p == "shuttle-behaviour") {
319 switch (Config->get_shuttle_behaviour ()) {
321 shuttle_style_button.set_active_text (_("sprung"));
323 shuttle_box.queue_draw ();
325 if (session->transport_rolling()) {
326 shuttle_fract = SHUTTLE_FRACT_SPEED1;
327 session->request_transport_speed (1.0);
332 shuttle_style_button.set_active_text (_("wheel"));
336 } else if (p == "shuttle-units") {
338 switch (Config->get_shuttle_units()) {
340 shuttle_units_button.set_label("% ");
343 shuttle_units_button.set_label(_("ST"));
346 } else if (p == "video-pullup" || p == "smpte-format") {
348 primary_clock.set (session->audible_frame(), true);
349 secondary_clock.set (session->audible_frame(), true);
351 primary_clock.set (0, true);
352 secondary_clock.set (0, true);
354 } else if (p == "show-track-meters") {
355 editor->toggle_meter_updating();