ardour
ardour_ui_options.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2005 Paul Davis
3 
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.
8 
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.
13 
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.
17 
18 */
19 
20 #ifdef WAF_BUILD
21 #include "gtk2ardour-config.h"
22 #endif
23 
24 #include "pbd/convert.h"
25 #include "pbd/stacktrace.h"
26 
27 #include <gtkmm2ext/utils.h>
28 
30 #include "ardour/session.h"
31 
32 #include "canvas/wave_view.h"
33 
34 #include "audio_clock.h"
35 #include "ardour_ui.h"
36 #include "actions.h"
37 #include "gui_thread.h"
38 #include "public_editor.h"
39 #include "main_clock.h"
40 
41 #include "i18n.h"
42 
43 using namespace Gtk;
44 using namespace Gtkmm2ext;
45 using namespace ARDOUR;
46 using namespace PBD;
47 
48 void
50 {
51  ActionManager::toggle_config_state ("Common", "KeepTearoffs", &UIConfiguration::set_keep_tearoffs, &UIConfiguration::get_keep_tearoffs);
52 
54 }
55 
56 void
58 {
59  if (_session) {
60  if (_session->config.get_video_pullup() != 0.0f) {
61  if (Config->get_sync_source() == Engine) {
62  MessageDialog msg (
63  _("It is not possible to use JACK as the the sync source\n\
64 when the pull up/down setting is non-zero."));
65  msg.run ();
66  return;
67  }
68  }
69 
70  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));
71 
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.
77  *
78  * Notficy RCOptionEditor by emitting a signal if the active
79  * status changed:
80  */
81  Config->ParameterChanged("sync-source");
82  }
83 }
84 
85 void
87 {
88  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));
89 }
90 
91 void
93 {
94  ActionManager::toggle_config_state ("options", "SendMTC", &RCConfiguration::set_send_mtc, &RCConfiguration::get_send_mtc);
95 }
96 
97 void
99 {
100  ActionManager::toggle_config_state ("options", "SendMMC", &RCConfiguration::set_send_mmc, &RCConfiguration::get_send_mmc);
101 }
102 
103 void
105 {
106  ActionManager::toggle_config_state ("options", "SendMidiClock", &RCConfiguration::set_send_midi_clock, &RCConfiguration::get_send_midi_clock);
107 }
108 
109 void
111 {
112  ActionManager::toggle_config_state ("options", "UseMMC", &RCConfiguration::set_mmc_control, &RCConfiguration::get_mmc_control);
113 }
114 
115 void
117 {
118  ActionManager::toggle_config_state ("options", "SendMIDIfeedback", &RCConfiguration::set_midi_feedback, &RCConfiguration::get_midi_feedback);
119 }
120 
121 void
123 {
124  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));
125 }
126 
127 void
129 {
130  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));
131 }
132 
133 void
135 {
136  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));
137 }
138 
139 void
141 {
142  ActionManager::toggle_config_state ("Transport", "ToggleClick", &RCConfiguration::set_clicking, &RCConfiguration::get_clicking);
143 }
144 
145 void
147 {
148  Glib::RefPtr<Action> action = ActionManager::get_action ("Transport", "TogglePunch");
149 
150  if (action) {
151  Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(action);
152  if (tact) {
153  ignore_dual_punch = true;
154  tact->set_active (false);
155  ignore_dual_punch = false;
156  }
157  }
158 }
159 
160 void
162 {
163  if (ignore_dual_punch) {
164  return;
165  }
166 
167  Glib::RefPtr<Action> action = ActionManager::get_action ("Transport", "TogglePunch");
168 
169  if (action) {
170 
171  Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(action);
172 
173  if (!tact) {
174  return;
175  }
176 
177  /* drive the other two actions from this one */
178 
179  Glib::RefPtr<Action> in_action = ActionManager::get_action ("Transport", "TogglePunchIn");
180  Glib::RefPtr<Action> out_action = ActionManager::get_action ("Transport", "TogglePunchOut");
181 
182  if (in_action && out_action) {
183  Glib::RefPtr<ToggleAction> tiact = Glib::RefPtr<ToggleAction>::cast_dynamic(in_action);
184  Glib::RefPtr<ToggleAction> toact = Glib::RefPtr<ToggleAction>::cast_dynamic(out_action);
185  tiact->set_active (tact->get_active());
186  toact->set_active (tact->get_active());
187  }
188  }
189 }
190 
191 void
193 {
194  Glib::RefPtr<Action> act = ActionManager::get_action (X_("Transport"), X_("TogglePunchIn"));
195  if (!act) {
196  return;
197  }
198 
199  Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
200  if (!tact) {
201  return;
202  }
203 
204  if (tact->get_active() != _session->config.get_punch_in()) {
205  _session->config.set_punch_in (tact->get_active ());
206  }
207 
208  if (tact->get_active()) {
209  /* if punch-in is turned on, make sure the loop/punch ruler is visible, and stop it being hidden,
210  to avoid confusing the user */
211  show_loop_punch_ruler_and_disallow_hide ();
212  }
213 
214  reenable_hide_loop_punch_ruler_if_appropriate ();
215 }
216 
217 void
219 {
220  Glib::RefPtr<Action> act = ActionManager::get_action (X_("Transport"), X_("TogglePunchOut"));
221  if (!act) {
222  return;
223  }
224 
225  Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
226  if (!tact) {
227  return;
228  }
229 
230  if (tact->get_active() != _session->config.get_punch_out()) {
231  _session->config.set_punch_out (tact->get_active ());
232  }
233 
234  if (tact->get_active()) {
235  /* if punch-out is turned on, make sure the loop/punch ruler is visible, and stop it being hidden,
236  to avoid confusing the user */
237  show_loop_punch_ruler_and_disallow_hide ();
238  }
239 
240  reenable_hide_loop_punch_ruler_if_appropriate ();
241 }
242 
243 void
245 {
246  Glib::RefPtr<Action> act = ActionManager::get_action (X_("Rulers"), "toggle-loop-punch-ruler");
247  if (!act) {
248  return;
249  }
250 
251  act->set_sensitive (false);
252 
253  Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
254  if (!tact) {
255  return;
256  }
257 
258  if (!tact->get_active()) {
259  tact->set_active ();
260  }
261 }
262 
263 /* This is a bit of a silly name for a method */
264 void
266 {
267  if (!_session->config.get_punch_in() && !_session->config.get_punch_out()) {
268  /* if punch in/out are now both off, reallow hiding of the loop/punch ruler */
269  Glib::RefPtr<Action> act = ActionManager::get_action (X_("Rulers"), "toggle-loop-punch-ruler");
270  if (act) {
271  act->set_sensitive (true);
272  }
273  }
274 }
275 
276 void
278 {
279  Glib::RefPtr<Action> act = ActionManager::get_action ("Transport", "ToggleVideoSync");
280  if (act) {
281  Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
282  _session->config.set_use_video_sync (tact->get_active());
283  }
284 }
285 
286 void
288 {
289  Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMaximalEditor");
290 
291  if (act) {
292  Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
293  if (tact->get_active()) {
294  maximise_editing_space ();
295  } else {
296  restore_editing_space ();
297  }
298  }
299 }
300 
301 void
303 {
304  _session->config.ParameterChanged.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::parameter_changed, this, _1), gui_context());
305  boost::function<void (std::string)> pc (boost::bind (&ARDOUR_UI::parameter_changed, this, _1));
306  _session->config.map_parameters (pc);
307 }
308 
309 void
311 {
312  if (p == "external-sync") {
313 
314  ActionManager::map_some_state ("Transport", "ToggleExternalSync", sigc::mem_fun (_session->config, &SessionConfiguration::get_external_sync));
315 
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);
321  } else {
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);
327  }
328 
329  } else if (p == "follow-edits") {
330 
331  ActionManager::map_some_state ("Transport", "ToggleFollowEdits", &UIConfiguration::get_follow_edits);
332 
333  } else if (p == "send-mtc") {
334 
335  ActionManager::map_some_state ("options", "SendMTC", &RCConfiguration::get_send_mtc);
336 
337  } else if (p == "send-mmc") {
338 
339  ActionManager::map_some_state ("options", "SendMMC", &RCConfiguration::get_send_mmc);
340 
341  } else if (p == "keep-tearoffs") {
342  ActionManager::map_some_state ("Common", "KeepTearoffs", &UIConfiguration::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()) {
356  unset_dual_punch ();
357  }
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()) {
361  unset_dual_punch ();
362  }
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 == "sync-source") {
368 
369  synchronize_sync_source_and_video_pullup ();
370  set_fps_timeout_connection ();
371 
372  } else if (p == "show-track-meters") {
373  if (editor) editor->toggle_meter_updating();
374  } else if (p == "primary-clock-delta-edit-cursor") {
375  if (ARDOUR_UI::config()->get_primary_clock_delta_edit_cursor()) {
376  primary_clock->set_is_duration (true);
377  primary_clock->set_editable (false);
378  primary_clock->set_widget_name ("transport delta");
379  } else {
380  primary_clock->set_is_duration (false);
381  primary_clock->set_editable (true);
382  primary_clock->set_widget_name ("transport");
383  }
384  } else if (p == "secondary-clock-delta-edit-cursor") {
385  if (ARDOUR_UI::config()->get_secondary_clock_delta_edit_cursor()) {
386  secondary_clock->set_is_duration (true);
387  secondary_clock->set_editable (false);
388  secondary_clock->set_widget_name ("secondary delta");
389  } else {
390  secondary_clock->set_is_duration (false);
391  secondary_clock->set_editable (true);
392  secondary_clock->set_widget_name ("secondary");
393  }
394  } else if (p == "super-rapid-clock-update") {
395  if (_session) {
396  stop_clocking ();
397  start_clocking ();
398  }
399  } else if (p == "waveform-gradient-depth") {
400  ArdourCanvas::WaveView::set_global_gradient_depth (config()->get_waveform_gradient_depth());
401  } else if (p == "show-editor-meter") {
402  bool show = ARDOUR_UI::config()->get_show_editor_meter();
403 
404  if (editor_meter) {
405  if (meter_box.get_parent()) {
406  transport_tearoff_hbox.remove (meter_box);
407  transport_tearoff_hbox.remove (editor_meter_peak_display);
408  }
409 
410  if (show) {
411  transport_tearoff_hbox.pack_start (meter_box, false, false);
412  transport_tearoff_hbox.pack_start (editor_meter_peak_display, false, false);
413  meter_box.show();
414  editor_meter_peak_display.show();
415  }
416  }
417  } else if (p == "waveform-scale") {
418  ArdourCanvas::WaveView::set_global_logscaled (ARDOUR_UI::config()->get_waveform_scale() == Logarithmic);
419  } else if (p == "widget-prelight") {
420  CairoWidget::set_widget_prelight( config()->get_widget_prelight() );
421  } else if (p == "waveform-shape") {
422  ArdourCanvas::WaveView::set_global_shape (ARDOUR_UI::config()->get_waveform_shape() == Rectified
424  } else if (p == "show-waveform-clipping") {
425  ArdourCanvas::WaveView::set_global_show_waveform_clipping (ARDOUR_UI::config()->get_show_waveform_clipping());
426  } else if (p == "font-scale") {
427  ui_scale = config()->get_font_scale () / 102400.;
428  }
429 }
430 
431 void
433 {
434  if (p == "native-file-data-format" || p == "native-file-header-format") {
435  update_format ();
436  } else if (p == "timecode-format") {
437  set_fps_timeout_connection ();
438  } else if (p == "video-pullup" || p == "timecode-format") {
439  set_fps_timeout_connection ();
440 
441  synchronize_sync_source_and_video_pullup ();
442  reset_main_clocks ();
443  editor->queue_visual_videotimeline_update();
444  } else if (p == "track-name-number") {
445  /* DisplaySuspender triggers _route->redisplay() when going out of scope
446  * which eventually calls reset_controls_layout_width() and re-sets the
447  * track-header width.
448  * see also RouteTimeAxisView::update_track_number_visibility()
449  */
450  DisplaySuspender ds;
451  }
452 }
453 
454 void
456 {
458 
459  if (_session) {
460  primary_clock->set (_session->audible_frame(), true);
461  secondary_clock->set (_session->audible_frame(), true);
462  } else {
463  primary_clock->set (0, true);
464  secondary_clock->set (0, true);
465  }
466 }
467 
468 void
470 {
471  Glib::RefPtr<Action> act = ActionManager::get_action (X_("Transport"), X_("ToggleExternalSync"));
472 
473  if (!act) {
474  return;
475  }
476 
477  if (!_session) {
478  goto just_label;
479  }
480 
481  if (_session->config.get_video_pullup() == 0.0f) {
482  /* with no video pull up/down, any sync source is OK */
483  act->set_sensitive (true);
484  } else {
485  /* can't sync to JACK if video pullup != 0.0 */
486  if (Config->get_sync_source() == Engine) {
487  act->set_sensitive (false);
488  } else {
489  act->set_sensitive (true);
490  }
491  }
492 
493  /* XXX should really be able to set the video pull up
494  action to insensitive/sensitive, but there is no action.
495  FIXME
496  */
497 
498  just_label:
499  if (act->get_sensitive ()) {
500  set_tip (sync_button, _("Enable/Disable external positional sync"));
501  } else {
502  set_tip (sync_button, _("Sync to JACK is not possible: video pull up/down is set"));
503  }
504 
505 }
506 
void toggle_video_sync()
void reenable_hide_loop_punch_ruler_if_appropriate()
void session_parameter_changed(std::string)
Definition: ardour_ui.h:130
void unset_dual_punch()
LIBARDOUR_API const char * sync_source_to_string(ARDOUR::SyncSource src, bool sh=false)
Definition: utils.cc:477
LIBGTKMM2EXT_API Glib::RefPtr< Gtk::Action > get_action(const char *group, const char *name)
Definition: actions.cc:406
void toggle_config_state_foo(const char *group, const char *action, sigc::slot< bool, bool >, sigc::slot< bool >)
Definition: actions.cc:152
void toggle_external_sync()
void toggle_send_midi_clock()
void toggle_send_midi_feedback()
void toggle_punch_in()
#define ENSURE_GUI_THREAD(obj, method,...)
Definition: gui_thread.h:34
static void set_widget_prelight(bool yn)
void toggle_auto_return()
#define _(Text)
Definition: i18n.h:11
#define X_(Text)
Definition: i18n.h:13
LIBARDOUR_API RCConfiguration * Config
Definition: globals.cc:119
Definition: amp.h:29
void show_loop_punch_ruler_and_disallow_hide()
#define gui_context()
Definition: gui_thread.h:36
void toggle_use_mmc()
void reset_main_clocks()
void map_some_state(const char *group, const char *action, bool(ARDOUR::RCConfiguration::*get)() const)
PBD::Signal1< void, std::string > ParameterChanged
Definition: configuration.h:44
void toggle_keep_tearoffs()
void setup_session_options()
static UIConfiguration * config()
Definition: ardour_ui.h:188
void toggle_auto_play()
Definition: debug.h:30
void toggle_punch_out()
void toggle_time_master()
void parameter_changed(std::string)
void toggle_editing_space()
void toggle_auto_input()
void toggle_config_state(const char *group, const char *action, bool(UIConfiguration::*set)(bool), bool(UIConfiguration::*get)(void) const)
Definition: actions.cc:134
void toggle_send_mmc()
#define MISSING_INVALIDATOR
Definition: event_loop.h:86
void update_tearoff_visibility()
Definition: ardour_ui2.cc:700
void synchronize_sync_source_and_video_pullup()
void toggle_send_mtc()