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
;
50 ARDOUR_UI::toggle_external_sync()
52 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
));
56 ARDOUR_UI::toggle_time_master ()
58 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
));
62 ARDOUR_UI::toggle_send_mtc ()
64 ActionManager::toggle_config_state ("options", "SendMTC", &RCConfiguration::set_send_mtc
, &RCConfiguration::get_send_mtc
);
68 ARDOUR_UI::toggle_send_mmc ()
70 ActionManager::toggle_config_state ("options", "SendMMC", &RCConfiguration::set_send_mmc
, &RCConfiguration::get_send_mmc
);
74 ARDOUR_UI::toggle_send_midi_clock ()
76 ActionManager::toggle_config_state ("options", "SendMidiClock", &RCConfiguration::set_send_midi_clock
, &RCConfiguration::get_send_midi_clock
);
80 ARDOUR_UI::toggle_use_mmc ()
82 ActionManager::toggle_config_state ("options", "UseMMC", &RCConfiguration::set_mmc_control
, &RCConfiguration::get_mmc_control
);
86 ARDOUR_UI::toggle_send_midi_feedback ()
88 ActionManager::toggle_config_state ("options", "SendMIDIfeedback", &RCConfiguration::set_midi_feedback
, &RCConfiguration::get_midi_feedback
);
92 ARDOUR_UI::toggle_auto_input ()
94 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
));
98 ARDOUR_UI::toggle_auto_play ()
100 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
));
104 ARDOUR_UI::toggle_auto_return ()
106 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
));
110 ARDOUR_UI::toggle_click ()
112 ActionManager::toggle_config_state ("Transport", "ToggleClick", &RCConfiguration::set_clicking
, &RCConfiguration::get_clicking
);
116 ARDOUR_UI::unset_dual_punch ()
118 Glib::RefPtr
<Action
> action
= ActionManager::get_action ("Transport", "TogglePunch");
121 Glib::RefPtr
<ToggleAction
> tact
= Glib::RefPtr
<ToggleAction
>::cast_dynamic(action
);
123 ignore_dual_punch
= true;
124 tact
->set_active (false);
125 ignore_dual_punch
= false;
131 ARDOUR_UI::toggle_punch ()
133 if (ignore_dual_punch
) {
137 Glib::RefPtr
<Action
> action
= ActionManager::get_action ("Transport", "TogglePunch");
141 Glib::RefPtr
<ToggleAction
> tact
= Glib::RefPtr
<ToggleAction
>::cast_dynamic(action
);
147 /* drive the other two actions from this one */
149 Glib::RefPtr
<Action
> in_action
= ActionManager::get_action ("Transport", "TogglePunchIn");
150 Glib::RefPtr
<Action
> out_action
= ActionManager::get_action ("Transport", "TogglePunchOut");
152 if (in_action
&& out_action
) {
153 Glib::RefPtr
<ToggleAction
> tiact
= Glib::RefPtr
<ToggleAction
>::cast_dynamic(in_action
);
154 Glib::RefPtr
<ToggleAction
> toact
= Glib::RefPtr
<ToggleAction
>::cast_dynamic(out_action
);
155 tiact
->set_active (tact
->get_active());
156 toact
->set_active (tact
->get_active());
162 ARDOUR_UI::toggle_punch_in ()
164 Glib::RefPtr
<Action
> act
= ActionManager::get_action (X_("Transport"), X_("TogglePunchIn"));
169 Glib::RefPtr
<ToggleAction
> tact
= Glib::RefPtr
<ToggleAction
>::cast_dynamic (act
);
174 if (tact
->get_active() != _session
->config
.get_punch_in()) {
175 _session
->config
.set_punch_in (tact
->get_active ());
178 if (tact
->get_active()) {
179 /* if punch-in is turned on, make sure the loop/punch ruler is visible, and stop it being hidden,
180 to avoid confusing the user */
181 show_loop_punch_ruler_and_disallow_hide ();
184 reenable_hide_loop_punch_ruler_if_appropriate ();
188 ARDOUR_UI::toggle_punch_out ()
190 Glib::RefPtr
<Action
> act
= ActionManager::get_action (X_("Transport"), X_("TogglePunchOut"));
195 Glib::RefPtr
<ToggleAction
> tact
= Glib::RefPtr
<ToggleAction
>::cast_dynamic (act
);
200 if (tact
->get_active() != _session
->config
.get_punch_out()) {
201 _session
->config
.set_punch_out (tact
->get_active ());
204 if (tact
->get_active()) {
205 /* if punch-out is turned on, make sure the loop/punch ruler is visible, and stop it being hidden,
206 to avoid confusing the user */
207 show_loop_punch_ruler_and_disallow_hide ();
210 reenable_hide_loop_punch_ruler_if_appropriate ();
214 ARDOUR_UI::show_loop_punch_ruler_and_disallow_hide ()
216 Glib::RefPtr
<Action
> act
= ActionManager::get_action (X_("Rulers"), "toggle-loop-punch-ruler");
221 act
->set_sensitive (false);
223 Glib::RefPtr
<ToggleAction
> tact
= Glib::RefPtr
<ToggleAction
>::cast_dynamic (act
);
228 if (!tact
->get_active()) {
233 /* This is a bit of a silly name for a method */
235 ARDOUR_UI::reenable_hide_loop_punch_ruler_if_appropriate ()
237 if (!_session
->config
.get_punch_in() && !_session
->config
.get_punch_out()) {
238 /* if punch in/out are now both off, reallow hiding of the loop/punch ruler */
239 Glib::RefPtr
<Action
> act
= ActionManager::get_action (X_("Rulers"), "toggle-loop-punch-ruler");
241 act
->set_sensitive (true);
247 ARDOUR_UI::toggle_video_sync()
249 Glib::RefPtr
<Action
> act
= ActionManager::get_action ("Transport", "ToggleVideoSync");
251 Glib::RefPtr
<ToggleAction
> tact
= Glib::RefPtr
<ToggleAction
>::cast_dynamic(act
);
252 _session
->config
.set_use_video_sync (tact
->get_active());
257 ARDOUR_UI::toggle_editing_space()
259 Glib::RefPtr
<Action
> act
= ActionManager::get_action ("Common", "ToggleMaximalEditor");
261 Glib::RefPtr
<ToggleAction
> tact
= Glib::RefPtr
<ToggleAction
>::cast_dynamic(act
);
262 if (tact
->get_active()) {
263 maximise_editing_space ();
265 restore_editing_space ();
271 ARDOUR_UI::setup_session_options ()
273 _session
->config
.ParameterChanged
.connect (_session_connections
, MISSING_INVALIDATOR
, ui_bind (&ARDOUR_UI::parameter_changed
, this, _1
), gui_context());
274 boost::function
<void (std::string
)> pc (boost::bind (&ARDOUR_UI::parameter_changed
, this, _1
));
275 _session
->config
.map_parameters (pc
);
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 (*this, &ARDOUR_UI::parameter_changed
, p
)
304 if (p
== "external-sync") {
306 ActionManager::map_some_state ("Transport", "ToggleExternalSync", sigc::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", sigc::mem_fun (_session
->config
, &SessionConfiguration::get_auto_play
));
343 } else if (p
== "auto-return") {
344 ActionManager::map_some_state ("Transport", "ToggleAutoReturn", sigc::mem_fun (_session
->config
, &SessionConfiguration::get_auto_return
));
345 } else if (p
== "auto-input") {
346 ActionManager::map_some_state ("Transport", "ToggleAutoInput", sigc::mem_fun (_session
->config
, &SessionConfiguration::get_auto_input
));
347 } else if (p
== "punch-out") {
348 ActionManager::map_some_state ("Transport", "TogglePunchOut", sigc::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", sigc::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", sigc::mem_fun (_session
->config
, &SessionConfiguration::get_jack_time_master
));
361 } else if (p
== "use-video-sync") {
362 ActionManager::map_some_state ("Transport", "ToggleVideoSync", sigc::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") {
393 reset_main_clocks ();
394 } else if (p
== "show-track-meters") {
395 editor
->toggle_meter_updating();
400 ARDOUR_UI::reset_main_clocks ()
402 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::reset_main_clocks
)
405 primary_clock
.set (_session
->audible_frame(), true);
406 secondary_clock
.set (_session
->audible_frame(), true);
408 primary_clock
.set (0, true);
409 secondary_clock
.set (0, true);