summaryrefslogtreecommitdiff
path: root/gtk2_ardour/ardour_ui_options.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2009-10-20 21:58:46 +0000
committerCarl Hetherington <carl@carlh.net>2009-10-20 21:58:46 +0000
commitc206cad638275a7bfc166d0a07d211d4f6e3e4e1 (patch)
tree47b7cb196cb291ee89e0d92a65701692c8793757 /gtk2_ardour/ardour_ui_options.cc
parent960efd79a3cb51a655aa42f807bac571ecbdebec (diff)
Ensure that the loop/punch ruler is always visible when punch in/out is enabled; closes mantis 1294.
git-svn-id: svn://localhost/ardour2/branches/3.0@5828 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/ardour_ui_options.cc')
-rw-r--r--gtk2_ardour/ardour_ui_options.cc77
1 files changed, 75 insertions, 2 deletions
diff --git a/gtk2_ardour/ardour_ui_options.cc b/gtk2_ardour/ardour_ui_options.cc
index bade3906a4..29c7c3cc6c 100644
--- a/gtk2_ardour/ardour_ui_options.cc
+++ b/gtk2_ardour/ardour_ui_options.cc
@@ -172,13 +172,86 @@ ARDOUR_UI::toggle_punch ()
void
ARDOUR_UI::toggle_punch_in ()
{
- ActionManager::toggle_config_state_foo ("Transport", "TogglePunchIn", mem_fun (session->config, &SessionConfiguration::set_punch_in), mem_fun (session->config, &SessionConfiguration::get_punch_in));
+ Glib::RefPtr<Action> act = ActionManager::get_action (X_("Transport"), X_("TogglePunchIn"));
+ if (!act) {
+ return;
+ }
+
+ Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
+ if (!tact) {
+ return;
+ }
+
+ if (tact->get_active() != session->config.get_punch_in()) {
+ session->config.set_punch_in (tact->get_active ());
+ }
+
+ if (tact->get_active()) {
+ /* if punch-in is turned on, make sure the loop/punch ruler is visible, and stop it being hidden,
+ to avoid confusing the user */
+ show_loop_punch_ruler_and_disallow_hide ();
+ }
+
+ reenable_hide_loop_punch_ruler_if_appropriate ();
}
void
ARDOUR_UI::toggle_punch_out ()
{
- ActionManager::toggle_config_state_foo ("Transport", "TogglePunchOut", mem_fun (session->config, &SessionConfiguration::set_punch_out), mem_fun (session->config, &SessionConfiguration::get_punch_out));
+ Glib::RefPtr<Action> act = ActionManager::get_action (X_("Transport"), X_("TogglePunchOut"));
+ if (!act) {
+ return;
+ }
+
+ Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
+ if (!tact) {
+ return;
+ }
+
+ if (tact->get_active() != session->config.get_punch_out()) {
+ session->config.set_punch_out (tact->get_active ());
+ }
+
+ if (tact->get_active()) {
+ /* if punch-out is turned on, make sure the loop/punch ruler is visible, and stop it being hidden,
+ to avoid confusing the user */
+ show_loop_punch_ruler_and_disallow_hide ();
+ }
+
+ reenable_hide_loop_punch_ruler_if_appropriate ();
+}
+
+void
+ARDOUR_UI::show_loop_punch_ruler_and_disallow_hide ()
+{
+ Glib::RefPtr<Action> act = ActionManager::get_action (X_("Rulers"), "toggle-loop-punch-ruler");
+ if (!act) {
+ return;
+ }
+
+ act->set_sensitive (false);
+
+ Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
+ if (!tact) {
+ return;
+ }
+
+ if (!tact->get_active()) {
+ tact->set_active ();
+ }
+}
+
+/* This is a bit of a silly name for a method */
+void
+ARDOUR_UI::reenable_hide_loop_punch_ruler_if_appropriate ()
+{
+ if (!session->config.get_punch_in() && !session->config.get_punch_out()) {
+ /* if punch in/out are now both off, reallow hiding of the loop/punch ruler */
+ Glib::RefPtr<Action> act = ActionManager::get_action (X_("Rulers"), "toggle-loop-punch-ruler");
+ if (act) {
+ act->set_sensitive (true);
+ }
+ }
}
void