diff options
author | Ben Loftis <ben@glw.com> | 2009-10-21 19:09:40 +0000 |
---|---|---|
committer | Ben Loftis <ben@glw.com> | 2009-10-21 19:09:40 +0000 |
commit | 657e7849e356c1e1c83c1d31418a5e172a8ee329 (patch) | |
tree | 10283d91b9b6d4d49d090d1d85d75fa596f51f62 /gtk2_ardour | |
parent | e75dda66e5d803b51ccb602561b16ff923e65058 (diff) |
Ensure that the loop/punch ruler is always visible when punch in/out is enabled; closes mantis 1294. thanks carlh
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@5846 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/ardour_ui.h | 2 | ||||
-rw-r--r-- | gtk2_ardour/ardour_ui_options.cc | 76 |
2 files changed, 76 insertions, 2 deletions
diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index 317958dbf4..6da33722f6 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -241,6 +241,8 @@ class ARDOUR_UI : public Gtkmm2ext::UI bool ignore_dual_punch; void toggle_punch_in (); void toggle_punch_out (); + void show_loop_punch_ruler_and_disallow_hide (); + void reenable_hide_loop_punch_ruler_if_appropriate (); void toggle_auto_return (); void toggle_click (); diff --git a/gtk2_ardour/ardour_ui_options.cc b/gtk2_ardour/ardour_ui_options.cc index 8923f5c9ba..92454c3253 100644 --- a/gtk2_ardour/ardour_ui_options.cc +++ b/gtk2_ardour/ardour_ui_options.cc @@ -436,13 +436,85 @@ ARDOUR_UI::toggle_punch () void ARDOUR_UI::toggle_punch_in () { - ActionManager::toggle_config_state ("Transport", "TogglePunchIn", &Configuration::set_punch_in, &Configuration::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() != Config->get_punch_in()) { + 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 ("Transport", "TogglePunchOut", &Configuration::set_punch_out, &Configuration::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() != Config->get_punch_out()) { + 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 (!Config->get_punch_in() && !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 |