mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 23:05:04 +01:00
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
4 changed files with 28 additions and 10 deletions
|
|
@ -112,6 +112,17 @@ BundleEditorMatrix::can_add_channels (boost::shared_ptr<Bundle> b) const
|
||||||
return PortMatrix::can_add_channels (b);
|
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
|
void
|
||||||
BundleEditorMatrix::add_channel (boost::shared_ptr<Bundle> b, DataType t)
|
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
|
bool
|
||||||
BundleEditorMatrix::can_remove_channels (boost::shared_ptr<Bundle> b) const
|
BundleEditorMatrix::can_remove_channels (boost::shared_ptr<Bundle> b) const
|
||||||
{
|
{
|
||||||
if (b == _bundle) {
|
if (b != _bundle) {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
return _bundle->n_total () > 1;
|
||||||
return PortMatrix::can_remove_channels (b);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ public:
|
||||||
PortMatrixNode::State get_state (ARDOUR::BundleChannel c[2]) const;
|
PortMatrixNode::State get_state (ARDOUR::BundleChannel c[2]) const;
|
||||||
|
|
||||||
bool can_add_channels (boost::shared_ptr<ARDOUR::Bundle>) 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);
|
void add_channel (boost::shared_ptr<ARDOUR::Bundle>, ARDOUR::DataType);
|
||||||
bool can_remove_channels (boost::shared_ptr<ARDOUR::Bundle>) const;
|
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)) {
|
if (can_add_channels (bc[dim].bundle)) {
|
||||||
/* Start off with options for the `natural' port type */
|
/* Start off with options for the `natural' port type */
|
||||||
for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
|
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());
|
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)));
|
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 */
|
/* Now add other ones */
|
||||||
for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
|
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());
|
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)));
|
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;
|
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
|
void
|
||||||
PortMatrix::add_channel (boost::shared_ptr<Bundle> b, DataType t)
|
PortMatrix::add_channel (boost::shared_ptr<Bundle> b, DataType t)
|
||||||
{
|
{
|
||||||
|
|
@ -805,14 +812,13 @@ PortMatrix::remove_all_channels (boost::weak_ptr<Bundle> w)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
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 ();
|
boost::shared_ptr<Bundle> b = w.lock ();
|
||||||
if (!b) {
|
if (!b) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
boost::shared_ptr<IO> io = io_from_bundle (b);
|
return can_add_port (b, t);
|
||||||
return io && io->can_add_port (t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -153,6 +153,7 @@ public:
|
||||||
virtual bool can_rename_channels (boost::shared_ptr<ARDOUR::Bundle>) const {
|
virtual bool can_rename_channels (boost::shared_ptr<ARDOUR::Bundle>) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
virtual bool can_add_port (boost::shared_ptr<ARDOUR::Bundle>, ARDOUR::DataType t) const;
|
||||||
virtual void rename_channel (ARDOUR::BundleChannel) {}
|
virtual void rename_channel (ARDOUR::BundleChannel) {}
|
||||||
virtual std::string disassociation_verb () const = 0;
|
virtual std::string disassociation_verb () const = 0;
|
||||||
virtual std::string channel_noun () const;
|
virtual std::string channel_noun () const;
|
||||||
|
|
@ -183,7 +184,7 @@ private:
|
||||||
void routes_changed ();
|
void routes_changed ();
|
||||||
void reconnect_to_routes ();
|
void reconnect_to_routes ();
|
||||||
void select_arrangement ();
|
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 add_channel_proxy (boost::weak_ptr<ARDOUR::Bundle>, ARDOUR::DataType);
|
||||||
void remove_channel_proxy (boost::weak_ptr<ARDOUR::Bundle>, uint32_t);
|
void remove_channel_proxy (boost::weak_ptr<ARDOUR::Bundle>, uint32_t);
|
||||||
void rename_channel_proxy (boost::weak_ptr<ARDOUR::Bundle>, uint32_t);
|
void rename_channel_proxy (boost::weak_ptr<ARDOUR::Bundle>, uint32_t);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue