Various tweaks to the bundle manager.
authorCarl Hetherington <carl@carlh.net>
Sat, 7 Nov 2009 20:33:41 +0000 (20:33 +0000)
committerCarl Hetherington <carl@carlh.net>
Sat, 7 Nov 2009 20:33:41 +0000 (20:33 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@6030 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/bundle_manager.cc
gtk2_ardour/bundle_manager.h
gtk2_ardour/port_group.cc
gtk2_ardour/port_group.h
gtk2_ardour/port_matrix.cc
gtk2_ardour/port_matrix.h
libs/ardour/ardour/bundle.h
libs/ardour/bundle.cc

index ff7cec26338000783bab9e7b5d2033e55643be2e..c5981f055214ef26f3ffcc567480fa208ed6aa1c 100644 (file)
@@ -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);
 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;
        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);
 }
 
        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);
        : 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);
 
        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 ();
 }
 
        show_all ();
 }
 
@@ -320,6 +318,10 @@ BundleManager::BundleManager (Session& session)
                sigc::mem_fun (*this, &BundleManager::set_button_sensitivity)
                );
 
                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 ();
        set_button_sensitivity ();
 
        show_all ();
@@ -342,12 +344,11 @@ BundleManager::new_clicked ()
        /* Start off with a single channel */
        b->add_channel ("1");
 
        /* 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
 }
 
 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];
        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)
 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);
 
        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 ();
 
        get_vbox ()->pack_end (*box);
        box->show_all ();
index b9709c73ee4e765f89e7e117e4e061ec4afcc3a5..94078a14af271123f68ae5053eb7f9d47f097e79 100644 (file)
@@ -67,7 +67,7 @@ class BundleEditorMatrix : public PortMatrix
 class BundleEditor : public ArdourDialog
 {
   public:
 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 ();
 
   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 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
        {
 
        class ModelColumns : public Gtk::TreeModelColumnRecord
        {
index 1537ea88ee824a11e6353be12d43937ec6b19328..240e03eb0fac13aa2393c846a88455c0983108ad 100644 (file)
@@ -184,7 +184,7 @@ PortGroup::io_from_bundle (boost::shared_ptr<ARDOUR::Bundle> b) const
 /** PortGroupList constructor.
  */
 PortGroupList::PortGroupList ()
 /** 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) {
 
        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->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 ();
                );
 
        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 ()
 {
 void
 PortGroupList::suspend_signals ()
 {
@@ -514,6 +518,11 @@ PortGroupList::resume_signals ()
                _pending_change = false;
        }
 
                _pending_change = false;
        }
 
+       if (_pending_bundle_change != 0) {
+               BundleChanged (_pending_bundle_change);
+               _pending_bundle_change = (ARDOUR::Bundle::Change) 0;
+       }
+
        _signals_suspended = false;
 }
 
        _signals_suspended = false;
 }
 
index cf6fba8e5301b5cf9d4cfede34c2bdce6d2268f4..456b801201b4a9b42422e1fae152c55e44362507 100644 (file)
@@ -127,12 +127,14 @@ class PortGroupList : public sigc::trackable
        }
 
        sigc::signal<void> Changed;
        }
 
        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 ();
 
   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> > &);
 
        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;
        std::vector<sigc::connection> _bundle_changed_connections;
        bool _signals_suspended;
        bool _pending_change;
+       ARDOUR::Bundle::Change _pending_bundle_change;
 };
 
 
 };
 
 
index b8fe7d3333064ef7a049c188754d9c98eacba017..0b87ee2ee18ab0fc7c83547c68ebce952ad64c62 100644 (file)
@@ -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));
 
                /* 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));
        }
 
        _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);
 }
 
        add_channel (b);
 }
+
+void
+PortMatrix::bundle_changed (ARDOUR::Bundle::Change c)
+{
+       if (c & (Bundle::DirectionChanged | Bundle::TypeChanged)) {
+               setup_all_ports ();
+       }
+       
+       setup ();
+}
index a4366897c6793de696ad17fdad5492b69e72cad8..0dc88f02f2e19e6413177437291bf56f8b1484f6 100644 (file)
@@ -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 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;
 
 
        Gtk::Window* _parent;
 
index 0e80c5433d6c0beed7af95953ca2bfa5dc875abc..0c7d6a597899f4bd0b5e80dfcbeb6651826f683f 100644 (file)
@@ -90,27 +90,18 @@ class Bundle : public sigc::trackable
        void disconnect (boost::shared_ptr<Bundle>, AudioEngine &);
        bool connected_to (boost::shared_ptr<Bundle>, AudioEngine &);
 
        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; }
 
 
        /** @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; }
 
 
        /** @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; }
 
        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
        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;
        };
 
        sigc::signal<void, Change> Changed;
index cd416c6a6775ce3935a7cf2bb64365d635669df6..4f2198fd41c7500ae61df4695cc917cae2e77e3d 100644 (file)
@@ -432,3 +432,37 @@ Bundle::connected_to (boost::shared_ptr<Bundle> other, AudioEngine & engine)
 
        return true;
 }
 
        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);
+}