+ int overlaid = 0;
+ int stacked = 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;
+ }
+
+ switch (v->layer_display ()) {
+ case Overlaid:
+ ++overlaid;
+ break;
+ case Stacked:
+ ++stacked;
+ break;
+ }
+ }
+
+ /* 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
+ select the active one, no toggled signal is emitted so nothing happens.
+ */
+
+ layers_items.push_back (RadioMenuElem (layers_group, _("Overlaid")));
+ RadioMenuItem* i = dynamic_cast<RadioMenuItem*> (&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));
+
+ layers_items.push_back (
+ RadioMenuElem (layers_group, _("Stacked"),
+ sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Stacked, true))
+ );
+
+ i = dynamic_cast<RadioMenuItem*> (&layers_items.back ());
+ i->signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Stacked, true));
+ i->set_active (overlaid == 0 && stacked != 0);
+ i->set_inconsistent (overlaid != 0 && stacked != 0);
+