From bd3f713d0e1bf4febbf6186ef6bc060778f658f6 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 17 Dec 2022 19:13:26 +0100 Subject: [PATCH] Fix gain menu (polarity, envelope) with multiple selection --- gtk2_ardour/editor_selection.cc | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/gtk2_ardour/editor_selection.cc b/gtk2_ardour/editor_selection.cc index a80d762554..eeabc7ada4 100644 --- a/gtk2_ardour/editor_selection.cc +++ b/gtk2_ardour/editor_selection.cc @@ -1512,8 +1512,11 @@ Editor::sensitize_the_right_region_actions (bool because_canvas_crossing) have_inactive_fade_out = true; } - have_inverted_polarity = ar->scale_amplitude () < 0; - have_non_inverted_polarity = ar->scale_amplitude () >= 0; + if (ar->scale_amplitude () < 0) { + have_inverted_polarity = true; + } else { + have_non_inverted_polarity = true; + } } } @@ -1564,14 +1567,18 @@ Editor::sensitize_the_right_region_actions (bool because_canvas_crossing) if (have_audio) { - if (have_envelope_active && !have_envelope_inactive) { - Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-gain-envelope-active"))->set_active (); + if (have_envelope_active != have_envelope_inactive) { + Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-gain-envelope-active"))->set_active (have_envelope_active); } else if (have_envelope_active && have_envelope_inactive) { - // Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-gain-envelope-active"))->set_inconsistent (); + // Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-gain-envelope-active"))->set_inconsistent (); // N/A + Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-gain-envelope-active"))->set_sensitive (false); } - if (have_inverted_polarity && !have_non_inverted_polarity) { - Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-polarity"))->set_active (); + if (have_inverted_polarity != have_non_inverted_polarity) { + Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-polarity"))->set_active (have_inverted_polarity); + } else if (have_inverted_polarity && have_non_inverted_polarity) { + // Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-polarity"))->set_inconsistent (); // N/A + Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-polarity"))->set_sensitive (false); } } else {