Make alignment options work across the track selection. Also remove code to update the options now that the menu is rebuilt every time it is shown.
git-svn-id: svn://localhost/ardour2/branches/3.0@8941 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
@@ -474,11 +474,14 @@ RouteTimeAxisView::build_display_menu ()
|
||||
if (!v) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (v->layer_display() == Overlaid) {
|
||||
|
||||
switch (v->layer_display ()) {
|
||||
case Overlaid:
|
||||
++overlaid;
|
||||
} else if (v->layer_display() == Stacked) {
|
||||
break;
|
||||
case Stacked:
|
||||
++stacked;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -513,23 +516,41 @@ RouteTimeAxisView::build_display_menu ()
|
||||
alignment_menu->set_name ("ArdourContextMenu");
|
||||
|
||||
RadioMenuItem::Group align_group;
|
||||
|
||||
alignment_items.push_back (RadioMenuElem (align_group, _("Align With Existing Material"),
|
||||
sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), ExistingMaterial)));
|
||||
align_existing_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
|
||||
if (track()->alignment_style() == ExistingMaterial) {
|
||||
align_existing_item->set_active();
|
||||
|
||||
/* Same verbose hacks as for the layering options above */
|
||||
|
||||
int existing = 0;
|
||||
int capture = 0;
|
||||
TrackSelection const & s = _editor.get_selection().tracks;
|
||||
for (TrackSelection::const_iterator i = s.begin(); i != s.end(); ++i) {
|
||||
RouteTimeAxisView* r = dynamic_cast<RouteTimeAxisView*> (*i);
|
||||
if (!r) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (r->track()->alignment_style()) {
|
||||
case ExistingMaterial:
|
||||
++existing;
|
||||
break;
|
||||
case CaptureTime:
|
||||
++capture;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
alignment_items.push_back (RadioMenuElem (align_group, _("Align With Capture Time"),
|
||||
sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), CaptureTime)));
|
||||
align_capture_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
|
||||
if (track()->alignment_style() == CaptureTime) {
|
||||
align_capture_item->set_active();
|
||||
}
|
||||
alignment_items.push_back (RadioMenuElem (align_group, _("Align With Existing Material")));
|
||||
RadioMenuItem* i = dynamic_cast<RadioMenuItem*> (&alignment_items.back());
|
||||
i->signal_activate().connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), ExistingMaterial, true));
|
||||
i->set_active (existing != 0 && capture == 0);
|
||||
i->set_inconsistent (existing != 0 && capture != 0);
|
||||
|
||||
alignment_items.push_back (RadioMenuElem (align_group, _("Align With Capture Time")));
|
||||
i = dynamic_cast<RadioMenuItem*> (&alignment_items.back());
|
||||
i->signal_activate().connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), CaptureTime, true));
|
||||
i->set_active (existing == 0 && capture != 0);
|
||||
i->set_inconsistent (existing != 0 && capture != 0);
|
||||
|
||||
items.push_back (MenuElem (_("Alignment"), *alignment_menu));
|
||||
track()->AlignmentStyleChanged.connect (route_connections, invalidator (*this), boost::bind (&RouteTimeAxisView::align_style_changed, this), gui_context());
|
||||
|
||||
Menu* mode_menu = manage (new Menu);
|
||||
MenuList& mode_items = mode_menu->items ();
|
||||
@@ -935,41 +956,11 @@ RouteTimeAxisView::set_samples_per_unit (double spu)
|
||||
}
|
||||
|
||||
void
|
||||
RouteTimeAxisView::align_style_changed ()
|
||||
RouteTimeAxisView::set_align_style (AlignStyle style, bool apply_to_selection)
|
||||
{
|
||||
switch (track()->alignment_style()) {
|
||||
case ExistingMaterial:
|
||||
if (!align_existing_item->get_active()) {
|
||||
align_existing_item->set_active();
|
||||
}
|
||||
break;
|
||||
case CaptureTime:
|
||||
if (!align_capture_item->get_active()) {
|
||||
align_capture_item->set_active();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
RouteTimeAxisView::set_align_style (AlignStyle style)
|
||||
{
|
||||
RadioMenuItem* item;
|
||||
|
||||
switch (style) {
|
||||
case ExistingMaterial:
|
||||
item = align_existing_item;
|
||||
break;
|
||||
case CaptureTime:
|
||||
item = align_capture_item;
|
||||
break;
|
||||
default:
|
||||
fatal << string_compose (_("programming error: %1 %2"), "illegal align style in RouteTimeAxisView::set_align_style", style) << endmsg;
|
||||
/*NOTREACHED*/
|
||||
return;
|
||||
}
|
||||
|
||||
if (item->get_active()) {
|
||||
if (apply_to_selection) {
|
||||
_editor.get_selection().tracks.foreach_route_time_axis (boost::bind (&RouteTimeAxisView::set_align_style, _1, style, false));
|
||||
} else {
|
||||
track()->set_align_style (style);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,8 +218,7 @@ protected:
|
||||
virtual void append_extra_display_menu_items () {}
|
||||
void build_display_menu ();
|
||||
|
||||
void align_style_changed ();
|
||||
void set_align_style (ARDOUR::AlignStyle);
|
||||
void set_align_style (ARDOUR::AlignStyle, bool apply_to_selection = false);
|
||||
|
||||
void playlist_click ();
|
||||
void show_playlist_selector ();
|
||||
@@ -261,8 +260,6 @@ protected:
|
||||
Gtk::Menu* automation_action_menu;
|
||||
Gtk::MenuItem* plugins_submenu_item;
|
||||
RouteGroupMenu* route_group_menu;
|
||||
Gtk::RadioMenuItem* align_existing_item;
|
||||
Gtk::RadioMenuItem* align_capture_item;
|
||||
Gtk::RadioMenuItem* normal_track_mode_item;
|
||||
Gtk::RadioMenuItem* non_layered_track_mode_item;
|
||||
Gtk::RadioMenuItem* destructive_track_mode_item;
|
||||
|
||||
Reference in New Issue
Block a user