13
0

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"
This commit is contained in:
Paul Davis 2020-04-03 18:48:34 -06:00
parent d1e55ff5b7
commit 743fbaf7bf
2 changed files with 22 additions and 44 deletions

View File

@ -652,34 +652,6 @@ RouteTimeAxisView::build_display_menu ()
RadioMenuItem::Group layers_group; 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 /* 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 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 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"))); layers_items.push_back (RadioMenuElem (layers_group, _("Overlaid")));
RadioMenuItem* i = dynamic_cast<RadioMenuItem*> (&layers_items.back ()); RadioMenuItem* i = dynamic_cast<RadioMenuItem*> (&layers_items.back ());
i->set_active (overlaid != 0 && stacked == 0); i->set_active (layer_display() == Overlaid);
i->set_inconsistent (overlaid != 0 && stacked != 0); i->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::layer_display_menu_change), i));
i->signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Overlaid, true));
overlaid_menu_item = i; overlaid_menu_item = i;
if (unchangeable) {
i->set_sensitive (false);
}
layers_items.push_back (RadioMenuElem (layers_group, _("Stacked"))); layers_items.push_back (RadioMenuElem (layers_group, _("Stacked")));
i = dynamic_cast<RadioMenuItem*> (&layers_items.back ()); i = dynamic_cast<RadioMenuItem*> (&layers_items.back ());
i->set_active (overlaid == 0 && stacked != 0); i->set_active (layer_display() == Stacked);
i->set_inconsistent (overlaid != 0 && stacked != 0); i->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::layer_display_menu_change), i));
i->signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Stacked, true));
stacked_menu_item = i; stacked_menu_item = i;
if (unchangeable) {
i->set_sensitive (false);
}
_ignore_set_layer_display = false; _ignore_set_layer_display = false;
items.push_back (MenuElem (_("Layers"), *layers_menu)); items.push_back (MenuElem (_("Layers"), *layers_menu));
@ -720,13 +682,12 @@ RouteTimeAxisView::build_display_menu ()
RadioMenuItem::Group align_group; RadioMenuItem::Group align_group;
/* Same verbose hacks as for the layering options above */
int existing = 0; int existing = 0;
int capture = 0; int capture = 0;
int automatic = 0; int automatic = 0;
int styles = 0; int styles = 0;
boost::shared_ptr<Track> first_track; boost::shared_ptr<Track> first_track;
TrackSelection const & s = _editor.get_selection().tracks;
for (TrackSelection::const_iterator t = s.begin(); t != s.end(); ++t) { for (TrackSelection::const_iterator t = s.begin(); t != s.end(); ++t) {
RouteTimeAxisView* r = dynamic_cast<RouteTimeAxisView*> (*t); RouteTimeAxisView* r = dynamic_cast<RouteTimeAxisView*> (*t);
@ -889,6 +850,22 @@ RouteTimeAxisView::build_display_menu ()
items.push_back (MenuElem (_("Remove"), sigc::mem_fun(_editor, &PublicEditor::remove_tracks))); 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<RadioMenuItem*>(item)->get_active()) {
if (item == stacked_menu_item) {
set_layer_display (Stacked, false);
} else {
set_layer_display (Overlaid, false);
}
}
}
void void
RouteTimeAxisView::show_timestretch (samplepos_t start, samplepos_t end, int layers, int layer) RouteTimeAxisView::show_timestretch (samplepos_t start, samplepos_t end, int layers, int layer)
{ {

View File

@ -291,6 +291,7 @@ protected:
UnderlayMirrorList _underlay_mirrors; UnderlayMirrorList _underlay_mirrors;
bool _ignore_set_layer_display; bool _ignore_set_layer_display;
void layer_display_menu_change (Gtk::MenuItem* item);
protected: protected:
void update_pan_track_visibility (); void update_pan_track_visibility ();