UserBundle: Allow adding/removing ports
Clean up internal API confusion - can_add_channels_proxy () -- checks presence of io - can_add_channel_proxy () -- checks io->can_add_port() UserBundle don't have a PortGroup::_bundle reference that can be used to lookup the IO via io_from_bundle(). While BundleEditorMatrix::can_add_channels_proxy() was overriden to allow adding I/Os, can_add_channel_proxy() later prevented that. This further prevents removing the last port, preventing empty bundles.
This commit is contained in:
parent
017b272864
commit
4716f34c28
|
@ -112,6 +112,17 @@ BundleEditorMatrix::can_add_channels (boost::shared_ptr<Bundle> b) const
|
|||
return PortMatrix::can_add_channels (b);
|
||||
}
|
||||
|
||||
bool
|
||||
BundleEditorMatrix::can_add_port (boost::shared_ptr<Bundle> b, DataType t) const
|
||||
{
|
||||
#if 1
|
||||
return true; // anything goes
|
||||
#else
|
||||
/* Do not allow to mix datatypes */
|
||||
return _bundle->nchannels().get (t) > 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BundleEditorMatrix::add_channel (boost::shared_ptr<Bundle> b, DataType t)
|
||||
{
|
||||
|
@ -136,11 +147,10 @@ BundleEditorMatrix::add_channel (boost::shared_ptr<Bundle> b, DataType t)
|
|||
bool
|
||||
BundleEditorMatrix::can_remove_channels (boost::shared_ptr<Bundle> b) const
|
||||
{
|
||||
if (b == _bundle) {
|
||||
return true;
|
||||
if (b != _bundle) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return PortMatrix::can_remove_channels (b);
|
||||
return _bundle->n_total () > 1;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -44,6 +44,7 @@ public:
|
|||
PortMatrixNode::State get_state (ARDOUR::BundleChannel c[2]) const;
|
||||
|
||||
bool can_add_channels (boost::shared_ptr<ARDOUR::Bundle>) const;
|
||||
bool can_add_port (boost::shared_ptr<ARDOUR::Bundle>, ARDOUR::DataType t) const;
|
||||
|
||||
void add_channel (boost::shared_ptr<ARDOUR::Bundle>, ARDOUR::DataType);
|
||||
bool can_remove_channels (boost::shared_ptr<ARDOUR::Bundle>) const;
|
||||
|
|
|
@ -460,7 +460,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) && can_add_channel_proxy (w, *i)) {
|
||||
if (should_show (*i) && can_add_port_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)));
|
||||
}
|
||||
|
@ -468,7 +468,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) && can_add_channel_proxy (w, *i)) {
|
||||
if (!should_show (*i) && can_add_port_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)));
|
||||
}
|
||||
|
@ -735,6 +735,13 @@ PortMatrix::can_add_channels (boost::shared_ptr<Bundle> b) const
|
|||
return io_from_bundle (b) != 0;
|
||||
}
|
||||
|
||||
bool
|
||||
PortMatrix::can_add_port (boost::shared_ptr<Bundle> b, DataType t) const
|
||||
{
|
||||
boost::shared_ptr<IO> io = io_from_bundle (b);
|
||||
return io && io->can_add_port (t);
|
||||
}
|
||||
|
||||
void
|
||||
PortMatrix::add_channel (boost::shared_ptr<Bundle> b, DataType t)
|
||||
{
|
||||
|
@ -805,14 +812,13 @@ PortMatrix::remove_all_channels (boost::weak_ptr<Bundle> w)
|
|||
}
|
||||
|
||||
bool
|
||||
PortMatrix::can_add_channel_proxy (boost::weak_ptr<Bundle> w, DataType t) const
|
||||
PortMatrix::can_add_port_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 && io->can_add_port (t);
|
||||
return can_add_port (b, t);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -153,6 +153,7 @@ public:
|
|||
virtual bool can_rename_channels (boost::shared_ptr<ARDOUR::Bundle>) const {
|
||||
return false;
|
||||
}
|
||||
virtual bool can_add_port (boost::shared_ptr<ARDOUR::Bundle>, ARDOUR::DataType t) const;
|
||||
virtual void rename_channel (ARDOUR::BundleChannel) {}
|
||||
virtual std::string disassociation_verb () const = 0;
|
||||
virtual std::string channel_noun () const;
|
||||
|
@ -183,7 +184,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;
|
||||
bool can_add_port_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);
|
||||
|
|
Loading…
Reference in New Issue