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;
50 ARDOUR_UI::toggle_keep_tearoffs ()
52 ActionManager::toggle_config_state ("Common", "KeepTearoffs", &RCConfiguration::set_keep_tearoffs, &RCConfiguration::get_keep_tearoffs);
54 ARDOUR_UI::toggle_editing_space ();
58 ARDOUR_UI::toggle_external_sync()
60 ActionManager::toggle_config_state_foo ("Transport", "ToggleExternalSync", sigc::mem_fun (_session->config, &SessionConfiguration::set_external_sync), sigc::mem_fun (_session->config, &SessionConfiguration::get_external_sync));
64 ARDOUR_UI::toggle_time_master ()
66 ActionManager::toggle_config_state_foo ("Transport", "ToggleTimeMaster", sigc::mem_fun (_session->config, &SessionConfiguration::set_jack_time_master), sigc::mem_fun (_session->config, &SessionConfiguration::get_jack_time_master));
70 ARDOUR_UI::toggle_send_mtc ()
72 ActionManager::toggle_config_state ("options", "SendMTC", &RCConfiguration::set_send_mtc, &RCConfiguration::get_send_mtc);
76 ARDOUR_UI::toggle_send_mmc ()
78 ActionManager::toggle_config_state ("options", "SendMMC", &RCConfiguration::set_send_mmc, &RCConfiguration::get_send_mmc);
82 ARDOUR_UI::toggle_send_midi_clock ()
84 ActionManager::toggle_config_state ("options", "SendMidiClock", &RCConfiguration::set_send_midi_clock, &RCConfiguration::get_send_midi_clock);
88 ARDOUR_UI::toggle_use_mmc ()
90 ActionManager::toggle_config_state ("options", "UseMMC", &RCConfiguration::set_mmc_control, &RCConfiguration::get_mmc_control);
94 ARDOUR_UI::toggle_send_midi_feedback ()
96 ActionManager::toggle_config_state ("options", "SendMIDIfeedback", &RCConfiguration::set_midi_feedback, &RCConfiguration::get_midi_feedback);
100 ARDOUR_UI::toggle_auto_input ()
102 ActionManager::toggle_config_state_foo ("Transport", "ToggleAutoInput", sigc::mem_fun (_session->config, &SessionConfiguration::set_auto_input), sigc::mem_fun (_session->config, &SessionConfiguration::get_auto_input));
106 ARDOUR_UI::toggle_auto_play ()
108 ActionManager::toggle_config_state_foo ("Transport", "ToggleAutoPlay", sigc::mem_fun (_session->config, &SessionConfiguration::set_auto_play), sigc::mem_fun (_session->config, &SessionConfiguration::get_auto_play));
112 ARDOUR_UI::toggle_auto_return ()
114 ActionManager::toggle_config_state_foo ("Transport", "ToggleAutoReturn", sigc::mem_fun (_session->config, &SessionConfiguration::set_auto_return), sigc::mem_fun (_session->config, &SessionConfiguration::get_auto_return));
118 ARDOUR_UI::toggle_click ()
120 ActionManager::toggle_config_state ("Transport", "ToggleClick", &RCConfiguration::set_clicking, &RCConfiguration::get_clicking);
124 ARDOUR_UI::unset_dual_punch ()
126 Glib::RefPtr<Action> action = ActionManager::get_action ("Transport", "TogglePunch");
129 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(action);
131 ignore_dual_punch = true;
132 tact->set_active (false);
133 ignore_dual_punch = false;
139 ARDOUR_UI::toggle_punch ()
141 if (ignore_dual_punch) {
145 Glib::RefPtr<Action> action = ActionManager::get_action ("Transport", "TogglePunch");
149 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(action);
155 /* drive the other two actions from this one */
157 Glib::RefPtr<Action> in_action = ActionManager::get_action ("Transport", "TogglePunchIn");
158 Glib::RefPtr<Action> out_action = ActionManager::get_action ("Transport", "TogglePunchOut");
160 if (in_action && out_action) {
161 Glib::RefPtr<ToggleAction> tiact = Glib::RefPtr<ToggleAction>::cast_dynamic(in_action);
162 Glib::RefPtr<ToggleAction> toact = Glib::RefPtr<ToggleAction>::cast_dynamic(out_action);
163 tiact->set_active (tact->get_active());
164 toact->set_active (tact->get_active());
170 ARDOUR_UI::toggle_punch_in ()
172 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Transport"), X_("TogglePunchIn"));
177 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
182 if (tact->get_active() != _session->config.get_punch_in()) {
183 _session->config.set_punch_in (tact->get_active ());
186 if (tact->get_active()) {
187 /* if punch-in is turned on, make sure the loop/punch ruler is visible, and stop it being hidden,
188 to avoid confusing the user */
189 show_loop_punch_ruler_and_disallow_hide ();
192 reenable_hide_loop_punch_ruler_if_appropriate ();
196 ARDOUR_UI::toggle_punch_out ()
198 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Transport"), X_("TogglePunchOut"));
203 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
208 if (tact->get_active() != _session->config.get_punch_out()) {
209 _session->config.set_punch_out (tact->get_active ());
212 if (tact->get_active()) {
213 /* if punch-out is turned on, make sure the loop/punch ruler is visible, and stop it being hidden,
214 to avoid confusing the user */
215 show_loop_punch_ruler_and_disallow_hide ();
218 reenable_hide_loop_punch_ruler_if_appropriate ();
222 ARDOUR_UI::show_loop_punch_ruler_and_disallow_hide ()
224 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Rulers"), "toggle-loop-punch-ruler");
229 act->set_sensitive (false);
231 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
236 if (!tact->get_active()) {
241 /* This is a bit of a silly name for a method */
243 ARDOUR_UI::reenable_hide_loop_punch_ruler_if_appropriate ()
245 if (!_session->config.get_punch_in() && !_session->config.get_punch_out()) {
246 /* if punch in/out are now both off, reallow hiding of the loop/punch ruler */
247 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Rulers"), "toggle-loop-punch-ruler");
249 act->set_sensitive (true);
255 ARDOUR_UI::toggle_video_sync()
257 Glib::RefPtr<Action> act = ActionManager::get_action ("Transport", "ToggleVideoSync");
259 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
260 _session->config.set_use_video_sync (tact->get_active());
265 ARDOUR_UI::toggle_editing_space()
267 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMaximalEditor");
269 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
270 if (tact->get_active()) {
271 maximise_editing_space ();
273 restore_editing_space ();
279 ARDOUR_UI::setup_session_options ()
281 _session->config.ParameterChanged.connect (_session_connections, MISSING_INVALIDATOR, ui_bind (&ARDOUR_UI::parameter_changed, this, _1), gui_context());
282 boost::function<void (std::string)> pc (boost::bind (&ARDOUR_UI::parameter_changed, this, _1));
283 _session->config.map_parameters (pc);
288 ARDOUR_UI::handle_sync_change ()
293 if (!_session->config.get_external_sync()) {
294 sync_button.set_label (_("Internal"));
295 ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (true);
296 ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (true);
298 sync_button.set_label (_("External"));
299 /* XXX need to make auto-play is off as well as insensitive */
300 ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (false);
301 ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (false);
308 ARDOUR_UI::parameter_changed (std::string p)
310 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::parameter_changed, p)
312 if (p == "external-sync") {
314 ActionManager::map_some_state ("Transport", "ToggleExternalSync", sigc::mem_fun (_session->config, &SessionConfiguration::get_external_sync));
316 if (!_session->config.get_external_sync()) {
317 sync_button.set_label (_("Internal"));
318 ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (true);
319 ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (true);
321 sync_button.set_label (sync_source_to_string (_session->config.get_sync_source()));
322 /* XXX need to make auto-play is off as well as insensitive */
323 ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (false);
324 ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (false);
327 } else if (p == "send-mtc") {
329 ActionManager::map_some_state ("options", "SendMTC", &RCConfiguration::get_send_mtc);
331 } else if (p == "send-mmc") {
333 ActionManager::map_some_state ("options", "SendMMC", &RCConfiguration::get_send_mmc);
335 } else if (p == "use-osc") {
338 if (Config->get_use_osc()) {
345 } else if (p == "keep-tearoffs") {
346 ActionManager::map_some_state ("Common", "KeepTearoffs", &RCConfiguration::get_keep_tearoffs);
347 } else if (p == "mmc-control") {
348 ActionManager::map_some_state ("options", "UseMMC", &RCConfiguration::get_mmc_control);
349 } else if (p == "midi-feedback") {
350 ActionManager::map_some_state ("options", "SendMIDIfeedback", &RCConfiguration::get_midi_feedback);
351 } else if (p == "auto-play") {
352 ActionManager::map_some_state ("Transport", "ToggleAutoPlay", sigc::mem_fun (_session->config, &SessionConfiguration::get_auto_play));
353 } else if (p == "auto-return") {
354 ActionManager::map_some_state ("Transport", "ToggleAutoReturn", sigc::mem_fun (_session->config, &SessionConfiguration::get_auto_return));
355 } else if (p == "auto-input") {
356 ActionManager::map_some_state ("Transport", "ToggleAutoInput", sigc::mem_fun (_session->config, &SessionConfiguration::get_auto_input));
357 } else if (p == "punch-out") {
358 ActionManager::map_some_state ("Transport", "TogglePunchOut", sigc::mem_fun (_session->config, &SessionConfiguration::get_punch_out));
359 if (!_session->config.get_punch_out()) {
362 } else if (p == "punch-in") {
363 ActionManager::map_some_state ("Transport", "TogglePunchIn", sigc::mem_fun (_session->config, &SessionConfiguration::get_punch_in));
364 if (!_session->config.get_punch_in()) {
367 } else if (p == "clicking") {
368 ActionManager::map_some_state ("Transport", "ToggleClick", &RCConfiguration::get_clicking);
369 } else if (p == "jack-time-master") {
370 ActionManager::map_some_state ("Transport", "ToggleTimeMaster", sigc::mem_fun (_session->config, &SessionConfiguration::get_jack_time_master));
371 } else if (p == "use-video-sync") {
372 ActionManager::map_some_state ("Transport", "ToggleVideoSync", sigc::mem_fun (_session->config, &SessionConfiguration::get_use_video_sync));
373 } else if (p == "shuttle-behaviour") {
375 switch (Config->get_shuttle_behaviour ()) {
377 shuttle_style_button.set_active_text (_("sprung"));
379 shuttle_box.queue_draw ();
381 if (_session->transport_rolling()) {
382 shuttle_fract = SHUTTLE_FRACT_SPEED1;
383 _session->request_transport_speed (1.0);
388 shuttle_style_button.set_active_text (_("wheel"));
392 } else if (p == "shuttle-units") {
394 switch (Config->get_shuttle_units()) {
396 shuttle_units_button.set_label("% ");
399 shuttle_units_button.set_label(_("ST"));
402 } else if (p == "video-pullup" || p == "timecode-format") {
403 reset_main_clocks ();
404 } else if (p == "show-track-meters") {
405 editor->toggle_meter_updating();
410 ARDOUR_UI::reset_main_clocks ()
412 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::reset_main_clocks)
415 primary_clock.set (_session->audible_frame(), true);
416 secondary_clock.set (_session->audible_frame(), true);
418 primary_clock.set (0, true);
419 secondary_clock.set (0, true);