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;
51 ARDOUR_UI::toggle_external_sync()
53 ActionManager::toggle_config_state_foo ("Transport", "ToggleExternalSync", mem_fun (session->config, &SessionConfiguration::set_external_sync), mem_fun (session->config, &SessionConfiguration::get_external_sync));
57 ARDOUR_UI::toggle_time_master ()
59 ActionManager::toggle_config_state_foo ("Transport", "ToggleTimeMaster", mem_fun (session->config, &SessionConfiguration::set_jack_time_master), mem_fun (session->config, &SessionConfiguration::get_jack_time_master));
63 ARDOUR_UI::toggle_send_mtc ()
65 ActionManager::toggle_config_state ("options", "SendMTC", &RCConfiguration::set_send_mtc, &RCConfiguration::get_send_mtc);
69 ARDOUR_UI::toggle_send_mmc ()
71 ActionManager::toggle_config_state ("options", "SendMMC", &RCConfiguration::set_send_mmc, &RCConfiguration::get_send_mmc);
75 ARDOUR_UI::toggle_send_midi_clock ()
77 ActionManager::toggle_config_state ("options", "SendMidiClock", &RCConfiguration::set_send_midi_clock, &RCConfiguration::get_send_midi_clock);
81 ARDOUR_UI::toggle_use_mmc ()
83 ActionManager::toggle_config_state ("options", "UseMMC", &RCConfiguration::set_mmc_control, &RCConfiguration::get_mmc_control);
87 ARDOUR_UI::toggle_send_midi_feedback ()
89 ActionManager::toggle_config_state ("options", "SendMIDIfeedback", &RCConfiguration::set_midi_feedback, &RCConfiguration::get_midi_feedback);
93 ARDOUR_UI::toggle_auto_input ()
95 ActionManager::toggle_config_state_foo ("Transport", "ToggleAutoInput", mem_fun (session->config, &SessionConfiguration::set_auto_input), mem_fun (session->config, &SessionConfiguration::get_auto_input));
99 ARDOUR_UI::toggle_auto_play ()
101 ActionManager::toggle_config_state_foo ("Transport", "ToggleAutoPlay", mem_fun (session->config, &SessionConfiguration::set_auto_play), mem_fun (session->config, &SessionConfiguration::get_auto_play));
105 ARDOUR_UI::toggle_auto_return ()
107 ActionManager::toggle_config_state_foo ("Transport", "ToggleAutoReturn", mem_fun (session->config, &SessionConfiguration::set_auto_return), mem_fun (session->config, &SessionConfiguration::get_auto_return));
111 ARDOUR_UI::toggle_click ()
113 ActionManager::toggle_config_state ("Transport", "ToggleClick", &RCConfiguration::set_clicking, &RCConfiguration::get_clicking);
117 ARDOUR_UI::unset_dual_punch ()
119 Glib::RefPtr<Action> action = ActionManager::get_action ("Transport", "TogglePunch");
122 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(action);
124 ignore_dual_punch = true;
125 tact->set_active (false);
126 ignore_dual_punch = false;
132 ARDOUR_UI::toggle_punch ()
134 if (ignore_dual_punch) {
138 Glib::RefPtr<Action> action = ActionManager::get_action ("Transport", "TogglePunch");
142 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(action);
148 /* drive the other two actions from this one */
150 Glib::RefPtr<Action> in_action = ActionManager::get_action ("Transport", "TogglePunchIn");
151 Glib::RefPtr<Action> out_action = ActionManager::get_action ("Transport", "TogglePunchOut");
153 if (in_action && out_action) {
154 Glib::RefPtr<ToggleAction> tiact = Glib::RefPtr<ToggleAction>::cast_dynamic(in_action);
155 Glib::RefPtr<ToggleAction> toact = Glib::RefPtr<ToggleAction>::cast_dynamic(out_action);
156 tiact->set_active (tact->get_active());
157 toact->set_active (tact->get_active());
163 ARDOUR_UI::toggle_punch_in ()
165 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Transport"), X_("TogglePunchIn"));
170 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
175 if (tact->get_active() != session->config.get_punch_in()) {
176 session->config.set_punch_in (tact->get_active ());
179 if (tact->get_active()) {
180 /* if punch-in is turned on, make sure the loop/punch ruler is visible, and stop it being hidden,
181 to avoid confusing the user */
182 show_loop_punch_ruler_and_disallow_hide ();
185 reenable_hide_loop_punch_ruler_if_appropriate ();
189 ARDOUR_UI::toggle_punch_out ()
191 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Transport"), X_("TogglePunchOut"));
196 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
201 if (tact->get_active() != session->config.get_punch_out()) {
202 session->config.set_punch_out (tact->get_active ());
205 if (tact->get_active()) {
206 /* if punch-out is turned on, make sure the loop/punch ruler is visible, and stop it being hidden,
207 to avoid confusing the user */
208 show_loop_punch_ruler_and_disallow_hide ();
211 reenable_hide_loop_punch_ruler_if_appropriate ();
215 ARDOUR_UI::show_loop_punch_ruler_and_disallow_hide ()
217 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Rulers"), "toggle-loop-punch-ruler");
222 act->set_sensitive (false);
224 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
229 if (!tact->get_active()) {
234 /* This is a bit of a silly name for a method */
236 ARDOUR_UI::reenable_hide_loop_punch_ruler_if_appropriate ()
238 if (!session->config.get_punch_in() && !session->config.get_punch_out()) {
239 /* if punch in/out are now both off, reallow hiding of the loop/punch ruler */
240 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Rulers"), "toggle-loop-punch-ruler");
242 act->set_sensitive (true);
248 ARDOUR_UI::toggle_video_sync()
250 Glib::RefPtr<Action> act = ActionManager::get_action ("Transport", "ToggleVideoSync");
252 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
253 session->config.set_use_video_sync (tact->get_active());
258 ARDOUR_UI::toggle_editing_space()
260 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMaximalEditor");
262 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
263 if (tact->get_active()) {
264 maximise_editing_space ();
266 restore_editing_space ();
272 ARDOUR_UI::setup_session_options ()
274 session->config.ParameterChanged.connect (mem_fun (*this, &ARDOUR_UI::parameter_changed));
275 session->config.map_parameters (mem_fun (*this, &ARDOUR_UI::parameter_changed));
280 ARDOUR_UI::handle_sync_change ()
285 if (!session->config.get_external_sync()) {
286 sync_button.set_label (_("Internal"));
287 ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (true);
288 ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (true);
290 sync_button.set_label (_("External"));
291 /* XXX need to make auto-play is off as well as insensitive */
292 ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (false);
293 ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (false);
300 ARDOUR_UI::parameter_changed (std::string p)
302 ENSURE_GUI_THREAD (bind (mem_fun (*this, &ARDOUR_UI::parameter_changed), p));
304 if (p == "external-sync") {
306 ActionManager::map_some_state ("Transport", "ToggleExternalSync", mem_fun (session->config, &SessionConfiguration::get_external_sync));
308 if (!session->config.get_external_sync()) {
309 sync_button.set_label (_("Internal"));
310 ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (true);
311 ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (true);
313 sync_button.set_label (sync_source_to_string (session->config.get_sync_source()));
314 /* XXX need to make auto-play is off as well as insensitive */
315 ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (false);
316 ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (false);
319 } else if (p == "send-mtc") {
321 ActionManager::map_some_state ("options", "SendMTC", &RCConfiguration::get_send_mtc);
323 } else if (p == "send-mmc") {
325 ActionManager::map_some_state ("options", "SendMMC", &RCConfiguration::get_send_mmc);
327 } else if (p == "use-osc") {
330 if (Config->get_use_osc()) {
337 } else if (p == "mmc-control") {
338 ActionManager::map_some_state ("options", "UseMMC", &RCConfiguration::get_mmc_control);
339 } else if (p == "midi-feedback") {
340 ActionManager::map_some_state ("options", "SendMIDIfeedback", &RCConfiguration::get_midi_feedback);
341 } else if (p == "auto-play") {
342 ActionManager::map_some_state ("Transport", "ToggleAutoPlay", mem_fun (session->config, &SessionConfiguration::get_auto_play));
343 } else if (p == "auto-return") {
344 ActionManager::map_some_state ("Transport", "ToggleAutoReturn", mem_fun (session->config, &SessionConfiguration::get_auto_return));
345 } else if (p == "auto-input") {
346 ActionManager::map_some_state ("Transport", "ToggleAutoInput", mem_fun (session->config, &SessionConfiguration::get_auto_input));
347 } else if (p == "punch-out") {
348 ActionManager::map_some_state ("Transport", "TogglePunchOut", mem_fun (session->config, &SessionConfiguration::get_punch_out));
349 if (!session->config.get_punch_out()) {
352 } else if (p == "punch-in") {
353 ActionManager::map_some_state ("Transport", "TogglePunchIn", mem_fun (session->config, &SessionConfiguration::get_punch_in));
354 if (!session->config.get_punch_in()) {
357 } else if (p == "clicking") {
358 ActionManager::map_some_state ("Transport", "ToggleClick", &RCConfiguration::get_clicking);
359 } else if (p == "jack-time-master") {
360 ActionManager::map_some_state ("Transport", "ToggleTimeMaster", mem_fun (session->config, &SessionConfiguration::get_jack_time_master));
361 } else if (p == "use-video-sync") {
362 ActionManager::map_some_state ("Transport", "ToggleVideoSync", mem_fun (session->config, &SessionConfiguration::get_use_video_sync));
363 } else if (p == "shuttle-behaviour") {
365 switch (Config->get_shuttle_behaviour ()) {
367 shuttle_style_button.set_active_text (_("sprung"));
369 shuttle_box.queue_draw ();
371 if (session->transport_rolling()) {
372 shuttle_fract = SHUTTLE_FRACT_SPEED1;
373 session->request_transport_speed (1.0);
378 shuttle_style_button.set_active_text (_("wheel"));
382 } else if (p == "shuttle-units") {
384 switch (Config->get_shuttle_units()) {
386 shuttle_units_button.set_label("% ");
389 shuttle_units_button.set_label(_("ST"));
392 } else if (p == "video-pullup" || p == "timecode-format") {
394 primary_clock.set (session->audible_frame(), true);
395 secondary_clock.set (session->audible_frame(), true);
397 primary_clock.set (0, true);
398 secondary_clock.set (0, true);
400 } else if (p == "show-track-meters") {
401 editor->toggle_meter_updating();