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"
32 #include "audio_clock.h"
33 #include "ardour_ui.h"
35 #include "gui_thread.h"
36 #include "public_editor.h"
37 #include "main_clock.h"
42 using namespace Gtkmm2ext;
43 using namespace ARDOUR;
47 ARDOUR_UI::toggle_keep_tearoffs ()
49 ActionManager::toggle_config_state ("Common", "KeepTearoffs", &RCConfiguration::set_keep_tearoffs, &RCConfiguration::get_keep_tearoffs);
51 ARDOUR_UI::update_tearoff_visibility();
55 ARDOUR_UI::toggle_external_sync()
58 if (_session->config.get_video_pullup() != 0.0f) {
59 if (Config->get_sync_source() == Engine) {
61 _("It is not possible to use JACK as the the sync source\n\
62 when the pull up/down setting is non-zero."));
68 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));
70 /* activating a slave is a session-property.
71 * The slave type is a RC property.
72 * When the slave is active is must not be reconfigured.
73 * This is a UI limitation, imposed by audio-clock and
74 * status displays which combine RC-config & session-properties.
76 * Notficy RCOptionEditor by emitting a signal if the active
79 Config->ParameterChanged("sync-source");
84 ARDOUR_UI::toggle_time_master ()
86 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));
90 ARDOUR_UI::toggle_send_mtc ()
92 ActionManager::toggle_config_state ("options", "SendMTC", &RCConfiguration::set_send_mtc, &RCConfiguration::get_send_mtc);
96 ARDOUR_UI::toggle_send_mmc ()
98 ActionManager::toggle_config_state ("options", "SendMMC", &RCConfiguration::set_send_mmc, &RCConfiguration::get_send_mmc);
102 ARDOUR_UI::toggle_send_midi_clock ()
104 ActionManager::toggle_config_state ("options", "SendMidiClock", &RCConfiguration::set_send_midi_clock, &RCConfiguration::get_send_midi_clock);
108 ARDOUR_UI::toggle_use_mmc ()
110 ActionManager::toggle_config_state ("options", "UseMMC", &RCConfiguration::set_mmc_control, &RCConfiguration::get_mmc_control);
114 ARDOUR_UI::toggle_send_midi_feedback ()
116 ActionManager::toggle_config_state ("options", "SendMIDIfeedback", &RCConfiguration::set_midi_feedback, &RCConfiguration::get_midi_feedback);
120 ARDOUR_UI::toggle_auto_input ()
122 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));
126 ARDOUR_UI::toggle_auto_play ()
128 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));
132 ARDOUR_UI::toggle_auto_return ()
134 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));
138 ARDOUR_UI::toggle_click ()
140 ActionManager::toggle_config_state ("Transport", "ToggleClick", &RCConfiguration::set_clicking, &RCConfiguration::get_clicking);
144 ARDOUR_UI::unset_dual_punch ()
146 Glib::RefPtr<Action> action = ActionManager::get_action ("Transport", "TogglePunch");
149 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(action);
151 ignore_dual_punch = true;
152 tact->set_active (false);
153 ignore_dual_punch = false;
159 ARDOUR_UI::toggle_punch ()
161 if (ignore_dual_punch) {
165 Glib::RefPtr<Action> action = ActionManager::get_action ("Transport", "TogglePunch");
169 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(action);
175 /* drive the other two actions from this one */
177 Glib::RefPtr<Action> in_action = ActionManager::get_action ("Transport", "TogglePunchIn");
178 Glib::RefPtr<Action> out_action = ActionManager::get_action ("Transport", "TogglePunchOut");
180 if (in_action && out_action) {
181 Glib::RefPtr<ToggleAction> tiact = Glib::RefPtr<ToggleAction>::cast_dynamic(in_action);
182 Glib::RefPtr<ToggleAction> toact = Glib::RefPtr<ToggleAction>::cast_dynamic(out_action);
183 tiact->set_active (tact->get_active());
184 toact->set_active (tact->get_active());
190 ARDOUR_UI::toggle_punch_in ()
192 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Transport"), X_("TogglePunchIn"));
197 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
202 if (tact->get_active() != _session->config.get_punch_in()) {
203 _session->config.set_punch_in (tact->get_active ());
206 if (tact->get_active()) {
207 /* if punch-in is turned on, make sure the loop/punch ruler is visible, and stop it being hidden,
208 to avoid confusing the user */
209 show_loop_punch_ruler_and_disallow_hide ();
212 reenable_hide_loop_punch_ruler_if_appropriate ();
216 ARDOUR_UI::toggle_punch_out ()
218 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Transport"), X_("TogglePunchOut"));
223 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
228 if (tact->get_active() != _session->config.get_punch_out()) {
229 _session->config.set_punch_out (tact->get_active ());
232 if (tact->get_active()) {
233 /* if punch-out is turned on, make sure the loop/punch ruler is visible, and stop it being hidden,
234 to avoid confusing the user */
235 show_loop_punch_ruler_and_disallow_hide ();
238 reenable_hide_loop_punch_ruler_if_appropriate ();
242 ARDOUR_UI::show_loop_punch_ruler_and_disallow_hide ()
244 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Rulers"), "toggle-loop-punch-ruler");
249 act->set_sensitive (false);
251 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
256 if (!tact->get_active()) {
261 /* This is a bit of a silly name for a method */
263 ARDOUR_UI::reenable_hide_loop_punch_ruler_if_appropriate ()
265 if (!_session->config.get_punch_in() && !_session->config.get_punch_out()) {
266 /* if punch in/out are now both off, reallow hiding of the loop/punch ruler */
267 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Rulers"), "toggle-loop-punch-ruler");
269 act->set_sensitive (true);
275 ARDOUR_UI::toggle_video_sync()
277 Glib::RefPtr<Action> act = ActionManager::get_action ("Transport", "ToggleVideoSync");
279 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
280 _session->config.set_use_video_sync (tact->get_active());
285 ARDOUR_UI::toggle_editing_space()
287 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMaximalEditor");
290 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
291 if (tact->get_active()) {
292 maximise_editing_space ();
294 restore_editing_space ();
300 ARDOUR_UI::setup_session_options ()
302 _session->config.ParameterChanged.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::parameter_changed, this, _1), gui_context());
303 boost::function<void (std::string)> pc (boost::bind (&ARDOUR_UI::parameter_changed, this, _1));
304 _session->config.map_parameters (pc);
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_text (_("Internal"));
318 ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (true);
319 ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (true);
320 ActionManager::get_action ("Transport", "ToggleFollowEdits")->set_sensitive (true);
322 sync_button.set_text (sync_source_to_string (Config->get_sync_source(), true));
323 /* XXX need to make auto-play is off as well as insensitive */
324 ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (false);
325 ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (false);
326 ActionManager::get_action ("Transport", "ToggleFollowEdits")->set_sensitive (false);
329 } else if (p == "always-play-range") {
331 ActionManager::map_some_state ("Transport", "ToggleFollowEdits", &RCConfiguration::get_always_play_range);
333 } else if (p == "send-mtc") {
335 ActionManager::map_some_state ("options", "SendMTC", &RCConfiguration::get_send_mtc);
337 } else if (p == "send-mmc") {
339 ActionManager::map_some_state ("options", "SendMMC", &RCConfiguration::get_send_mmc);
341 } else if (p == "keep-tearoffs") {
342 ActionManager::map_some_state ("Common", "KeepTearoffs", &RCConfiguration::get_keep_tearoffs);
343 } else if (p == "mmc-control") {
344 ActionManager::map_some_state ("options", "UseMMC", &RCConfiguration::get_mmc_control);
345 } else if (p == "midi-feedback") {
346 ActionManager::map_some_state ("options", "SendMIDIfeedback", &RCConfiguration::get_midi_feedback);
347 } else if (p == "auto-play") {
348 ActionManager::map_some_state ("Transport", "ToggleAutoPlay", sigc::mem_fun (_session->config, &SessionConfiguration::get_auto_play));
349 } else if (p == "auto-return") {
350 ActionManager::map_some_state ("Transport", "ToggleAutoReturn", sigc::mem_fun (_session->config, &SessionConfiguration::get_auto_return));
351 } else if (p == "auto-input") {
352 ActionManager::map_some_state ("Transport", "ToggleAutoInput", sigc::mem_fun (_session->config, &SessionConfiguration::get_auto_input));
353 } else if (p == "punch-out") {
354 ActionManager::map_some_state ("Transport", "TogglePunchOut", sigc::mem_fun (_session->config, &SessionConfiguration::get_punch_out));
355 if (!_session->config.get_punch_out()) {
358 } else if (p == "punch-in") {
359 ActionManager::map_some_state ("Transport", "TogglePunchIn", sigc::mem_fun (_session->config, &SessionConfiguration::get_punch_in));
360 if (!_session->config.get_punch_in()) {
363 } else if (p == "clicking") {
364 ActionManager::map_some_state ("Transport", "ToggleClick", &RCConfiguration::get_clicking);
365 } else if (p == "use-video-sync") {
366 ActionManager::map_some_state ("Transport", "ToggleVideoSync", sigc::mem_fun (_session->config, &SessionConfiguration::get_use_video_sync));
367 } else if (p == "video-pullup" || p == "timecode-format") {
369 synchronize_sync_source_and_video_pullup ();
370 reset_main_clocks ();
371 editor->queue_visual_videotimeline_update();
373 } else if (p == "sync-source") {
375 synchronize_sync_source_and_video_pullup ();
377 } else if (p == "show-track-meters") {
378 editor->toggle_meter_updating();
379 } else if (p == "primary-clock-delta-edit-cursor") {
380 if (Config->get_primary_clock_delta_edit_cursor()) {
381 primary_clock->set_is_duration (true);
382 primary_clock->set_editable (false);
383 primary_clock->set_widget_name ("transport delta");
385 primary_clock->set_is_duration (false);
386 primary_clock->set_editable (true);
387 primary_clock->set_widget_name ("transport");
389 } else if (p == "secondary-clock-delta-edit-cursor") {
390 if (Config->get_secondary_clock_delta_edit_cursor()) {
391 secondary_clock->set_is_duration (true);
392 secondary_clock->set_editable (false);
393 secondary_clock->set_widget_name ("secondary delta");
395 secondary_clock->set_is_duration (false);
396 secondary_clock->set_editable (true);
397 secondary_clock->set_widget_name ("secondary");
399 } else if (p == "super-rapid-clock-update") {
402 } else if (p == "show-editor-meter") {
403 bool show = Config->get_show_editor_meter();
406 if (meter_box.get_parent()) {
407 transport_tearoff_hbox.remove (meter_box);
408 transport_tearoff_hbox.remove (editor_meter_peak_display);
412 transport_tearoff_hbox.pack_start (meter_box, false, false);
413 transport_tearoff_hbox.pack_start (editor_meter_peak_display, false, false);
415 editor_meter_peak_display.show();
422 ARDOUR_UI::session_parameter_changed (std::string p)
424 if (p == "native-file-data-format" || p == "native-file-header-format") {
430 ARDOUR_UI::reset_main_clocks ()
432 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::reset_main_clocks)
435 primary_clock->set (_session->audible_frame(), true);
436 secondary_clock->set (_session->audible_frame(), true);
438 primary_clock->set (0, true);
439 secondary_clock->set (0, true);
444 ARDOUR_UI::synchronize_sync_source_and_video_pullup ()
446 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Transport"), X_("ToggleExternalSync"));
456 if (_session->config.get_video_pullup() == 0.0f) {
457 /* with no video pull up/down, any sync source is OK */
458 act->set_sensitive (true);
460 /* can't sync to JACK if video pullup != 0.0 */
461 if (Config->get_sync_source() == Engine) {
462 act->set_sensitive (false);
464 act->set_sensitive (true);
468 /* XXX should really be able to set the video pull up
469 action to insensitive/sensitive, but there is no action.
474 if (act->get_sensitive ()) {
475 set_tip (sync_button, _("Enable/Disable external positional sync"));
477 set_tip (sync_button, _("Sync to JACK is not possible: video pull up/down is set"));