summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2009-11-07 20:33:41 +0000
committerCarl Hetherington <carl@carlh.net>2009-11-07 20:33:41 +0000
commit660fd702af13ace2d0399e47d5e9a644a6e3a8d7 (patch)
tree3b3204fa23c82b246485e70d3e77001427edb6e7
parent040869db5c5681ee1b89fb1893fbb076d5216d42 (diff)
Various tweaks to the bundle manager.
git-svn-id: svn://localhost/ardour2/branches/3.0@6030 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/bundle_manager.cc47
-rw-r--r--gtk2_ardour/bundle_manager.h3
-rw-r--r--gtk2_ardour/port_group.cc27
-rw-r--r--gtk2_ardour/port_group.h3
-rw-r--r--gtk2_ardour/port_matrix.cc13
-rw-r--r--gtk2_ardour/port_matrix.h1
-rw-r--r--libs/ardour/ardour/bundle.h21
-rw-r--r--libs/ardour/bundle.cc34
8 files changed, 108 insertions, 41 deletions
diff --git a/gtk2_ardour/bundle_manager.cc b/gtk2_ardour/bundle_manager.cc
index ff7cec2633..c5981f0552 100644
--- a/gtk2_ardour/bundle_manager.cc
+++ b/gtk2_ardour/bundle_manager.cc
@@ -75,6 +75,10 @@ PortMatrixNode::State
BundleEditorMatrix::get_state (BundleChannel c[2]) const
{
Bundle::PortList const& pl = c[OTHER].bundle->channel_ports (c[OTHER].channel);
+ if (pl.empty ()) {
+ return PortMatrixNode::NOT_ASSOCIATED;
+ }
+
for (Bundle::PortList::const_iterator i = pl.begin(); i != pl.end(); ++i) {
if (!c[OURS].bundle->port_attached_to_channel (c[OURS].channel, *i)) {
return PortMatrixNode::NOT_ASSOCIATED;
@@ -162,7 +166,7 @@ BundleEditorMatrix::list_is_global (int dim) const
return (dim == OTHER);
}
-BundleEditor::BundleEditor (Session& session, boost::shared_ptr<UserBundle> bundle, bool add)
+BundleEditor::BundleEditor (Session& session, boost::shared_ptr<UserBundle> bundle)
: ArdourDialog (_("Edit Bundle")), _matrix (this, session, bundle), _bundle (bundle)
{
Gtk::Table* t = new Gtk::Table (3, 2);
@@ -220,13 +224,7 @@ BundleEditor::BundleEditor (Session& session, boost::shared_ptr<UserBundle> bund
get_vbox()->pack_start (_matrix);
get_vbox()->set_spacing (4);
- add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
- if (add) {
- add_button (Gtk::Stock::ADD, Gtk::RESPONSE_ACCEPT);
- } else {
- add_button (Gtk::Stock::APPLY, Gtk::RESPONSE_ACCEPT);
- }
-
+ add_button (Gtk::Stock::CLOSE, Gtk::RESPONSE_ACCEPT);
show_all ();
}
@@ -320,6 +318,10 @@ BundleManager::BundleManager (Session& session)
sigc::mem_fun (*this, &BundleManager::set_button_sensitivity)
);
+ _tree_view.signal_row_activated().connect (
+ sigc::mem_fun (*this, &BundleManager::row_activated)
+ );
+
set_button_sensitivity ();
show_all ();
@@ -342,12 +344,11 @@ BundleManager::new_clicked ()
/* Start off with a single channel */
b->add_channel ("1");
- BundleEditor e (_session, b, true);
+ _session.add_bundle (b);
+ add_bundle (b);
- if (e.run () == Gtk::RESPONSE_ACCEPT) {
- _session.add_bundle (b);
- add_bundle (b);
- }
+ BundleEditor e (_session, b);
+ e.run ();
}
void
@@ -356,10 +357,8 @@ BundleManager::edit_clicked ()
Gtk::TreeModel::iterator i = _tree_view.get_selection()->get_selected();
if (i) {
boost::shared_ptr<UserBundle> b = (*i)[_list_model_columns.bundle];
- BundleEditor e (_session, b, false);
- if (e.run () == Gtk::RESPONSE_ACCEPT) {
- _session.set_dirty ();
- }
+ BundleEditor e (_session, b);
+ e.run ();
}
}
@@ -410,6 +409,19 @@ BundleManager::bundle_changed (Bundle::Change c, boost::shared_ptr<UserBundle> b
}
}
+void
+BundleManager::row_activated (Gtk::TreeModel::Path const & p, Gtk::TreeViewColumn* c)
+{
+ Gtk::TreeModel::iterator i = _list_model->get_iter (p);
+ if (!i) {
+ return;
+ }
+
+ boost::shared_ptr<UserBundle> b = (*i)[_list_model_columns.bundle];
+ BundleEditor e (_session, b);
+ e.run ();
+}
+
NameChannelDialog::NameChannelDialog ()
: ArdourDialog (_("Add channel")),
_adding (true)
@@ -435,6 +447,7 @@ NameChannelDialog::setup ()
box->pack_start (*Gtk::manage (new Gtk::Label (_("Name"))));
box->pack_start (_name);
+ _name.set_activates_default (true);
get_vbox ()->pack_end (*box);
box->show_all ();
diff --git a/gtk2_ardour/bundle_manager.h b/gtk2_ardour/bundle_manager.h
index b9709c73ee..94078a14af 100644
--- a/gtk2_ardour/bundle_manager.h
+++ b/gtk2_ardour/bundle_manager.h
@@ -67,7 +67,7 @@ class BundleEditorMatrix : public PortMatrix
class BundleEditor : public ArdourDialog
{
public:
- BundleEditor (ARDOUR::Session &, boost::shared_ptr<ARDOUR::UserBundle>, bool);
+ BundleEditor (ARDOUR::Session &, boost::shared_ptr<ARDOUR::UserBundle>);
protected:
void on_map ();
@@ -98,6 +98,7 @@ class BundleManager : public ArdourDialog
void add_bundle (boost::shared_ptr<ARDOUR::Bundle>);
void bundle_changed (ARDOUR::Bundle::Change, boost::shared_ptr<ARDOUR::UserBundle>);
void set_button_sensitivity ();
+ void row_activated (Gtk::TreeModel::Path const & p, Gtk::TreeViewColumn* c);
class ModelColumns : public Gtk::TreeModelColumnRecord
{
diff --git a/gtk2_ardour/port_group.cc b/gtk2_ardour/port_group.cc
index 1537ea88ee..240e03eb0f 100644
--- a/gtk2_ardour/port_group.cc
+++ b/gtk2_ardour/port_group.cc
@@ -184,7 +184,7 @@ PortGroup::io_from_bundle (boost::shared_ptr<ARDOUR::Bundle> b) const
/** PortGroupList constructor.
*/
PortGroupList::PortGroupList ()
- : _type (DataType::AUDIO), _signals_suspended (false), _pending_change (false)
+ : _type (DataType::AUDIO), _signals_suspended (false), _pending_change (false), _pending_bundle_change ((Bundle::Change) 0)
{
}
@@ -281,17 +281,12 @@ PortGroupList::gather (ARDOUR::Session& session, bool inputs)
}
}
- /* Bundles owned by the session. We only add the mono ones and the User ones
- otherwise there is duplication of the same ports within the matrix */
+ /* Bundles owned by the session */
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 ((*i)->nchannels() == 1 || boost::dynamic_pointer_cast<UserBundle> (*i)) {
- system->add_bundle (*i);
- }
-
+ system->add_bundle (*i);
}
}
@@ -474,7 +469,7 @@ PortGroupList::add_group (boost::shared_ptr<PortGroup> g)
g->Changed.connect (sigc::mem_fun (*this, &PortGroupList::emit_changed));
_bundle_changed_connections.push_back (
- g->BundleChanged.connect (sigc::hide (sigc::mem_fun (*this, &PortGroupList::emit_changed)))
+ g->BundleChanged.connect (sigc::mem_fun (*this, &PortGroupList::emit_bundle_changed))
);
emit_changed ();
@@ -501,6 +496,15 @@ PortGroupList::emit_changed ()
}
void
+PortGroupList::emit_bundle_changed (Bundle::Change c)
+{
+ if (_signals_suspended) {
+ _pending_bundle_change = c;
+ } else {
+ BundleChanged (c);
+ }
+}
+void
PortGroupList::suspend_signals ()
{
_signals_suspended = true;
@@ -514,6 +518,11 @@ PortGroupList::resume_signals ()
_pending_change = false;
}
+ if (_pending_bundle_change != 0) {
+ BundleChanged (_pending_bundle_change);
+ _pending_bundle_change = (ARDOUR::Bundle::Change) 0;
+ }
+
_signals_suspended = false;
}
diff --git a/gtk2_ardour/port_group.h b/gtk2_ardour/port_group.h
index cf6fba8e53..456b801201 100644
--- a/gtk2_ardour/port_group.h
+++ b/gtk2_ardour/port_group.h
@@ -127,12 +127,14 @@ class PortGroupList : public sigc::trackable
}
sigc::signal<void> Changed;
+ sigc::signal<void, ARDOUR::Bundle::Change> BundleChanged;
private:
bool port_has_prefix (std::string const &, std::string const &) const;
std::string common_prefix (std::vector<std::string> const &) const;
std::string common_prefix_before (std::vector<std::string> const &, std::string const &) const;
void emit_changed ();
+ void emit_bundle_changed (ARDOUR::Bundle::Change);
boost::shared_ptr<ARDOUR::Bundle> make_bundle_from_ports (std::vector<std::string> const &, bool) const;
void maybe_add_processor_to_bundle (boost::weak_ptr<ARDOUR::Processor>, boost::shared_ptr<RouteBundle>, bool, std::set<boost::shared_ptr<ARDOUR::IO> > &);
@@ -142,6 +144,7 @@ class PortGroupList : public sigc::trackable
std::vector<sigc::connection> _bundle_changed_connections;
bool _signals_suspended;
bool _pending_change;
+ ARDOUR::Bundle::Change _pending_bundle_change;
};
diff --git a/gtk2_ardour/port_matrix.cc b/gtk2_ardour/port_matrix.cc
index b8fe7d3333..0b87ee2ee1 100644
--- a/gtk2_ardour/port_matrix.cc
+++ b/gtk2_ardour/port_matrix.cc
@@ -65,6 +65,9 @@ PortMatrix::PortMatrix (Window* parent, Session& session, DataType type)
/* watch for the content of _ports[] changing */
_ports[i].Changed.connect (mem_fun (*this, &PortMatrix::setup));
+
+ /* and for bundles in _ports[] changing */
+ _ports[i].BundleChanged.connect (mem_fun (*this, &PortMatrix::bundle_changed));
}
_hscroll.signal_value_changed().connect (mem_fun (*this, &PortMatrix::hscroll_changed));
@@ -587,3 +590,13 @@ PortMatrix::add_channel_proxy (boost::weak_ptr<Bundle> w)
add_channel (b);
}
+
+void
+PortMatrix::bundle_changed (ARDOUR::Bundle::Change c)
+{
+ if (c & (Bundle::DirectionChanged | Bundle::TypeChanged)) {
+ setup_all_ports ();
+ }
+
+ setup ();
+}
diff --git a/gtk2_ardour/port_matrix.h b/gtk2_ardour/port_matrix.h
index a4366897c6..0dc88f02f2 100644
--- a/gtk2_ardour/port_matrix.h
+++ b/gtk2_ardour/port_matrix.h
@@ -169,6 +169,7 @@ private:
void toggle_show_only_bundles ();
bool on_scroll_event (GdkEventScroll *);
boost::shared_ptr<ARDOUR::IO> io_from_bundle (boost::shared_ptr<ARDOUR::Bundle>) const;
+ void bundle_changed (ARDOUR::Bundle::Change);
Gtk::Window* _parent;
diff --git a/libs/ardour/ardour/bundle.h b/libs/ardour/ardour/bundle.h
index 0e80c5433d..0c7d6a5978 100644
--- a/libs/ardour/ardour/bundle.h
+++ b/libs/ardour/ardour/bundle.h
@@ -90,27 +90,18 @@ class Bundle : public sigc::trackable
void disconnect (boost::shared_ptr<Bundle>, AudioEngine &);
bool connected_to (boost::shared_ptr<Bundle>, AudioEngine &);
- /** Set the name.
- * @param n New name.
- */
- void set_name (std::string const & n) {
- _name = n;
- Changed (NameChanged);
- }
+ void set_name (std::string const &);
/** @return Bundle name */
std::string name () const { return _name; }
- /** Set the type of the ports in this Bundle.
- * @param t New type.
- */
- void set_type (DataType t) { _type = t; }
+ void set_type (DataType);
/** @return Type of the ports in this Bundle. */
DataType type () const { return _type; }
- void set_ports_are_inputs () { _ports_are_inputs = true; }
- void set_ports_are_outputs () { _ports_are_inputs = false; }
+ void set_ports_are_inputs ();
+ void set_ports_are_outputs ();
bool ports_are_inputs () const { return _ports_are_inputs; }
bool ports_are_outputs () const { return !_ports_are_inputs; }
@@ -121,7 +112,9 @@ class Bundle : public sigc::trackable
enum Change {
NameChanged = 0x1, ///< the bundle name or a channel name has changed
ConfigurationChanged = 0x2, ///< the number of channels has changed
- PortsChanged = 0x4 ///< the port list associated with one of our channels has changed
+ PortsChanged = 0x4, ///< the port list associated with one of our channels has changed
+ TypeChanged = 0x8, ///< the data type has changed
+ DirectionChanged = 0x10 ///< the direction (whether ports are inputs or outputs) has changed
};
sigc::signal<void, Change> Changed;
diff --git a/libs/ardour/bundle.cc b/libs/ardour/bundle.cc
index cd416c6a67..4f2198fd41 100644
--- a/libs/ardour/bundle.cc
+++ b/libs/ardour/bundle.cc
@@ -432,3 +432,37 @@ Bundle::connected_to (boost::shared_ptr<Bundle> other, AudioEngine & engine)
return true;
}
+
+/** Set the type of the ports in this Bundle.
+ * @param t New type.
+ */
+void
+Bundle::set_type (DataType t)
+{
+ _type = t;
+ emit_changed (TypeChanged);
+}
+
+void
+Bundle::set_ports_are_inputs ()
+{
+ _ports_are_inputs = true;
+ emit_changed (DirectionChanged);
+}
+
+void
+Bundle::set_ports_are_outputs ()
+{
+ _ports_are_inputs = false;
+ emit_changed (DirectionChanged);
+}
+
+/** Set the name.
+ * @param n New name.
+ */
+void
+Bundle::set_name (string const & n)
+{
+ _name = n;
+ emit_changed (NameChanged);
+}