summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2019-07-11 22:58:27 +0200
committerRobin Gareus <robin@gareus.org>2019-07-11 22:58:27 +0200
commitdc131da53b2603189dc0fb00109b77178c971fc4 (patch)
tree90279a03a80824bbf2d8809322e5ef5befd6620b
parentc6740b7cb06591f68851a3821a6cbc2b095e5bd0 (diff)
Hide "Add MIDI Port" in the GUI if there is already one
-rw-r--r--gtk2_ardour/mixer_strip.cc23
-rw-r--r--gtk2_ardour/port_matrix.cc15
-rw-r--r--gtk2_ardour/port_matrix.h1
3 files changed, 33 insertions, 6 deletions
diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc
index 35801cbd0f..316430c7bc 100644
--- a/gtk2_ardour/mixer_strip.cc
+++ b/gtk2_ardour/mixer_strip.cc
@@ -934,10 +934,15 @@ MixerStrip::output_press (GdkEventButton *ev)
citems.pop_back ();
}
- if (!ARDOUR::Profile->get_mixbus()) {
- citems.push_back (SeparatorElem());
+ citems.push_back (SeparatorElem());
+ if (!ARDOUR::Profile->get_mixbus()) {
+ bool need_separator = false;
for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
+ if (!_route->output()->can_add_port (*i)) {
+ continue;
+ }
+ need_separator = true;
citems.push_back (
MenuElem (
string_compose (_("Add %1 port"), (*i).to_i18n_string()),
@@ -945,9 +950,11 @@ MixerStrip::output_press (GdkEventButton *ev)
)
);
}
+ if (need_separator) {
+ citems.push_back (SeparatorElem());
+ }
}
- citems.push_back (SeparatorElem());
citems.push_back (MenuElem (_("Routing Grid"), sigc::mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::edit_output_configuration)));
Gtkmm2ext::anchored_menu_popup(&output_menu, &output_button, "",
@@ -1040,7 +1047,13 @@ MixerStrip::input_press (GdkEventButton *ev)
}
citems.push_back (SeparatorElem());
+
+ bool need_separator = false;
for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
+ if (!_route->input()->can_add_port (*i)) {
+ continue;
+ }
+ need_separator = true;
citems.push_back (
MenuElem (
string_compose (_("Add %1 port"), (*i).to_i18n_string()),
@@ -1048,8 +1061,10 @@ MixerStrip::input_press (GdkEventButton *ev)
)
);
}
+ if (need_separator) {
+ citems.push_back (SeparatorElem());
+ }
- citems.push_back (SeparatorElem());
citems.push_back (MenuElem (_("Routing Grid"), sigc::mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::edit_input_configuration)));
Gtkmm2ext::anchored_menu_popup(&input_menu, &input_button, "",
diff --git a/gtk2_ardour/port_matrix.cc b/gtk2_ardour/port_matrix.cc
index 23e9acaf62..b5e7cb008d 100644
--- a/gtk2_ardour/port_matrix.cc
+++ b/gtk2_ardour/port_matrix.cc
@@ -446,7 +446,7 @@ PortMatrix::popup_menu (BundleChannel column, BundleChannel row, uint32_t t)
if (can_add_channels (bc[dim].bundle)) {
/* Start off with options for the `natural' port type */
for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
- if (should_show (*i)) {
+ if (should_show (*i) && can_add_channel_proxy (w, *i)) {
snprintf (buf, sizeof (buf), _("Add %s %s"), (*i).to_i18n_string(), channel_noun().c_str());
sub.push_back (MenuElem (buf, sigc::bind (sigc::mem_fun (*this, &PortMatrix::add_channel_proxy), w, *i)));
}
@@ -454,7 +454,7 @@ PortMatrix::popup_menu (BundleChannel column, BundleChannel row, uint32_t t)
/* Now add other ones */
for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
- if (!should_show (*i)) {
+ if (!should_show (*i) && can_add_channel_proxy (w, *i)) {
snprintf (buf, sizeof (buf), _("Add %s %s"), (*i).to_i18n_string(), channel_noun().c_str());
sub.push_back (MenuElem (buf, sigc::bind (sigc::mem_fun (*this, &PortMatrix::add_channel_proxy), w, *i)));
}
@@ -790,6 +790,17 @@ PortMatrix::remove_all_channels (boost::weak_ptr<Bundle> w)
}
}
+bool
+PortMatrix::can_add_channel_proxy (boost::weak_ptr<Bundle> w, DataType t) const
+{
+ boost::shared_ptr<Bundle> b = w.lock ();
+ if (!b) {
+ return false;
+ }
+ boost::shared_ptr<IO> io = io_from_bundle (b);
+ return io->can_add_port (t);
+}
+
void
PortMatrix::add_channel_proxy (boost::weak_ptr<Bundle> w, DataType t)
{
diff --git a/gtk2_ardour/port_matrix.h b/gtk2_ardour/port_matrix.h
index 09c334b5ef..5fc0bd221f 100644
--- a/gtk2_ardour/port_matrix.h
+++ b/gtk2_ardour/port_matrix.h
@@ -182,6 +182,7 @@ private:
void routes_changed ();
void reconnect_to_routes ();
void select_arrangement ();
+ bool can_add_channel_proxy (boost::weak_ptr<ARDOUR::Bundle>, ARDOUR::DataType) const;
void add_channel_proxy (boost::weak_ptr<ARDOUR::Bundle>, ARDOUR::DataType);
void remove_channel_proxy (boost::weak_ptr<ARDOUR::Bundle>, uint32_t);
void rename_channel_proxy (boost::weak_ptr<ARDOUR::Bundle>, uint32_t);