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 "canvas/wave_view.h"
34 #include "audio_clock.h"
35 #include "ardour_ui.h"
37 #include "gui_thread.h"
38 #include "public_editor.h"
39 #include "main_clock.h"
44 using namespace Gtkmm2ext;
45 using namespace ARDOUR;
49 ARDOUR_UI::toggle_external_sync()
52 if (_session->config.get_video_pullup() != 0.0f) {
53 if (Config->get_sync_source() == Engine) {
55 _("It is not possible to use JACK as the the sync source\n\
56 when the pull up/down setting is non-zero."));
62 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 /* activating a slave is a session-property.
65 * The slave type is a RC property.
66 * When the slave is active is must not be reconfigured.
67 * This is a UI limitation, imposed by audio-clock and
68 * status displays which combine RC-config & session-properties.
70 * Notficy RCOptionEditor by emitting a signal if the active
73 Config->ParameterChanged("sync-source");
78 ARDOUR_UI::toggle_time_master ()
80 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));
84 ARDOUR_UI::toggle_send_mtc ()
86 ActionManager::toggle_config_state ("Options", "SendMTC", &RCConfiguration::set_send_mtc, &RCConfiguration::get_send_mtc);
90 ARDOUR_UI::toggle_send_mmc ()
92 ActionManager::toggle_config_state ("Options", "SendMMC", &RCConfiguration::set_send_mmc, &RCConfiguration::get_send_mmc);
96 ARDOUR_UI::toggle_send_midi_clock ()
98 ActionManager::toggle_config_state ("Options", "SendMidiClock", &RCConfiguration::set_send_midi_clock, &RCConfiguration::get_send_midi_clock);
102 ARDOUR_UI::toggle_use_mmc ()
104 ActionManager::toggle_config_state ("Options", "UseMMC", &RCConfiguration::set_mmc_control, &RCConfiguration::get_mmc_control);
108 ARDOUR_UI::toggle_auto_input ()
110 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));
114 ARDOUR_UI::toggle_auto_play ()
116 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));
120 ARDOUR_UI::toggle_auto_return ()
122 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));
126 ARDOUR_UI::toggle_click ()
128 ActionManager::toggle_config_state ("Transport", "ToggleClick", &RCConfiguration::set_clicking, &RCConfiguration::get_clicking);
132 ARDOUR_UI::unset_dual_punch ()
134 Glib::RefPtr<Action> action = ActionManager::get_action ("Transport", "TogglePunch");
137 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(action);
139 ignore_dual_punch = true;
140 tact->set_active (false);
141 ignore_dual_punch = false;
147 ARDOUR_UI::toggle_punch ()
149 if (ignore_dual_punch) {
153 Glib::RefPtr<Action> action = ActionManager::get_action ("Transport", "TogglePunch");
157 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(action);
163 /* drive the other two actions from this one */
165 Glib::RefPtr<Action> in_action = ActionManager::get_action ("Transport", "TogglePunchIn");
166 Glib::RefPtr<Action> out_action = ActionManager::get_action ("Transport", "TogglePunchOut");
168 if (in_action && out_action) {
169 Glib::RefPtr<ToggleAction> tiact = Glib::RefPtr<ToggleAction>::cast_dynamic(in_action);
170 Glib::RefPtr<ToggleAction> toact = Glib::RefPtr<ToggleAction>::cast_dynamic(out_action);
171 tiact->set_active (tact->get_active());
172 toact->set_active (tact->get_active());
178 ARDOUR_UI::toggle_punch_in ()
180 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Transport"), X_("TogglePunchIn"));
185 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
190 if (tact->get_active() != _session->config.get_punch_in()) {
191 _session->config.set_punch_in (tact->get_active ());
194 if (tact->get_active()) {
195 /* if punch-in is turned on, make sure the loop/punch ruler is visible, and stop it being hidden,
196 to avoid confusing the user */
197 show_loop_punch_ruler_and_disallow_hide ();
200 reenable_hide_loop_punch_ruler_if_appropriate ();
204 ARDOUR_UI::toggle_punch_out ()
206 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Transport"), X_("TogglePunchOut"));
211 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
216 if (tact->get_active() != _session->config.get_punch_out()) {
217 _session->config.set_punch_out (tact->get_active ());
220 if (tact->get_active()) {
221 /* if punch-out is turned on, make sure the loop/punch ruler is visible, and stop it being hidden,
222 to avoid confusing the user */
223 show_loop_punch_ruler_and_disallow_hide ();
226 reenable_hide_loop_punch_ruler_if_appropriate ();
230 ARDOUR_UI::show_loop_punch_ruler_and_disallow_hide ()
232 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Rulers"), "toggle-loop-punch-ruler");
237 act->set_sensitive (false);
239 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
244 if (!tact->get_active()) {
249 /* This is a bit of a silly name for a method */
251 ARDOUR_UI::reenable_hide_loop_punch_ruler_if_appropriate ()
253 if (!_session->config.get_punch_in() && !_session->config.get_punch_out()) {
254 /* if punch in/out are now both off, reallow hiding of the loop/punch ruler */
255 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Rulers"), "toggle-loop-punch-ruler");
257 act->set_sensitive (true);
263 ARDOUR_UI::toggle_video_sync()
265 Glib::RefPtr<Action> act = ActionManager::get_action ("Transport", "ToggleVideoSync");
267 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
268 _session->config.set_use_video_sync (tact->get_active());
273 ARDOUR_UI::toggle_editing_space()
275 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMaximalEditor");
278 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
279 if (tact->get_active()) {
280 maximise_editing_space ();
282 restore_editing_space ();
288 ARDOUR_UI::setup_session_options ()
290 _session->config.ParameterChanged.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::parameter_changed, this, _1), gui_context());
291 boost::function<void (std::string)> pc (boost::bind (&ARDOUR_UI::parameter_changed, this, _1));
292 _session->config.map_parameters (pc);
296 ARDOUR_UI::parameter_changed (std::string p)
298 if (p == "external-sync") {
300 ActionManager::map_some_state ("Transport", "ToggleExternalSync", sigc::mem_fun (_session->config, &SessionConfiguration::get_external_sync));
302 if (!_session->config.get_external_sync()) {
303 sync_button.set_text (S_("SyncSource|Int."));
304 auto_loop_button.set_sensitive (true);
305 ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (true);
306 ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (true);
307 ActionManager::get_action ("Transport", "ToggleFollowEdits")->set_sensitive (true);
309 sync_button.set_text (sync_source_to_string (Config->get_sync_source(), true));
310 if (_session && _session->locations()->auto_loop_location()) {
311 // disable looping with external sync.
312 // This is not necessary because session-transport ignores the loop-state,
313 // but makes it clear to the user that it's disabled.
314 _session->request_play_loop (false, false);
316 auto_loop_button.set_sensitive (false);
317 /* XXX we need to make sure that auto-play is off as well as insensitive */
318 ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (false);
319 ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (false);
320 ActionManager::get_action ("Transport", "ToggleFollowEdits")->set_sensitive (false);
323 } else if (p == "follow-edits") {
325 ActionManager::map_some_state ("Transport", "ToggleFollowEdits", &UIConfiguration::get_follow_edits);
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 == "mmc-control") {
336 ActionManager::map_some_state ("Options", "UseMMC", &RCConfiguration::get_mmc_control);
337 } else if (p == "auto-play") {
338 ActionManager::map_some_state ("Transport", "ToggleAutoPlay", sigc::mem_fun (_session->config, &SessionConfiguration::get_auto_play));
339 } else if (p == "auto-return") {
340 ActionManager::map_some_state ("Transport", "ToggleAutoReturn", sigc::mem_fun (_session->config, &SessionConfiguration::get_auto_return));
341 } else if (p == "auto-input") {
342 ActionManager::map_some_state ("Transport", "ToggleAutoInput", sigc::mem_fun (_session->config, &SessionConfiguration::get_auto_input));
343 } else if (p == "punch-out") {
344 ActionManager::map_some_state ("Transport", "TogglePunchOut", sigc::mem_fun (_session->config, &SessionConfiguration::get_punch_out));
345 if (!_session->config.get_punch_out()) {
348 } else if (p == "punch-in") {
349 ActionManager::map_some_state ("Transport", "TogglePunchIn", sigc::mem_fun (_session->config, &SessionConfiguration::get_punch_in));
350 if (!_session->config.get_punch_in()) {
353 } else if (p == "clicking") {
354 ActionManager::map_some_state ("Transport", "ToggleClick", &RCConfiguration::get_clicking);
355 } else if (p == "use-video-sync") {
356 ActionManager::map_some_state ("Transport", "ToggleVideoSync", sigc::mem_fun (_session->config, &SessionConfiguration::get_use_video_sync));
357 } else if (p == "sync-source") {
359 synchronize_sync_source_and_video_pullup ();
360 set_fps_timeout_connection ();
362 } else if (p == "show-track-meters") {
363 if (editor) editor->toggle_meter_updating();
364 } else if (p == "primary-clock-delta-edit-cursor") {
365 if (UIConfiguration::instance().get_primary_clock_delta_edit_cursor()) {
366 primary_clock->set_is_duration (true);
367 primary_clock->set_editable (false);
368 primary_clock->set_widget_name ("transport delta");
370 primary_clock->set_is_duration (false);
371 primary_clock->set_editable (true);
372 primary_clock->set_widget_name ("transport");
374 } else if (p == "secondary-clock-delta-edit-cursor") {
375 if (UIConfiguration::instance().get_secondary_clock_delta_edit_cursor()) {
376 secondary_clock->set_is_duration (true);
377 secondary_clock->set_editable (false);
378 secondary_clock->set_widget_name ("secondary delta");
380 secondary_clock->set_is_duration (false);
381 secondary_clock->set_editable (true);
382 secondary_clock->set_widget_name ("secondary");
384 } else if (p == "super-rapid-clock-update") {
389 } else if (p == "use-tooltips") {
390 /* this doesn't really belong here but it has to go somewhere */
391 if (UIConfiguration::instance().get_use_tooltips()) {
392 Gtkmm2ext::enable_tooltips ();
394 Gtkmm2ext::disable_tooltips ();
396 } else if (p == "waveform-gradient-depth") {
397 ArdourCanvas::WaveView::set_global_gradient_depth (UIConfiguration::instance().get_waveform_gradient_depth());
398 } else if (p == "show-mini-timeline") {
399 repack_transport_hbox ();
400 } else if (p == "show-toolbar-selclock") {
401 repack_transport_hbox ();
402 } else if (p == "show-editor-meter") {
403 repack_transport_hbox ();
404 } else if (p == "show-secondary-clock") {
405 update_clock_visibility ();
406 } else if (p == "waveform-scale") {
407 ArdourCanvas::WaveView::set_global_logscaled (UIConfiguration::instance().get_waveform_scale() == Logarithmic);
408 } else if (p == "widget-prelight") {
409 CairoWidget::set_widget_prelight (UIConfiguration::instance().get_widget_prelight());
410 } else if (p == "waveform-shape") {
411 ArdourCanvas::WaveView::set_global_shape (UIConfiguration::instance().get_waveform_shape() == Rectified
412 ? ArdourCanvas::WaveView::Rectified : ArdourCanvas::WaveView::Normal);
413 } else if (p == "show-waveform-clipping") {
414 ArdourCanvas::WaveView::set_global_show_waveform_clipping (UIConfiguration::instance().get_show_waveform_clipping());
415 } else if (p == "waveform-cache-size") {
416 /* GUI option has units of megabytes; image cache uses units of bytes */
417 ArdourCanvas::WaveView::set_image_cache_size (UIConfiguration::instance().get_waveform_cache_size() * 1048576);
418 } else if (p == "use-wm-visibility") {
419 VisibilityTracker::set_use_window_manager_visibility (UIConfiguration::instance().get_use_wm_visibility());
420 } else if (p == "action-table-columns") {
421 const uint32_t cols = UIConfiguration::instance().get_action_table_columns ();
422 for (int i = 0; i < 9; ++i) {
423 const int col = i / 2;
424 if (cols & (1<<col)) {
425 action_script_call_btn[i].show();
427 action_script_call_btn[i].hide();
430 } else if (p == "layered-record-mode") {
431 layered_button.set_active (_session->config.get_layered_record_mode ());
432 } else if (p == "show-waveform-clipping") {
433 ArdourCanvas::WaveView::set_global_show_waveform_clipping (UIConfiguration::instance().get_show_waveform_clipping());
434 } else if (p == "waveform-gradient-depth") {
435 ArdourCanvas::WaveView::set_global_gradient_depth (UIConfiguration::instance().get_waveform_gradient_depth());
436 } else if (p == "flat-buttons") {
437 bool flat = UIConfiguration::instance().get_flat_buttons();
438 if (ArdourButton::flat_buttons () != flat) {
439 ArdourButton::set_flat_buttons (flat);
441 gtk_rc_reset_styles (gtk_settings_get_default());
447 ARDOUR_UI::session_parameter_changed (std::string p)
449 if (p == "native-file-data-format" || p == "native-file-header-format") {
451 } else if (p == "timecode-format") {
452 set_fps_timeout_connection ();
453 } else if (p == "video-pullup" || p == "timecode-format") {
454 set_fps_timeout_connection ();
456 synchronize_sync_source_and_video_pullup ();
457 reset_main_clocks ();
458 editor->queue_visual_videotimeline_update();
459 } else if (p == "track-name-number") {
460 /* DisplaySuspender triggers _route->redisplay() when going out of scope
461 * which eventually calls reset_controls_layout_width() and re-sets the
462 * track-header width.
463 * see also RouteTimeAxisView::update_track_number_visibility()
470 ARDOUR_UI::reset_main_clocks ()
472 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::reset_main_clocks)
475 primary_clock->set (_session->audible_frame(), true);
476 secondary_clock->set (_session->audible_frame(), true);
478 primary_clock->set (0, true);
479 secondary_clock->set (0, true);
484 ARDOUR_UI::synchronize_sync_source_and_video_pullup ()
486 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Transport"), X_("ToggleExternalSync"));
496 if (_session->config.get_video_pullup() == 0.0f) {
497 /* with no video pull up/down, any sync source is OK */
498 act->set_sensitive (true);
500 /* can't sync to JACK if video pullup != 0.0 */
501 if (Config->get_sync_source() == Engine) {
502 act->set_sensitive (false);
504 act->set_sensitive (true);
508 /* XXX should really be able to set the video pull up
509 action to insensitive/sensitive, but there is no action.
514 if (act->get_sensitive ()) {
515 set_tip (sync_button, _("Enable/Disable external positional sync"));
517 set_tip (sync_button, _("Sync to JACK is not possible: video pull up/down is set"));