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/rc_configuration.h"
30 #include "ardour/session.h"
33 #include "ardour/osc.h"
36 #include "audio_clock.h"
37 #include "ardour_ui.h"
39 #include "gui_thread.h"
40 #include "public_editor.h"
41 #include "main_clock.h"
46 using namespace Gtkmm2ext;
47 using namespace ARDOUR;
51 ARDOUR_UI::toggle_keep_tearoffs ()
53 ActionManager::toggle_config_state ("Common", "KeepTearoffs", &RCConfiguration::set_keep_tearoffs, &RCConfiguration::get_keep_tearoffs);
55 ARDOUR_UI::update_tearoff_visibility();
59 ARDOUR_UI::toggle_external_sync()
62 if (_session->config.get_video_pullup() != 0.0f) {
63 if (Config->get_sync_source() == JACK) {
65 _("It is not possible to use JACK as the the sync source\n\
66 when the pull up/down setting is non-zero."));
72 /* activating a slave is a session-property.
73 * The slave type is a RC property.
74 * When the slave is active is must not be reconfigured.
75 * This is a UI limitation, imposed by audio-clock and
76 * status displays which combine RC-config & session-properties.
78 * Notficy RCOptionEditor by emitting a signal if the active
81 Config->ParameterChanged("sync-source");
83 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));
88 ARDOUR_UI::toggle_time_master ()
90 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));
94 ARDOUR_UI::toggle_send_mtc ()
96 ActionManager::toggle_config_state ("options", "SendMTC", &RCConfiguration::set_send_mtc, &RCConfiguration::get_send_mtc);
100 ARDOUR_UI::toggle_send_mmc ()
102 ActionManager::toggle_config_state ("options", "SendMMC", &RCConfiguration::set_send_mmc, &RCConfiguration::get_send_mmc);
106 ARDOUR_UI::toggle_send_midi_clock ()
108 ActionManager::toggle_config_state ("options", "SendMidiClock", &RCConfiguration::set_send_midi_clock, &RCConfiguration::get_send_midi_clock);
112 ARDOUR_UI::toggle_use_mmc ()
114 ActionManager::toggle_config_state ("options", "UseMMC", &RCConfiguration::set_mmc_control, &RCConfiguration::get_mmc_control);
118 ARDOUR_UI::toggle_send_midi_feedback ()
120 ActionManager::toggle_config_state ("options", "SendMIDIfeedback", &RCConfiguration::set_midi_feedback, &RCConfiguration::get_midi_feedback);
124 ARDOUR_UI::toggle_auto_input ()
126 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));
130 ARDOUR_UI::toggle_auto_play ()
132 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));
136 ARDOUR_UI::toggle_auto_return ()
138 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));
142 ARDOUR_UI::toggle_click ()
144 ActionManager::toggle_config_state ("Transport", "ToggleClick", &RCConfiguration::set_clicking, &RCConfiguration::get_clicking);
148 ARDOUR_UI::unset_dual_punch ()
150 Glib::RefPtr<Action> action = ActionManager::get_action ("Transport", "TogglePunch");
153 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(action);
155 ignore_dual_punch = true;
156 tact->set_active (false);
157 ignore_dual_punch = false;
163 ARDOUR_UI::toggle_punch ()
165 if (ignore_dual_punch) {
169 Glib::RefPtr<Action> action = ActionManager::get_action ("Transport", "TogglePunch");
173 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(action);
179 /* drive the other two actions from this one */
181 Glib::RefPtr<Action> in_action = ActionManager::get_action ("Transport", "TogglePunchIn");
182 Glib::RefPtr<Action> out_action = ActionManager::get_action ("Transport", "TogglePunchOut");
184 if (in_action && out_action) {
185 Glib::RefPtr<ToggleAction> tiact = Glib::RefPtr<ToggleAction>::cast_dynamic(in_action);
186 Glib::RefPtr<ToggleAction> toact = Glib::RefPtr<ToggleAction>::cast_dynamic(out_action);
187 tiact->set_active (tact->get_active());
188 toact->set_active (tact->get_active());
194 ARDOUR_UI::toggle_punch_in ()
196 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Transport"), X_("TogglePunchIn"));
201 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
206 if (tact->get_active() != _session->config.get_punch_in()) {
207 _session->config.set_punch_in (tact->get_active ());
210 if (tact->get_active()) {
211 /* if punch-in is turned on, make sure the loop/punch ruler is visible, and stop it being hidden,
212 to avoid confusing the user */
213 show_loop_punch_ruler_and_disallow_hide ();
216 reenable_hide_loop_punch_ruler_if_appropriate ();
220 ARDOUR_UI::toggle_punch_out ()
222 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Transport"), X_("TogglePunchOut"));
227 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
232 if (tact->get_active() != _session->config.get_punch_out()) {
233 _session->config.set_punch_out (tact->get_active ());
236 if (tact->get_active()) {
237 /* if punch-out is turned on, make sure the loop/punch ruler is visible, and stop it being hidden,
238 to avoid confusing the user */
239 show_loop_punch_ruler_and_disallow_hide ();
242 reenable_hide_loop_punch_ruler_if_appropriate ();
246 ARDOUR_UI::show_loop_punch_ruler_and_disallow_hide ()
248 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Rulers"), "toggle-loop-punch-ruler");
253 act->set_sensitive (false);
255 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
260 if (!tact->get_active()) {
265 /* This is a bit of a silly name for a method */
267 ARDOUR_UI::reenable_hide_loop_punch_ruler_if_appropriate ()
269 if (!_session->config.get_punch_in() && !_session->config.get_punch_out()) {
270 /* if punch in/out are now both off, reallow hiding of the loop/punch ruler */
271 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Rulers"), "toggle-loop-punch-ruler");
273 act->set_sensitive (true);
279 ARDOUR_UI::toggle_video_sync()
281 Glib::RefPtr<Action> act = ActionManager::get_action ("Transport", "ToggleVideoSync");
283 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
284 _session->config.set_use_video_sync (tact->get_active());
289 ARDOUR_UI::toggle_editing_space()
291 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMaximalEditor");
294 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
295 if (tact->get_active()) {
296 maximise_editing_space ();
298 restore_editing_space ();
304 ARDOUR_UI::setup_session_options ()
306 _session->config.ParameterChanged.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::parameter_changed, this, _1), gui_context());
307 boost::function<void (std::string)> pc (boost::bind (&ARDOUR_UI::parameter_changed, this, _1));
308 _session->config.map_parameters (pc);
312 ARDOUR_UI::parameter_changed (std::string p)
314 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::parameter_changed, p)
316 if (p == "external-sync") {
318 ActionManager::map_some_state ("Transport", "ToggleExternalSync", sigc::mem_fun (_session->config, &SessionConfiguration::get_external_sync));
320 if (!_session->config.get_external_sync()) {
321 sync_button.set_text (_("Internal"));
322 ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (true);
323 ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (true);
325 sync_button.set_text (sync_source_to_string (Config->get_sync_source(), true));
326 /* XXX need to make auto-play is off as well as insensitive */
327 ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (false);
328 ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (false);
331 } else if (p == "always-play-range") {
333 ActionManager::map_some_state ("Transport", "AlwaysPlayRange", &RCConfiguration::get_always_play_range);
335 } else if (p == "send-mtc") {
337 ActionManager::map_some_state ("options", "SendMTC", &RCConfiguration::get_send_mtc);
339 } else if (p == "send-mmc") {
341 ActionManager::map_some_state ("options", "SendMMC", &RCConfiguration::get_send_mmc);
343 } else if (p == "use-osc") {
346 if (Config->get_use_osc()) {
353 } else if (p == "keep-tearoffs") {
354 ActionManager::map_some_state ("Common", "KeepTearoffs", &RCConfiguration::get_keep_tearoffs);
355 } else if (p == "mmc-control") {
356 ActionManager::map_some_state ("options", "UseMMC", &RCConfiguration::get_mmc_control);
357 } else if (p == "midi-feedback") {
358 ActionManager::map_some_state ("options", "SendMIDIfeedback", &RCConfiguration::get_midi_feedback);
359 } else if (p == "auto-play") {
360 ActionManager::map_some_state ("Transport", "ToggleAutoPlay", sigc::mem_fun (_session->config, &SessionConfiguration::get_auto_play));
361 } else if (p == "auto-return") {
362 ActionManager::map_some_state ("Transport", "ToggleAutoReturn", sigc::mem_fun (_session->config, &SessionConfiguration::get_auto_return));
363 } else if (p == "auto-input") {
364 ActionManager::map_some_state ("Transport", "ToggleAutoInput", sigc::mem_fun (_session->config, &SessionConfiguration::get_auto_input));
365 } else if (p == "punch-out") {
366 ActionManager::map_some_state ("Transport", "TogglePunchOut", sigc::mem_fun (_session->config, &SessionConfiguration::get_punch_out));
367 if (!_session->config.get_punch_out()) {
370 } else if (p == "punch-in") {
371 ActionManager::map_some_state ("Transport", "TogglePunchIn", sigc::mem_fun (_session->config, &SessionConfiguration::get_punch_in));
372 if (!_session->config.get_punch_in()) {
375 } else if (p == "clicking") {
376 ActionManager::map_some_state ("Transport", "ToggleClick", &RCConfiguration::get_clicking);
377 } else if (p == "use-video-sync") {
378 ActionManager::map_some_state ("Transport", "ToggleVideoSync", sigc::mem_fun (_session->config, &SessionConfiguration::get_use_video_sync));
379 } else if (p == "video-pullup" || p == "timecode-format") {
381 synchronize_sync_source_and_video_pullup ();
382 reset_main_clocks ();
384 } else if (p == "sync-source") {
386 synchronize_sync_source_and_video_pullup ();
388 } else if (p == "show-track-meters") {
389 editor->toggle_meter_updating();
390 } else if (p == "primary-clock-delta-edit-cursor") {
391 if (Config->get_primary_clock_delta_edit_cursor()) {
392 primary_clock->set_is_duration (true);
393 primary_clock->set_editable (false);
394 primary_clock->set_widget_name ("transport delta");
396 primary_clock->set_is_duration (false);
397 primary_clock->set_editable (true);
398 primary_clock->set_widget_name ("transport");
400 } else if (p == "secondary-clock-delta-edit-cursor") {
401 if (Config->get_secondary_clock_delta_edit_cursor()) {
402 secondary_clock->set_is_duration (true);
403 secondary_clock->set_editable (false);
404 secondary_clock->set_widget_name ("secondary delta");
406 secondary_clock->set_is_duration (false);
407 secondary_clock->set_editable (true);
408 secondary_clock->set_widget_name ("secondary");
414 ARDOUR_UI::session_parameter_changed (std::string p)
416 if (p == "native-file-data-format" || p == "native-file-header-format") {
422 ARDOUR_UI::reset_main_clocks ()
424 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::reset_main_clocks)
427 primary_clock->set (_session->audible_frame(), true);
428 secondary_clock->set (_session->audible_frame(), true);
430 primary_clock->set (0, true);
431 secondary_clock->set (0, true);
436 ARDOUR_UI::synchronize_sync_source_and_video_pullup ()
438 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Transport"), X_("ToggleExternalSync"));
448 if (_session->config.get_video_pullup() == 0.0f) {
449 /* with no video pull up/down, any sync source is OK */
450 act->set_sensitive (true);
452 /* can't sync to JACK if video pullup != 0.0 */
453 if (Config->get_sync_source() == JACK) {
454 act->set_sensitive (false);
456 act->set_sensitive (true);
460 /* XXX should really be able to set the video pull up
461 action to insensitive/sensitive, but there is no action.
466 if (act->get_sensitive ()) {
467 set_tip (sync_button, _("Enable/Disable external positional sync"));
469 set_tip (sync_button, _("Sync to JACK is not possible: video pull up/down is set"));