mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-07 07:14:56 +01:00
Various adjustments to user bundle handling, with the general aim of allowing the user to create meaningful bundles with respect to their sound card an outboard setup, and having those user bundles take priority over ardour-generated ones.
git-svn-id: svn://localhost/ardour2/branches/3.0@6050 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
da03bc931b
commit
dbb0b9ca4f
9 changed files with 135 additions and 41 deletions
|
|
@ -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 ();
|
||||
|
|
|
|||
|
|
@ -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>);
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 ();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -424,15 +424,21 @@ PortMatrixColumnLabels::render_channel_name (
|
|||
);
|
||||
}
|
||||
|
||||
cairo_save (cr);
|
||||
cairo_rotate (cr, -angle());
|
||||
if (bc.bundle->nchannels() > 1) {
|
||||
|
||||
cairo_show_text (
|
||||
cr,
|
||||
bc.bundle->channel_name(bc.channel).c_str()
|
||||
);
|
||||
|
||||
cairo_restore (cr);
|
||||
/* 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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 &);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue