From 743fbaf7bf992bdd1d277df7fd34e6965f327a16 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 3 Apr 2020 18:48:34 -0600 Subject: change implementation of layer display menu items and handlers The menu items no longer ever apply to the selection, because there will be an Editor-level action to change things "globally" --- gtk2_ardour/route_time_axis.cc | 65 ++++++++++++++---------------------------- 1 file changed, 21 insertions(+), 44 deletions(-) (limited to 'gtk2_ardour/route_time_axis.cc') diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc index d092f58a45..4d24e73bf8 100644 --- a/gtk2_ardour/route_time_axis.cc +++ b/gtk2_ardour/route_time_axis.cc @@ -652,34 +652,6 @@ RouteTimeAxisView::build_display_menu () RadioMenuItem::Group layers_group; - /* Find out how many overlaid/stacked tracks we have in the selection */ - - int overlaid = 0; - int stacked = 0; - int unchangeable = 0; - TrackSelection const & s = _editor.get_selection().tracks; - - for (TrackSelection::const_iterator i = s.begin(); i != s.end(); ++i) { - StreamView* v = (*i)->view (); - if (!v) { - continue; - } - - if (v->can_change_layer_display()) { - switch (v->layer_display ()) { - case Overlaid: - ++overlaid; - break; - case Stacked: - case Expanded: - ++stacked; - break; - } - } else { - unchangeable++; - } - } - /* We're not connecting to signal_toggled() here; in the case where these two items are set to be in the `inconsistent' state, it seems that one or other will end up active as well as inconsistent (presumably due to the RadioMenuItem::Group). Then when you @@ -690,26 +662,16 @@ RouteTimeAxisView::build_display_menu () layers_items.push_back (RadioMenuElem (layers_group, _("Overlaid"))); RadioMenuItem* i = dynamic_cast (&layers_items.back ()); - i->set_active (overlaid != 0 && stacked == 0); - i->set_inconsistent (overlaid != 0 && stacked != 0); - i->signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Overlaid, true)); + i->set_active (layer_display() == Overlaid); + i->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::layer_display_menu_change), i)); overlaid_menu_item = i; - if (unchangeable) { - i->set_sensitive (false); - } - layers_items.push_back (RadioMenuElem (layers_group, _("Stacked"))); i = dynamic_cast (&layers_items.back ()); - i->set_active (overlaid == 0 && stacked != 0); - i->set_inconsistent (overlaid != 0 && stacked != 0); - i->signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Stacked, true)); + i->set_active (layer_display() == Stacked); + i->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::layer_display_menu_change), i)); stacked_menu_item = i; - if (unchangeable) { - i->set_sensitive (false); - } - _ignore_set_layer_display = false; items.push_back (MenuElem (_("Layers"), *layers_menu)); @@ -720,13 +682,12 @@ RouteTimeAxisView::build_display_menu () RadioMenuItem::Group align_group; - /* Same verbose hacks as for the layering options above */ - int existing = 0; int capture = 0; int automatic = 0; int styles = 0; boost::shared_ptr first_track; + TrackSelection const & s = _editor.get_selection().tracks; for (TrackSelection::const_iterator t = s.begin(); t != s.end(); ++t) { RouteTimeAxisView* r = dynamic_cast (*t); @@ -889,6 +850,22 @@ RouteTimeAxisView::build_display_menu () items.push_back (MenuElem (_("Remove"), sigc::mem_fun(_editor, &PublicEditor::remove_tracks))); } +void +RouteTimeAxisView::layer_display_menu_change (Gtk::MenuItem* item) +{ + /* change only if the item is now active, since this will be called for + both buttons as one becomes active and the other inactive. + */ + + if (dynamic_cast(item)->get_active()) { + if (item == stacked_menu_item) { + set_layer_display (Stacked, false); + } else { + set_layer_display (Overlaid, false); + } + } +} + void RouteTimeAxisView::show_timestretch (samplepos_t start, samplepos_t end, int layers, int layer) { -- cgit v1.2.3