From 660fd702af13ace2d0399e47d5e9a644a6e3a8d7 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 7 Nov 2009 20:33:41 +0000 Subject: Various tweaks to the bundle manager. git-svn-id: svn://localhost/ardour2/branches/3.0@6030 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/bundle_manager.cc | 47 +++++++++++++++++++++++++++---------------- gtk2_ardour/bundle_manager.h | 3 ++- gtk2_ardour/port_group.cc | 27 ++++++++++++++++--------- gtk2_ardour/port_group.h | 3 +++ gtk2_ardour/port_matrix.cc | 13 ++++++++++++ gtk2_ardour/port_matrix.h | 1 + 6 files changed, 67 insertions(+), 27 deletions(-) (limited to 'gtk2_ardour') 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 bundle, bool add) +BundleEditor::BundleEditor (Session& session, boost::shared_ptr 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 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 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 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 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, bool); + BundleEditor (ARDOUR::Session &, boost::shared_ptr); protected: void on_map (); @@ -98,6 +98,7 @@ class BundleManager : public ArdourDialog void add_bundle (boost::shared_ptr); void bundle_changed (ARDOUR::Bundle::Change, boost::shared_ptr); 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 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 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 (*i)) { - system->add_bundle (*i); - } - + system->add_bundle (*i); } } @@ -474,7 +469,7 @@ PortGroupList::add_group (boost::shared_ptr 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 (); @@ -500,6 +495,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 () { @@ -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 Changed; + sigc::signal BundleChanged; private: bool port_has_prefix (std::string const &, std::string const &) const; std::string common_prefix (std::vector const &) const; std::string common_prefix_before (std::vector const &, std::string const &) const; void emit_changed (); + void emit_bundle_changed (ARDOUR::Bundle::Change); boost::shared_ptr make_bundle_from_ports (std::vector const &, bool) const; void maybe_add_processor_to_bundle (boost::weak_ptr, boost::shared_ptr, bool, std::set > &); @@ -142,6 +144,7 @@ class PortGroupList : public sigc::trackable std::vector _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 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 io_from_bundle (boost::shared_ptr) const; + void bundle_changed (ARDOUR::Bundle::Change); Gtk::Window* _parent; -- cgit v1.2.3