diff options
-rw-r--r-- | gtk2_ardour/mixer_strip.cc | 52 | ||||
-rw-r--r-- | gtk2_ardour/mixer_strip.h | 4 | ||||
-rw-r--r-- | gtk2_ardour/port_group.cc | 52 | ||||
-rw-r--r-- | gtk2_ardour/port_group.h | 1 | ||||
-rw-r--r-- | gtk2_ardour/port_matrix.cc | 2 | ||||
-rw-r--r-- | gtk2_ardour/port_matrix_column_labels.cc | 24 | ||||
-rw-r--r-- | gtk2_ardour/port_matrix_row_labels.cc | 19 | ||||
-rw-r--r-- | libs/ardour/ardour/bundle.h | 1 | ||||
-rw-r--r-- | libs/ardour/bundle.cc | 23 |
9 files changed, 136 insertions, 42 deletions
diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index f2af375149..1ec93aa9b6 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -646,7 +646,8 @@ MixerStrip::output_press (GdkEventButton *ev) case 3: { output_menu.set_name ("ArdourContextMenu"); - citems.clear(); + citems.clear (); + output_menu_bundles.clear (); citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_output))); citems.push_back (SeparatorElem()); @@ -654,10 +655,21 @@ MixerStrip::output_press (GdkEventButton *ev) ARDOUR::BundleList current = _route->output()->bundles_connected (); boost::shared_ptr<ARDOUR::BundleList> b = _session.bundles (); + + /* give user bundles first chance at being in the menu */ + for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) { - maybe_add_bundle_to_output_menu (*i, current); + if (boost::dynamic_pointer_cast<UserBundle> (*i)) { + maybe_add_bundle_to_output_menu (*i, current); + } } + for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) { + if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0) { + maybe_add_bundle_to_output_menu (*i, current); + } + } + boost::shared_ptr<ARDOUR::RouteList> routes = _session.get_routes (); for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) { maybe_add_bundle_to_output_menu ((*i)->input()->bundle(), current); @@ -731,14 +743,26 @@ MixerStrip::input_press (GdkEventButton *ev) { citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_input))); citems.push_back (SeparatorElem()); + input_menu_bundles.clear (); ARDOUR::BundleList current = _route->input()->bundles_connected (); boost::shared_ptr<ARDOUR::BundleList> b = _session.bundles (); + + /* give user bundles first chance at being in the menu */ + for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) { - maybe_add_bundle_to_input_menu (*i, current); + if (boost::dynamic_pointer_cast<UserBundle> (*i)) { + maybe_add_bundle_to_input_menu (*i, current); + } } + for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) { + if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0) { + maybe_add_bundle_to_input_menu (*i, current); + } + } + boost::shared_ptr<ARDOUR::RouteList> routes = _session.get_routes (); for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) { maybe_add_bundle_to_input_menu ((*i)->output()->bundle(), current); @@ -802,6 +826,17 @@ MixerStrip::maybe_add_bundle_to_input_menu (boost::shared_ptr<Bundle> b, ARDOUR: return; } + list<boost::shared_ptr<Bundle> >::iterator i = input_menu_bundles.begin (); + while (i != input_menu_bundles.end() && b->has_same_ports (*i) == false) { + ++i; + } + + if (i != input_menu_bundles.end()) { + return; + } + + input_menu_bundles.push_back (b); + MenuList& citems = input_menu.items(); std::string n = b->name (); @@ -828,6 +863,17 @@ MixerStrip::maybe_add_bundle_to_output_menu (boost::shared_ptr<Bundle> b, ARDOUR return; } + list<boost::shared_ptr<Bundle> >::iterator i = output_menu_bundles.begin (); + while (i != output_menu_bundles.end() && b->has_same_ports (*i) == false) { + ++i; + } + + if (i != output_menu_bundles.end()) { + return; + } + + output_menu_bundles.push_back (b); + MenuList& citems = output_menu.items(); std::string n = b->name (); diff --git a/gtk2_ardour/mixer_strip.h b/gtk2_ardour/mixer_strip.h index ac68b505ef..fdcf85e1f3 100644 --- a/gtk2_ardour/mixer_strip.h +++ b/gtk2_ardour/mixer_strip.h @@ -187,10 +187,12 @@ class MixerStrip : public RouteUI, public Gtk::EventBox gint input_press (GdkEventButton *); gint output_press (GdkEventButton *); - Gtk::Menu input_menu; + Gtk::Menu input_menu; + std::list<boost::shared_ptr<ARDOUR::Bundle> > input_menu_bundles; void maybe_add_bundle_to_input_menu (boost::shared_ptr<ARDOUR::Bundle>, ARDOUR::BundleList const &); Gtk::Menu output_menu; + std::list<boost::shared_ptr<ARDOUR::Bundle> > output_menu_bundles; void maybe_add_bundle_to_output_menu (boost::shared_ptr<ARDOUR::Bundle>, ARDOUR::BundleList const &); void bundle_input_toggled (boost::shared_ptr<ARDOUR::Bundle>); diff --git a/gtk2_ardour/port_group.cc b/gtk2_ardour/port_group.cc index 240e03eb0f..fceb143d34 100644 --- a/gtk2_ardour/port_group.cc +++ b/gtk2_ardour/port_group.cc @@ -53,7 +53,7 @@ PortGroup::PortGroup (std::string const & n) void PortGroup::add_bundle (boost::shared_ptr<Bundle> b) { - add_bundle (b, boost::shared_ptr<IO> ()); + add_bundle_internal (b, boost::shared_ptr<IO> (), false, Gdk::Color ()); } /** Add a bundle to a group. @@ -62,38 +62,45 @@ PortGroup::add_bundle (boost::shared_ptr<Bundle> b) void PortGroup::add_bundle (boost::shared_ptr<Bundle> b, boost::shared_ptr<IO> io) { - assert (b.get()); - - BundleRecord r; - r.bundle = b; - r.io = io; - r.has_colour = false; - r.changed_connection = b->Changed.connect (sigc::mem_fun (*this, &PortGroup::bundle_changed)); - - _bundles.push_back (r); - - Changed (); + add_bundle_internal (b, io, false, Gdk::Color ()); } /** Add a bundle to a group. * @param b Bundle. - * @param c Colour to represent the group with. + * @param c Colour to represent the bundle with. */ void PortGroup::add_bundle (boost::shared_ptr<Bundle> b, boost::shared_ptr<IO> io, Gdk::Color c) { + add_bundle_internal (b, io, true, c); +} + +void +PortGroup::add_bundle_internal (boost::shared_ptr<Bundle> b, boost::shared_ptr<IO> io, bool has_colour, Gdk::Color colour) +{ assert (b.get()); + /* don't add this bundle if we already have one with the same ports */ + + BundleList::iterator i = _bundles.begin (); + while (i != _bundles.end() && b->has_same_ports (i->bundle) == false) { + ++i; + } + + if (i != _bundles.end ()) { + return; + } + BundleRecord r; r.bundle = b; r.io = io; - r.colour = c; - r.has_colour = true; + r.colour = colour; + r.has_colour = has_colour; r.changed_connection = b->Changed.connect (sigc::mem_fun (*this, &PortGroup::bundle_changed)); _bundles.push_back (r); - Changed (); + Changed (); } void @@ -281,15 +288,24 @@ PortGroupList::gather (ARDOUR::Session& session, bool inputs) } } - /* Bundles owned by the session */ + /* Bundles owned by the session; add user bundles first, then normal ones, so + that UserBundles that offer the same ports as a normal bundle get priority + */ boost::shared_ptr<BundleList> b = session.bundles (); + for (BundleList::iterator i = b->begin(); i != b->end(); ++i) { - if ((*i)->ports_are_inputs() == inputs && (*i)->type() == _type) { + if (boost::dynamic_pointer_cast<UserBundle> (*i) && (*i)->ports_are_inputs() == inputs && (*i)->type() == _type) { system->add_bundle (*i); } } + for (BundleList::iterator i = b->begin(); i != b->end(); ++i) { + if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0 && (*i)->ports_are_inputs() == inputs && (*i)->type() == _type) { + system->add_bundle (*i); + } + } + /* Ardour stuff */ if (!inputs && _type == DataType::AUDIO) { diff --git a/gtk2_ardour/port_group.h b/gtk2_ardour/port_group.h index 456b801201..e382a7f7c6 100644 --- a/gtk2_ardour/port_group.h +++ b/gtk2_ardour/port_group.h @@ -90,6 +90,7 @@ public: private: void bundle_changed (ARDOUR::Bundle::Change); + void add_bundle_internal (boost::shared_ptr<ARDOUR::Bundle>, boost::shared_ptr<ARDOUR::IO>, bool, Gdk::Color); BundleList _bundles; bool _visible; ///< true if the group is visible in the UI diff --git a/gtk2_ardour/port_matrix.cc b/gtk2_ardour/port_matrix.cc index 0b87ee2ee1..1e0db19cf6 100644 --- a/gtk2_ardour/port_matrix.cc +++ b/gtk2_ardour/port_matrix.cc @@ -594,7 +594,7 @@ PortMatrix::add_channel_proxy (boost::weak_ptr<Bundle> w) void PortMatrix::bundle_changed (ARDOUR::Bundle::Change c) { - if (c & (Bundle::DirectionChanged | Bundle::TypeChanged)) { + if (c != Bundle::NameChanged) { setup_all_ports (); } diff --git a/gtk2_ardour/port_matrix_column_labels.cc b/gtk2_ardour/port_matrix_column_labels.cc index fa3d3dd030..70476af7af 100644 --- a/gtk2_ardour/port_matrix_column_labels.cc +++ b/gtk2_ardour/port_matrix_column_labels.cc @@ -424,15 +424,21 @@ PortMatrixColumnLabels::render_channel_name ( ); } - cairo_save (cr); - cairo_rotate (cr, -angle()); - - cairo_show_text ( - cr, - bc.bundle->channel_name(bc.channel).c_str() - ); - - cairo_restore (cr); + if (bc.bundle->nchannels() > 1) { + + /* only plot the name if the bundle has more than one channel; + the name of a single channel is assumed to be redundant */ + + cairo_save (cr); + cairo_rotate (cr, -angle()); + + cairo_show_text ( + cr, + bc.bundle->channel_name(bc.channel).c_str() + ); + + cairo_restore (cr); + } } double diff --git a/gtk2_ardour/port_matrix_row_labels.cc b/gtk2_ardour/port_matrix_row_labels.cc index 47c791afb3..21efda897e 100644 --- a/gtk2_ardour/port_matrix_row_labels.cc +++ b/gtk2_ardour/port_matrix_row_labels.cc @@ -291,13 +291,6 @@ PortMatrixRowLabels::render_bundle_name ( double const off = grid_spacing() / 2; -// if ((*i)->nchannels () > 0 && !_matrix->show_only_bundles()) { -// /* use the extent of our first channel name so that the bundle name is vertically aligned with it */ -// cairo_text_extents_t ext; -// cairo_text_extents (cr, (*i)->channel_name(0).c_str(), &ext); -// off = (grid_spacing() - ext.height) / 2; -// } - set_source_rgb (cr, text_colour()); cairo_move_to (cr, xoff + x + name_pad(), yoff + name_pad() + off); cairo_show_text (cr, b->name().c_str()); @@ -319,9 +312,15 @@ PortMatrixRowLabels::render_channel_name ( cairo_text_extents (cr, bc.bundle->channel_name(bc.channel).c_str(), &ext); double const off = (grid_spacing() - ext.height) / 2; - set_source_rgb (cr, text_colour()); - cairo_move_to (cr, port_name_x() + xoff + name_pad(), yoff + name_pad() + off); - cairo_show_text (cr, bc.bundle->channel_name(bc.channel).c_str()); + if (bc.bundle->nchannels() > 1) { + + /* only plot the name if the bundle has more than one channel; + the name of a single channel is assumed to be redundant */ + + set_source_rgb (cr, text_colour()); + cairo_move_to (cr, port_name_x() + xoff + name_pad(), yoff + name_pad() + off); + cairo_show_text (cr, bc.bundle->channel_name(bc.channel).c_str()); + } } double diff --git a/libs/ardour/ardour/bundle.h b/libs/ardour/ardour/bundle.h index 0c7d6a5978..1af7a3bad0 100644 --- a/libs/ardour/ardour/bundle.h +++ b/libs/ardour/ardour/bundle.h @@ -89,6 +89,7 @@ class Bundle : public sigc::trackable void connect (boost::shared_ptr<Bundle>, AudioEngine &); void disconnect (boost::shared_ptr<Bundle>, AudioEngine &); bool connected_to (boost::shared_ptr<Bundle>, AudioEngine &); + bool has_same_ports (boost::shared_ptr<Bundle>) const; void set_name (std::string const &); diff --git a/libs/ardour/bundle.cc b/libs/ardour/bundle.cc index 4f2198fd41..f409e0beee 100644 --- a/libs/ardour/bundle.cc +++ b/libs/ardour/bundle.cc @@ -466,3 +466,26 @@ Bundle::set_name (string const & n) _name = n; emit_changed (NameChanged); } + +/** @param b Other bundle. + * @return true if b has the same number of channels as this bundle, and those channels have corresponding ports. + */ +bool +Bundle::has_same_ports (boost::shared_ptr<Bundle> b) const +{ + uint32_t const N = nchannels (); + + if (b->nchannels() != N) { + return false; + } + + /* XXX: probably should sort channel port lists before comparing them */ + + for (uint32_t i = 0; i < N; ++i) { + if (channel_ports (i) != b->channel_ports (i)) { + return false; + } + } + + return true; +} |