#include <pbd/convert.h>
#include <pbd/enumwriter.h>
+#include <pbd/replace_all.h>
#include <gtkmm2ext/gtk_ui.h>
#include <gtkmm2ext/utils.h>
#include <ardour/session.h>
#include <ardour/audioengine.h>
#include <ardour/route.h>
+#include <ardour/route_group.h>
#include <ardour/audio_track.h>
#include <ardour/audio_diskstream.h>
#include <ardour/panner.h>
hide_button.add (*img);
input_label.set_text (_("Input"));
- ARDOUR_UI::instance()->set_tip (&input_button, _("Click to choose inputs"), "");
+ ARDOUR_UI::instance()->set_tip (&input_button, _("Button 1 to choose inputs from a port matrix, button 3 to select inputs from a menu"), "");
input_button.add (input_label);
input_button.set_name ("MixerIOButton");
input_label.set_name ("MixerIOButtonLabel");
+ Gtkmm2ext::set_size_request_to_display_given_text (input_button, "longest label", 4, 4);
output_label.set_text (_("Output"));
- ARDOUR_UI::instance()->set_tip (&output_button, _("Click to choose outputs"), "");
+ ARDOUR_UI::instance()->set_tip (&output_button, _("Button 1 to choose outputs from a port matrix, button 3 to select inputs from a menu"), "");
output_button.add (output_label);
output_button.set_name ("MixerIOButton");
output_label.set_name ("MixerIOButtonLabel");
+ Gtkmm2ext::set_size_request_to_display_given_text (output_button, "longest label", 4, 4);
ARDOUR_UI::instance()->set_tip (&meter_point_button, _("Select metering point"), "");
meter_point_button.add (meter_point_label);
switch (ev->button) {
case 1:
+ edit_output_configuration ();
+ break;
+
+ case 3:
{
output_menu.set_name ("ArdourContextMenu");
citems.clear();
- citems.push_back (MenuElem (_("Edit"), mem_fun(*this, &MixerStrip::edit_output_configuration)));
- citems.push_back (SeparatorElem());
citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_output)));
citems.push_back (SeparatorElem());
boost::shared_ptr<ARDOUR::BundleList> b = _session.bundles ();
for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
- add_bundle_to_output_menu (*i, current);
+ 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)->bundle_for_inputs(), current);
+ }
+
+ if (citems.size() == 2) {
+ /* no routes added; remove the separator */
+ citems.pop_back ();
}
output_menu.popup (1, ev->time);
break;
}
-
+
default:
break;
}
switch (ev->button) {
case 1:
+ edit_input_configuration ();
+ break;
+
+ case 3:
{
- citems.push_back (MenuElem (_("Edit"), mem_fun(*this, &MixerStrip::edit_input_configuration)));
- citems.push_back (SeparatorElem());
citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_input)));
citems.push_back (SeparatorElem());
boost::shared_ptr<ARDOUR::BundleList> b = _session.bundles ();
for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
- add_bundle_to_input_menu (*i, current);
+ 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)->bundle_for_outputs(), current);
+ }
+
+ if (citems.size() == 2) {
+ /* no routes added; remove the separator */
+ citems.pop_back ();
}
input_menu.popup (1, ev->time);
}
void
-MixerStrip::bundle_input_chosen (boost::shared_ptr<ARDOUR::Bundle> c)
+MixerStrip::bundle_input_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
{
- if (!ignore_toggle) {
+ if (ignore_toggle) {
+ return;
+ }
- try {
- _route->connect_input_ports_to_bundle (c, this);
- }
+ ARDOUR::BundleList current = _route->bundles_connected_to_inputs ();
- catch (AudioEngine::PortRegistrationFailure& err) {
- error << _("could not register new ports required for that bundle")
- << endmsg;
- }
+ if (std::find (current.begin(), current.end(), c) == current.end()) {
+ _route->connect_input_ports_to_bundle (c, this);
+ } else {
+ _route->disconnect_input_ports_from_bundle (c, this);
}
}
void
-MixerStrip::bundle_output_chosen (boost::shared_ptr<ARDOUR::Bundle> c)
+MixerStrip::bundle_output_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
{
- if (!ignore_toggle) {
+ if (ignore_toggle) {
+ return;
+ }
- try {
- _route->connect_output_ports_to_bundle (c, this);
- }
+ ARDOUR::BundleList current = _route->bundles_connected_to_outputs ();
- catch (AudioEngine::PortRegistrationFailure& err) {
- error << _("could not register new ports required for that bundle")
- << endmsg;
- }
+ if (std::find (current.begin(), current.end(), c) == current.end()) {
+ _route->connect_output_ports_to_bundle (c, this);
+ } else {
+ _route->disconnect_output_ports_from_bundle (c, this);
}
}
void
-MixerStrip::add_bundle_to_input_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
+MixerStrip::maybe_add_bundle_to_input_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
{
using namespace Menu_Helpers;
- /* the input menu needs to contain only output bundles (that we
- can connect inputs to */
- if (b->ports_are_outputs() == false) {
+ if (b->ports_are_outputs() == false ||
+ route()->default_type() != b->type() ||
+ b->nchannels() != _route->n_inputs().get (b->type ())) {
+
return;
}
MenuList& citems = input_menu.items();
- if (b->nchannels() == _route->n_inputs().get (b->type ())) {
-
- citems.push_back (CheckMenuElem (b->name(), bind (mem_fun(*this, &MixerStrip::bundle_input_chosen), b)));
-
- if (std::find (current.begin(), current.end(), b) != current.end()) {
- ignore_toggle = true;
- dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
- ignore_toggle = false;
- }
+ std::string n = b->name ();
+ replace_all (n, "_", " ");
+
+ citems.push_back (CheckMenuElem (n, bind (mem_fun(*this, &MixerStrip::bundle_input_toggled), b)));
+
+ if (std::find (current.begin(), current.end(), b) != current.end()) {
+ ignore_toggle = true;
+ dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
+ ignore_toggle = false;
}
}
void
-MixerStrip::add_bundle_to_output_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
+MixerStrip::maybe_add_bundle_to_output_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
{
using namespace Menu_Helpers;
- /* the output menu needs to contain only input bundles (that we
- can connect outputs to */
- if (b->ports_are_inputs() == false) {
+ if (b->ports_are_inputs() == false ||
+ route()->default_type() != b->type() ||
+ b->nchannels() != _route->n_outputs().get (b->type ())) {
+
return;
}
- if (b->nchannels() == _route->n_outputs().get (b->type ())) {
-
- MenuList& citems = output_menu.items();
- citems.push_back (CheckMenuElem (b->name(), bind (mem_fun(*this, &MixerStrip::bundle_output_chosen), b)));
-
- if (std::find (current.begin(), current.end(), b) != current.end()) {
- ignore_toggle = true;
- dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
- ignore_toggle = false;
- }
+ MenuList& citems = output_menu.items();
+
+ std::string n = b->name ();
+ replace_all (n, "_", " ");
+
+ citems.push_back (CheckMenuElem (n, bind (mem_fun(*this, &MixerStrip::bundle_output_toggled), b)));
+
+ if (std::find (current.begin(), current.end(), b) != current.end()) {
+ ignore_toggle = true;
+ dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
+ ignore_toggle = false;
}
}
void
MixerStrip::update_input_display ()
{
- ARDOUR::BundleList c = _route->bundles_connected_to_inputs ();
+ ARDOUR::BundleList const c = _route->bundles_connected_to_inputs ();
- /* XXX: how do we represent >1 connected bundle? */
- if (c.empty() == false) {
- input_label.set_text (c[0]->name());
+ if (c.size() > 1) {
+ input_label.set_text (_("Inputs"));
+ } else if (c.size() == 1) {
+ input_label.set_text (c[0]->name ());
} else {
switch (_width) {
case Wide:
void
MixerStrip::update_output_display ()
{
- ARDOUR::BundleList c = _route->bundles_connected_to_outputs ();
+ ARDOUR::BundleList const c = _route->bundles_connected_to_outputs ();
/* XXX: how do we represent >1 connected bundle? */
- if (c.empty() == false) {
+ if (c.size() > 1) {
+ output_label.set_text (_("Outputs"));
+ } else if (c.size() == 1) {
output_label.set_text (c[0]->name());
} else {
switch (_width) {