Use track colours in the port matrix.
authorCarl Hetherington <carl@carlh.net>
Fri, 17 Jul 2009 13:18:58 +0000 (13:18 +0000)
committerCarl Hetherington <carl@carlh.net>
Fri, 17 Jul 2009 13:18:58 +0000 (13:18 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@5367 d708f5d6-7413-0410-9779-e7cbd77b26cf

12 files changed:
gtk2_ardour/editor.cc
gtk2_ardour/editor.h
gtk2_ardour/port_group.cc
gtk2_ardour/port_group.h
gtk2_ardour/port_matrix.cc
gtk2_ardour/port_matrix_body.cc
gtk2_ardour/port_matrix_column_labels.cc
gtk2_ardour/port_matrix_column_labels.h
gtk2_ardour/port_matrix_grid.cc
gtk2_ardour/port_matrix_grid.h
gtk2_ardour/port_matrix_row_labels.cc
gtk2_ardour/public_editor.h

index da1385bbe7c5e4987dd63b4feb5d994ea5a6df50..fda0ebeacf729ec1eb0a2f2ad7fcdb0719d7df0a 100644 (file)
@@ -4863,19 +4863,31 @@ Editor::streamview_height_changed ()
        _summary->set_dirty ();
 }
 
+TimeAxisView*
+Editor::axis_view_from_route (Route* r) const
+{
+       TrackViewList::const_iterator j = track_views.begin ();
+       while (j != track_views.end()) {
+               RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*j);
+               if (rtv && rtv->route().get() == r) {
+                       return rtv;
+               }
+               ++j;
+       }
+
+       return 0;
+}
+
+
 TrackSelection
 Editor::axis_views_from_routes (list<Route*> r) const
 {
        TrackSelection t;
        
        for (list<Route*>::const_iterator i = r.begin(); i != r.end(); ++i) {
-               TrackViewList::const_iterator j = track_views.begin ();
-               while (j != track_views.end()) {
-                       RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*j);
-                       if (rtv && rtv->route().get() == *i) {
-                               t.push_back (rtv);
-                       }
-                       ++j;
+               TimeAxisView* tv = axis_view_from_route (*i);
+               if (tv) {
+                       t.push_back (tv);
                }
        }
 
index e1c06a6ebdc27cfa63d33024f902612cf6a023e9..b1478d39229b280752db425befcd494db2a3725d 100644 (file)
@@ -970,6 +970,7 @@ class Editor : public PublicEditor
        /* track views */
        TrackViewList track_views;
        std::pair<TimeAxisView*, ARDOUR::layer_t> trackview_by_y_position (double);
+       TimeAxisView* axis_view_from_route (ARDOUR::Route *) const;
        TrackSelection axis_views_from_routes (std::list<ARDOUR::Route *>) const;
 
        static Gdk::Cursor* cross_hair_cursor;
index 0aae51d2b926810b672786f6dd88a802aee8f10c..f64b1031efa4a49eace6838a4f446e49b5569525 100644 (file)
@@ -31,6 +31,8 @@
 
 #include "port_group.h"
 #include "port_matrix.h"
+#include "time_axis_view.h"
+#include "public_editor.h"
 
 #include "i18n.h"
 
@@ -54,11 +56,34 @@ void
 PortGroup::add_bundle (boost::shared_ptr<Bundle> b)
 {
        assert (b.get());
-       _bundles.push_back (b);
 
-       _bundle_changed_connections[b] = 
-               b->Changed.connect (sigc::mem_fun (*this, &PortGroup::bundle_changed));
-       
+       BundleRecord r;
+       r.bundle = b;
+       r.has_colour = false;
+       r.changed_connection = b->Changed.connect (sigc::mem_fun (*this, &PortGroup::bundle_changed));
+
+       _bundles.push_back (r);
+
+       Modified ();
+}
+
+/** Add a bundle to a group.
+ *  @param b Bundle.
+ *  @param c Colour to represent the group with.
+ */
+void
+PortGroup::add_bundle (boost::shared_ptr<Bundle> b, Gdk::Color c)
+{
+       assert (b.get());
+
+       BundleRecord r;
+       r.bundle = b;
+       r.colour = c;
+       r.has_colour = true;
+       r.changed_connection = b->Changed.connect (sigc::mem_fun (*this, &PortGroup::bundle_changed));
+
+       _bundles.push_back (r);
+
        Modified ();
 }
 
@@ -67,13 +92,17 @@ PortGroup::remove_bundle (boost::shared_ptr<Bundle> b)
 {
        assert (b.get());
 
-       BundleList::iterator i = std::find (_bundles.begin(), _bundles.end(), b);
+       BundleList::iterator i = _bundles.begin ();
+       while (i != _bundles.end() && i->bundle != b) {
+               ++i;
+       }
+
        if (i == _bundles.end()) {
                return;
        }
 
+       i->changed_connection.disconnect ();
        _bundles.erase (i);
-       _bundle_changed_connections[b].disconnect ();
        
        Modified ();
 }
@@ -88,16 +117,11 @@ PortGroup::bundle_changed (Bundle::Change c)
 void
 PortGroup::clear ()
 {
-       _bundles.clear ();
-
-       for (ConnectionList::iterator i = _bundle_changed_connections.begin(); i != _bundle_changed_connections.end(); ++i) {
-
-               i->second.disconnect ();
-
+       for (BundleList::iterator i = _bundles.begin(); i != _bundles.end(); ++i) {
+               i->changed_connection.disconnect ();
        }
-       
-       _bundle_changed_connections.clear ();
 
+       _bundles.clear ();
        Modified ();
 }
 
@@ -105,7 +129,7 @@ bool
 PortGroup::has_port (std::string const& p) const
 {
        for (BundleList::const_iterator i = _bundles.begin(); i != _bundles.end(); ++i) {
-               if ((*i)->offers_port_alone (p)) {
+               if (i->bundle->offers_port_alone (p)) {
                        return true;
                }
        }
@@ -117,7 +141,7 @@ boost::shared_ptr<Bundle>
 PortGroup::only_bundle ()
 {
        assert (_bundles.size() == 1);
-       return _bundles.front();
+       return _bundles.front().bundle;
 }
 
 
@@ -126,13 +150,12 @@ PortGroup::total_channels () const
 {
        uint32_t n = 0;
        for (BundleList::const_iterator i = _bundles.begin(); i != _bundles.end(); ++i) {
-               n += (*i)->nchannels ();
+               n += i->bundle->nchannels ();
        }
 
        return n;
 }
 
-       
 /** PortGroupList constructor.
  */
 PortGroupList::PortGroupList ()
@@ -173,7 +196,7 @@ PortGroupList::maybe_add_processor_to_bundle (boost::weak_ptr<Processor> wp, boo
 
 /** Gather bundles from around the system and put them in this PortGroupList */
 void
-PortGroupList::gather (Session& session, bool inputs)
+PortGroupList::gather (ARDOUR::Session& session, bool inputs)
 {
        clear ();
 
@@ -222,7 +245,13 @@ PortGroupList::gather (Session& session, bool inputs)
                } 
                        
                if (g) {
-                       g->add_bundle (rb);
+
+                       TimeAxisView* tv = PublicEditor::instance().axis_view_from_route (i->get());
+                       if (tv) {
+                               g->add_bundle (rb, tv->color ());
+                       } else {
+                               g->add_bundle (rb);
+                       }
                }
        }
 
@@ -246,7 +275,7 @@ PortGroupList::gather (Session& session, bool inputs)
        std::vector<std::string> extra_other;
 
        const char **ports = session.engine().get_ports ("", _type.to_jack_type(), inputs ? 
-                                                         JackPortIsInput : JackPortIsOutput);
+                                                        JackPortIsInput : JackPortIsOutput);
        if (ports) {
 
                int n = 0;
@@ -376,7 +405,7 @@ PortGroupList::clear ()
 }
 
 
-BundleList const &
+PortGroup::BundleList const &
 PortGroupList::bundles () const
 {
        _bundles.clear ();
index 5abe0c9bcd8871b50166deacdc427a43d27757a8..f3f84a23ad19d40f66557f25cd32ff7ae126cca4 100644 (file)
@@ -38,6 +38,7 @@ namespace ARDOUR {
 
 class PortMatrix;
 class RouteBundle;
+class PublicEditor;
 
 /** A list of bundles and ports, grouped by some aspect of their
  *  type e.g. busses, tracks, system.  Each group has 0 or more bundles
@@ -49,6 +50,7 @@ public:
        PortGroup (std::string const & n);
 
        void add_bundle (boost::shared_ptr<ARDOUR::Bundle>);
+       void add_bundle (boost::shared_ptr<ARDOUR::Bundle>, Gdk::Color);
        void remove_bundle (boost::shared_ptr<ARDOUR::Bundle>);
        boost::shared_ptr<ARDOUR::Bundle> only_bundle ();
        void clear ();
@@ -56,10 +58,6 @@ public:
 
        std::string name; ///< name for the group
 
-       ARDOUR::BundleList const & bundles () const {
-               return _bundles;
-       }
-       
        bool visible () const {
                return _visible;
        }
@@ -74,14 +72,23 @@ public:
        sigc::signal<void> Modified;
        sigc::signal<void, ARDOUR::Bundle::Change> BundleChanged;
 
+       struct BundleRecord {
+               boost::shared_ptr<ARDOUR::Bundle> bundle;
+               Gdk::Color colour;
+               bool has_colour;
+               sigc::connection changed_connection;
+       };
+
+       typedef std::list<BundleRecord> BundleList;
+
+       BundleList const & bundles () const {
+               return _bundles;
+       }
+       
 private:
        void bundle_changed (ARDOUR::Bundle::Change);
-       
-       ARDOUR::BundleList _bundles;
 
-       typedef std::map<boost::shared_ptr<ARDOUR::Bundle>, sigc::connection> ConnectionList;
-       ConnectionList _bundle_changed_connections;
-       
+       BundleList _bundles;
        bool _visible; ///< true if the group is visible in the UI
 };
 
@@ -96,7 +103,7 @@ class PortGroupList : public sigc::trackable
        void add_group (boost::shared_ptr<PortGroup>);
        void set_type (ARDOUR::DataType);
        void gather (ARDOUR::Session &, bool);
-       ARDOUR::BundleList const & bundles () const;
+       PortGroup::BundleList const & bundles () const;
        void clear ();
        void remove_bundle (boost::shared_ptr<ARDOUR::Bundle>);
        uint32_t total_visible_channels () const;
@@ -126,7 +133,7 @@ class PortGroupList : public sigc::trackable
        void maybe_add_processor_to_bundle (boost::weak_ptr<ARDOUR::Processor>, boost::shared_ptr<RouteBundle>, bool, std::set<boost::shared_ptr<ARDOUR::IO> > &);
 
        ARDOUR::DataType _type;
-       mutable ARDOUR::BundleList _bundles;
+       mutable PortGroup::BundleList _bundles;
        List _groups;
        std::vector<sigc::connection> _bundle_changed_connections;
        bool _signals_suspended;
index 79256df6e05a29d9198f96907cc150eb8a6e99a9..b2c43ad35aa77aef4f647411da4db009750ae2c0 100644 (file)
@@ -278,17 +278,17 @@ PortMatrix::setup_scrollbars ()
 void
 PortMatrix::disassociate_all ()
 {
-       ARDOUR::BundleList a = _ports[0].bundles ();
-       ARDOUR::BundleList b = _ports[1].bundles ();
+       PortGroup::BundleList a = _ports[0].bundles ();
+       PortGroup::BundleList b = _ports[1].bundles ();
 
-       for (ARDOUR::BundleList::iterator i = a.begin(); i != a.end(); ++i) {
-               for (uint32_t j = 0; j < (*i)->nchannels(); ++j) {
-                       for (ARDOUR::BundleList::iterator k = b.begin(); k != b.end(); ++k) {
-                               for (uint32_t l = 0; l < (*k)->nchannels(); ++l) {
+       for (PortGroup::BundleList::iterator i = a.begin(); i != a.end(); ++i) {
+               for (uint32_t j = 0; j < i->bundle->nchannels(); ++j) {
+                       for (PortGroup::BundleList::iterator k = b.begin(); k != b.end(); ++k) {
+                               for (uint32_t l = 0; l < k->bundle->nchannels(); ++l) {
                                                
                                        ARDOUR::BundleChannel c[2] = {
-                                               ARDOUR::BundleChannel (*i, j),
-                                               ARDOUR::BundleChannel (*k, l)
+                                               ARDOUR::BundleChannel (i->bundle, j),
+                                               ARDOUR::BundleChannel (k->bundle, l)
                                                        };
 
                                        if (get_state (c) == PortMatrixNode::ASSOCIATED) {
@@ -376,13 +376,13 @@ PortMatrix::popup_channel_context_menu (int dim, uint32_t N, uint32_t t)
 
        ARDOUR::BundleChannel bc;
 
-       ARDOUR::BundleList const r = _ports[dim].bundles();
-       for (ARDOUR::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) {
-               if (N < (*i)->nchannels ()) {
-                       bc = ARDOUR::BundleChannel (*i, N);
+       PortGroup::BundleList const r = _ports[dim].bundles();
+       for (PortGroup::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) {
+               if (N < i->bundle->nchannels ()) {
+                       bc = ARDOUR::BundleChannel (i->bundle, N);
                        break;
                } else {
-                       N -= (*i)->nchannels ();
+                       N -= i->bundle->nchannels ();
                }
        }
 
@@ -464,14 +464,14 @@ PortMatrix::disassociate_all_on_channel (boost::weak_ptr<ARDOUR::Bundle> bundle,
                return;
        }
 
-       ARDOUR::BundleList a = _ports[1-dim].bundles ();
+       PortGroup::BundleList a = _ports[1-dim].bundles ();
 
-       for (ARDOUR::BundleList::iterator i = a.begin(); i != a.end(); ++i) {
-               for (uint32_t j = 0; j < (*i)->nchannels(); ++j) {
+       for (PortGroup::BundleList::iterator i = a.begin(); i != a.end(); ++i) {
+               for (uint32_t j = 0; j < i->bundle->nchannels(); ++j) {
 
                        ARDOUR::BundleChannel c[2];
                        c[dim] = ARDOUR::BundleChannel (sb, channel);
-                       c[1-dim] = ARDOUR::BundleChannel (*i, j);
+                       c[1-dim] = ARDOUR::BundleChannel (i->bundle, j);
 
                        if (get_state (c) == PortMatrixNode::ASSOCIATED) {
                                set_state (c, false);
index 59444ba7ff61595e8abbe4dc500d68688053f186..2991c9937b5e458726397dc8357a9562115f350d 100644 (file)
@@ -278,19 +278,19 @@ PortMatrixBody::setup ()
 
        /* Connect to bundles so that we find out when their names change */
        
-       ARDOUR::BundleList r = _matrix->rows()->bundles ();
-       for (ARDOUR::BundleList::iterator i = r.begin(); i != r.end(); ++i) {
+       PortGroup::BundleList r = _matrix->rows()->bundles ();
+       for (PortGroup::BundleList::iterator i = r.begin(); i != r.end(); ++i) {
                
                _bundle_connections.push_back (
-                       (*i)->Changed.connect (sigc::hide (sigc::mem_fun (*this, &PortMatrixBody::rebuild_and_draw_row_labels)))
+                       i->bundle->Changed.connect (sigc::hide (sigc::mem_fun (*this, &PortMatrixBody::rebuild_and_draw_row_labels)))
                        );
                
        }
 
-       ARDOUR::BundleList c = _matrix->columns()->bundles ();
-       for (ARDOUR::BundleList::iterator i = c.begin(); i != c.end(); ++i) {
+       PortGroup::BundleList c = _matrix->columns()->bundles ();
+       for (PortGroup::BundleList::iterator i = c.begin(); i != c.end(); ++i) {
                _bundle_connections.push_back (
-                       (*i)->Changed.connect (sigc::hide (sigc::mem_fun (*this, &PortMatrixBody::rebuild_and_draw_column_labels)))
+                       i->bundle->Changed.connect (sigc::hide (sigc::mem_fun (*this, &PortMatrixBody::rebuild_and_draw_column_labels)))
                        );
        }
        
@@ -458,13 +458,13 @@ PortMatrixBody::highlight_associated_channels (int dim, uint32_t N)
 {
        ARDOUR::BundleChannel bc[2];
        
-       ARDOUR::BundleList const a = _matrix->ports(dim)->bundles ();
-       for (ARDOUR::BundleList::const_iterator i = a.begin(); i != a.end(); ++i) {
-               if (N < (*i)->nchannels ()) {
-                       bc[dim] = ARDOUR::BundleChannel (*i, N);
+       PortGroup::BundleList const a = _matrix->ports(dim)->bundles ();
+       for (PortGroup::BundleList::const_iterator i = a.begin(); i != a.end(); ++i) {
+               if (N < i->bundle->nchannels ()) {
+                       bc[dim] = ARDOUR::BundleChannel (i->bundle, N);
                        break;
                } else {
-                       N -= (*i)->nchannels ();
+                       N -= i->bundle->nchannels ();
                }
        }
 
@@ -478,11 +478,11 @@ PortMatrixBody::highlight_associated_channels (int dim, uint32_t N)
                _row_labels->add_channel_highlight (bc[dim]);
        }
 
-       ARDOUR::BundleList const b = _matrix->ports(1 - dim)->bundles ();
+       PortGroup::BundleList const b = _matrix->ports(1 - dim)->bundles ();
 
-       for (ARDOUR::BundleList::const_iterator i = b.begin(); i != b.end(); ++i) {
-               for (uint32_t j = 0; j < (*i)->nchannels(); ++j) {
-                       bc[1 - dim] = ARDOUR::BundleChannel (*i, j);
+       for (PortGroup::BundleList::const_iterator i = b.begin(); i != b.end(); ++i) {
+               for (uint32_t j = 0; j < i->bundle->nchannels(); ++j) {
+                       bc[1 - dim] = ARDOUR::BundleChannel (i->bundle, j);
                        if (_matrix->get_state (bc) == PortMatrixNode::ASSOCIATED) {
                                if (dim == _matrix->column_index()) {
                                        _row_labels->add_channel_highlight (bc[1 - dim]);
index a1ec3920887bf35923eef7b01c7b5eaa8a766203..e630dec4c08a15d475d4fd3ee8269d78017f521d 100644 (file)
@@ -25,6 +25,8 @@
 #include "port_matrix_body.h"
 #include "utils.h"
 
+using namespace std;
+
 PortMatrixColumnLabels::PortMatrixColumnLabels (PortMatrix* m, PortMatrixBody* b)
        : PortMatrixLabels (m, b)
 {
@@ -47,11 +49,11 @@ PortMatrixColumnLabels::compute_dimensions ()
        /* width of the whole thing */
        _width = 0;
 
-       ARDOUR::BundleList const c = _matrix->columns()->bundles();
-       for (ARDOUR::BundleList::const_iterator i = c.begin (); i != c.end(); ++i) {
+       PortGroup::BundleList const c = _matrix->columns()->bundles();
+       for (PortGroup::BundleList::const_iterator i = c.begin (); i != c.end(); ++i) {
 
                cairo_text_extents_t ext;
-               cairo_text_extents (cr, (*i)->name().c_str(), &ext);
+               cairo_text_extents (cr, i->bundle->name().c_str(), &ext);
                if (ext.width > _longest_bundle_name) {
                        _longest_bundle_name = ext.width;
                }
@@ -59,11 +61,11 @@ PortMatrixColumnLabels::compute_dimensions ()
                        _highest_text = ext.height;
                }
 
-               for (uint32_t j = 0; j < (*i)->nchannels (); ++j) {
+               for (uint32_t j = 0; j < i->bundle->nchannels (); ++j) {
                        
                        cairo_text_extents (
                                cr,
-                               (*i)->channel_name (j).c_str(),
+                               i->bundle->channel_name (j).c_str(),
                                &ext
                                );
                        
@@ -78,7 +80,7 @@ PortMatrixColumnLabels::compute_dimensions ()
                if (_matrix->show_only_bundles()) {
                        _width += column_width();
                } else {
-                       _width += (*i)->nchannels() * column_width();
+                       _width += i->bundle->nchannels() * column_width();
                }
        }
 
@@ -164,8 +166,8 @@ PortMatrixColumnLabels::render (cairo_t* cr)
                }
                cairo_fill (cr);
 
-               std::string const upper = Glib::ustring ((*i)->name).uppercase ();
-               std::pair<std::string, double> const display = fit_to_pixels (cr, upper, w);
+               string const upper = Glib::ustring ((*i)->name).uppercase ();
+               pair<string, double> const display = fit_to_pixels (cr, upper, w);
 
                /* plot it */
                set_source_rgb (cr, text_colour());
@@ -179,16 +181,20 @@ PortMatrixColumnLabels::render (cairo_t* cr)
         /* BUNDLE PARALLELOGRAM-TYPE-THING AND NAME */
 
        x = 0;
-       ARDOUR::BundleList const c = _matrix->columns()->bundles();
-       for (ARDOUR::BundleList::const_iterator i = c.begin (); i != c.end(); ++i) {
+       int N = 0;
+       PortGroup::BundleList const bundles = _matrix->columns()->bundles();
+       for (PortGroup::BundleList::const_iterator i = bundles.begin (); i != bundles.end(); ++i) {
 
-               render_bundle_name (cr, get_a_bundle_colour (i - c.begin ()), x, 0, *i);
+               Gdk::Color c = i->has_colour ? i->colour : get_a_bundle_colour (N);
+               render_bundle_name (cr, c, x, 0, i->bundle);
 
                if (_matrix->show_only_bundles()) {
                        x += column_width();
                } else {
-                       x += (*i)->nchannels () * column_width();
+                       x += i->bundle->nchannels () * column_width();
                }
+
+               ++N;
        }
        
 
@@ -196,13 +202,16 @@ PortMatrixColumnLabels::render (cairo_t* cr)
 
        if (!_matrix->show_only_bundles()) {
                x = 0;
-               for (ARDOUR::BundleList::const_iterator i = c.begin (); i != c.end(); ++i) {
+               N = 0;
+               for (PortGroup::BundleList::const_iterator i = bundles.begin (); i != bundles.end(); ++i) {
                        
-                       for (uint32_t j = 0; j < (*i)->nchannels(); ++j) {
-                               
-                               render_channel_name (cr, get_a_bundle_colour (i - c.begin()), x, 0, ARDOUR::BundleChannel (*i, j));
+                       for (uint32_t j = 0; j < i->bundle->nchannels(); ++j) {
+                               Gdk::Color c = i->has_colour ? i->colour : get_a_bundle_colour (N);
+                               render_channel_name (cr, c, x, 0, ARDOUR::BundleChannel (i->bundle, j));
                                x += column_width();
                        }
+
+                       ++N;
                }
        }
 }
@@ -240,10 +249,10 @@ PortMatrixColumnLabels::mouseover_changed (PortMatrixNode const &)
        }
 }
 
-std::vector<std::pair<double, double> >
+vector<pair<double, double> >
 PortMatrixColumnLabels::port_name_shape (double xoff, double yoff) const
 {
-       std::vector<std::pair<double, double> > shape;
+       vector<pair<double, double> > shape;
        
        double const lc = _longest_channel_name + name_pad();
        double const w = column_width();
@@ -252,29 +261,29 @@ PortMatrixColumnLabels::port_name_shape (double xoff, double yoff) const
 
                double x_ = xoff + slanted_height() / tan (angle()) + w;
                double y_ = yoff;
-               shape.push_back (std::make_pair (x_, y_));
+               shape.push_back (make_pair (x_, y_));
                x_ -= w;
-               shape.push_back (std::make_pair (x_, y_));
+               shape.push_back (make_pair (x_, y_));
                x_ -= lc * cos (angle());
                y_ += lc * sin (angle());
-               shape.push_back (std::make_pair (x_, y_));
+               shape.push_back (make_pair (x_, y_));
                x_ += w * pow (sin (angle()), 2);
                y_ += w * sin (angle()) * cos (angle());
-               shape.push_back (std::make_pair (x_, y_));
+               shape.push_back (make_pair (x_, y_));
                
        } else {
                
                double x_ = xoff;
                double y_ = yoff + _height;
-               shape.push_back (std::make_pair (x_, y_));
+               shape.push_back (make_pair (x_, y_));
                x_ += w;
-               shape.push_back (std::make_pair (x_, y_));
+               shape.push_back (make_pair (x_, y_));
                x_ += lc * cos (angle());
                y_ -= lc * sin (angle());
-               shape.push_back (std::make_pair (x_, y_));
+               shape.push_back (make_pair (x_, y_));
                x_ -= column_width() * pow (sin (angle()), 2);
                y_ -= column_width() * sin (angle()) * cos (angle());
-               shape.push_back (std::make_pair (x_, y_));
+               shape.push_back (make_pair (x_, y_));
        }
 
        return shape;
@@ -354,7 +363,7 @@ PortMatrixColumnLabels::render_channel_name (
        cairo_t* cr, Gdk::Color colour, double xoff, double yoff, ARDOUR::BundleChannel const &bc
        )
 {
-       std::vector<std::pair<double, double> > const shape = port_name_shape (xoff, yoff);
+       vector<pair<double, double> > const shape = port_name_shape (xoff, yoff);
 
        cairo_move_to (cr, shape[0].first, shape[0].second);
        for (uint32_t i = 1; i < 4; ++i) {
@@ -404,12 +413,12 @@ PortMatrixColumnLabels::channel_x (ARDOUR::BundleChannel const &bc) const
 {
        uint32_t n = 0;
 
-       ARDOUR::BundleList::const_iterator i = _matrix->columns()->bundles().begin();
-       while (i != _matrix->columns()->bundles().end() && *i != bc.bundle) {
+       PortGroup::BundleList::const_iterator i = _matrix->columns()->bundles().begin();
+       while (i != _matrix->columns()->bundles().end() && i->bundle != bc.bundle) {
                if (_matrix->show_only_bundles()) {
                        n += 1;
                } else {
-                       n += (*i)->nchannels ();
+                       n += i->bundle->nchannels ();
                }
                ++i;
        }
@@ -481,7 +490,7 @@ PortMatrixColumnLabels::button_press (double x, double y, int b, uint32_t t)
        uint32_t i = 0;
        for (; i < N; ++i) {
                
-               std::vector<std::pair<double, double> > const shape = port_name_shape (i * column_width(), 0);
+               vector<pair<double, double> > const shape = port_name_shape (i * column_width(), 0);
 
                uint32_t j = 0;
                for (; j < 4; ++j) {
index d4e06226b1f293fb62e89230f2be0c2dcfe487a6..f91a5be204025a45e80b04718cf9c2879bc0a786 100644 (file)
@@ -60,7 +60,7 @@ private:
                return _height - _highest_group_name - 2 * name_pad();
        }
 
-       std::vector<boost::shared_ptr<ARDOUR::Bundle> > _bundles;
+//     PortGroup::BundleList _bundles;
        double _longest_bundle_name;
        double _longest_channel_name;
        double _highest_text;
index 7c94beaeacc0ad69ba58bd85f1e08a48eb03e6dc..cb08abb46083c1fe62d62016c2d2618f6aad58d8 100644 (file)
@@ -35,22 +35,22 @@ void
 PortMatrixGrid::compute_dimensions ()
 {
        _width = 0;
-       ARDOUR::BundleList const c = _matrix->columns()->bundles();
+       PortGroup::BundleList const c = _matrix->columns()->bundles();
        if (_matrix->show_only_bundles()) {
                _width = c.size() * column_width();
        } else {
-               for (ARDOUR::BundleList::const_iterator i = c.begin(); i != c.end(); ++i) {
-                       _width += (*i)->nchannels() * column_width();
+               for (PortGroup::BundleList::const_iterator i = c.begin(); i != c.end(); ++i) {
+                       _width += i->bundle->nchannels() * column_width();
                }
        }
 
        _height = 0;
-       ARDOUR::BundleList const r = _matrix->rows()->bundles();
+       PortGroup::BundleList const r = _matrix->rows()->bundles();
        if (_matrix->show_only_bundles()) {
                _height = r.size() * column_width();
        } else {
-               for (ARDOUR::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) {
-                       _height += (*i)->nchannels() * row_height();
+               for (PortGroup::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) {
+                       _height += i->bundle->nchannels() * row_height();
                }
        }
 }
@@ -69,12 +69,13 @@ PortMatrixGrid::render (cairo_t* cr)
        
        set_source_rgb (cr, grid_colour());
        uint32_t x = 0;
-       ARDOUR::BundleList const c = _matrix->columns()->bundles();
-       for (ARDOUR::BundleList::size_type i = 0; i < c.size(); ++i) {
+       PortGroup::BundleList const c = _matrix->columns()->bundles();
+       uint32_t N = 0;
+       for (PortGroup::BundleList::const_iterator i = c.begin(); i != c.end(); ++i) {
 
                if (!_matrix->show_only_bundles()) {
                        cairo_set_line_width (cr, thin_grid_line_width());
-                       for (uint32_t j = 1; j < c[i]->nchannels(); ++j) {
+                       for (uint32_t j = 1; j < i->bundle->nchannels(); ++j) {
                                x += column_width();
                                cairo_move_to (cr, x, 0);
                                cairo_line_to (cr, x, _height);
@@ -82,13 +83,15 @@ PortMatrixGrid::render (cairo_t* cr)
                        }
                }
 
-               if (i < (c.size() - 1)) {
+               if (N < (c.size() - 1)) {
                        x += column_width();
                        cairo_set_line_width (cr, thick_grid_line_width());
                        cairo_move_to (cr, x, 0);
                        cairo_line_to (cr, x, _height);
                        cairo_stroke (cr);
                }
+
+               ++N;
         }
                
        uint32_t grid_width = x + column_width();
@@ -96,12 +99,13 @@ PortMatrixGrid::render (cairo_t* cr)
        /* HORIZONTAL GRID LINES */
        
        uint32_t y = 0;
-       ARDOUR::BundleList const r = _matrix->rows()->bundles();
-       for (ARDOUR::BundleList::size_type i = 0; i < r.size(); ++i) {
+       N = 0;
+       PortGroup::BundleList const r = _matrix->rows()->bundles();
+       for (PortGroup::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) {
 
                if (!_matrix->show_only_bundles()) {
                        cairo_set_line_width (cr, thin_grid_line_width());
-                       for (uint32_t j = 1; j < r[i]->nchannels(); ++j) {
+                       for (uint32_t j = 1; j < i->bundle->nchannels(); ++j) {
                                y += row_height();
                                cairo_move_to (cr, 0, y);
                                cairo_line_to (cr, grid_width, y);
@@ -109,13 +113,15 @@ PortMatrixGrid::render (cairo_t* cr)
                        }
                }
 
-               if (i < (r.size() - 1)) {
+               if (N < (r.size() - 1)) {
                        y += row_height();
                        cairo_set_line_width (cr, thick_grid_line_width());
                        cairo_move_to (cr, 0, y);
                        cairo_line_to (cr, grid_width, y);
                        cairo_stroke (cr);
                }
+
+               ++N;
        }
 
        /* ASSOCIATION INDICATORS */
@@ -125,12 +131,12 @@ PortMatrixGrid::render (cairo_t* cr)
 
        if (_matrix->show_only_bundles()) {
 
-               for (ARDOUR::BundleList::const_iterator i = c.begin(); i < c.end(); ++i) {
+               for (PortGroup::BundleList::const_iterator i = c.begin(); i != c.end(); ++i) {
                        by = 0;
                        
-                       for (ARDOUR::BundleList::const_iterator j = r.begin(); j < r.end(); ++j) {
+                       for (PortGroup::BundleList::const_iterator j = r.begin(); j != r.end(); ++j) {
 
-                               PortMatrixNode::State s = bundle_to_bundle_state (*i, *j);
+                               PortMatrixNode::State s = bundle_to_bundle_state (i->bundle, j->bundle);
                                switch (s) {
                                case PortMatrixNode::UNKNOWN:
                                        draw_unknown_indicator (cr, bx, by);
@@ -153,20 +159,20 @@ PortMatrixGrid::render (cairo_t* cr)
 
        } else {
 
-               for (ARDOUR::BundleList::const_iterator i = c.begin(); i < c.end(); ++i) {
+               for (PortGroup::BundleList::const_iterator i = c.begin(); i != c.end(); ++i) {
                        by = 0;
                        
-                       for (ARDOUR::BundleList::const_iterator j = r.begin(); j < r.end(); ++j) {
+                       for (PortGroup::BundleList::const_iterator j = r.begin(); j != r.end(); ++j) {
                                
                                x = bx;
-                               for (uint32_t k = 0; k < (*i)->nchannels (); ++k) {
+                               for (uint32_t k = 0; k < i->bundle->nchannels (); ++k) {
                                        
                                        y = by;
-                                       for (uint32_t l = 0; l < (*j)->nchannels (); ++l) {
+                                       for (uint32_t l = 0; l < j->bundle->nchannels (); ++l) {
                                                
                                                ARDOUR::BundleChannel c[2];
-                                               c[_matrix->column_index()] = ARDOUR::BundleChannel (*i, k);
-                                               c[_matrix->row_index()] = ARDOUR::BundleChannel (*j, l);
+                                               c[_matrix->column_index()] = ARDOUR::BundleChannel (i->bundle, k);
+                                               c[_matrix->row_index()] = ARDOUR::BundleChannel (j->bundle, l);
                                                
                                                PortMatrixNode::State const s = _matrix->get_state (c);
                                                
@@ -192,10 +198,10 @@ PortMatrixGrid::render (cairo_t* cr)
                                        x += column_width();
                                }
                                
-                               by += (*j)->nchannels () * row_height();
+                               by += j->bundle->nchannels () * row_height();
                        }
                        
-                       bx += (*i)->nchannels () * column_width();
+                       bx += i->bundle->nchannels () * column_width();
                }
        }
 }
@@ -241,15 +247,15 @@ PortMatrixGrid::position_to_node (double x, double y) const
 
 
 ARDOUR::BundleChannel
-PortMatrixGrid::position_to_channel (double p, ARDOUR::BundleList const& bundles, double inc) const
+PortMatrixGrid::position_to_channel (double p, PortGroup::BundleList const & bundles, double inc) const
 {
        uint32_t pos = p / inc;
 
        if (_matrix->show_only_bundles()) {
                
-               for (ARDOUR::BundleList::const_iterator i = bundles.begin(); i != bundles.end(); ++i) {
+               for (PortGroup::BundleList::const_iterator i = bundles.begin(); i != bundles.end(); ++i) {
                        if (pos == 0) {
-                               return ARDOUR::BundleChannel (*i, 0);
+                               return ARDOUR::BundleChannel (i->bundle, 0);
                        } else {
                                pos--;
                        }
@@ -257,11 +263,11 @@ PortMatrixGrid::position_to_channel (double p, ARDOUR::BundleList const& bundles
 
        } else {
 
-               for (ARDOUR::BundleList::const_iterator i = bundles.begin(); i != bundles.end(); ++i) {
-                       if (pos < (*i)->nchannels()) {
-                               return ARDOUR::BundleChannel (*i, pos);
+               for (PortGroup::BundleList::const_iterator i = bundles.begin(); i != bundles.end(); ++i) {
+                       if (pos < i->bundle->nchannels()) {
+                               return ARDOUR::BundleChannel (i->bundle, pos);
                        } else {
-                               pos -= (*i)->nchannels();
+                               pos -= i->bundle->nchannels();
                        }
                }
                
@@ -274,18 +280,18 @@ PortMatrixGrid::position_to_channel (double p, ARDOUR::BundleList const& bundles
 double
 PortMatrixGrid::channel_position (
        ARDOUR::BundleChannel bc,
-       ARDOUR::BundleList const& bundles,
+       PortGroup::BundleList const& bundles,
        double inc) const
 {
        double p = 0;
        
-       ARDOUR::BundleList::const_iterator i = bundles.begin ();
-       while (i != bundles.end() && *i != bc.bundle) {
+       PortGroup::BundleList::const_iterator i = bundles.begin ();
+       while (i != bundles.end() && i->bundle != bc.bundle) {
 
                if (_matrix->show_only_bundles()) {
                        p += inc;
                } else {
-                       p += inc * (*i)->nchannels();
+                       p += inc * i->bundle->nchannels();
                }
                
                ++i;
index 4a05c3138d813b703a692d0034b1f5b19224d1ce..5d2e528e603ed5c8f8b456ce8756ab0a40a7008b 100644 (file)
@@ -26,6 +26,7 @@
 #include "ardour/types.h"
 #include "port_matrix_component.h"
 #include "port_matrix_types.h"
+#include "port_group.h"
 
 class PortMatrix;
 class PortMatrixBody;
@@ -55,9 +56,9 @@ private:
        void compute_dimensions ();
        void render (cairo_t *);
 
-       double channel_position (ARDOUR::BundleChannel, ARDOUR::BundleList const &, double) const;
+       double channel_position (ARDOUR::BundleChannel, PortGroup::BundleList const &, double) const;
        PortMatrixNode position_to_node (double, double) const;
-       ARDOUR::BundleChannel position_to_channel (double, ARDOUR::BundleList const &, double) const;
+       ARDOUR::BundleChannel position_to_channel (double, PortGroup::BundleList const &, double) const;
        void queue_draw_for (PortMatrixNode const &);
        void draw_association_indicator (cairo_t *, uint32_t, uint32_t, double p = 1);
        void draw_unknown_indicator (cairo_t *, uint32_t, uint32_t);
index 799fb8c14f05ba5ffdce5a103328b9b898960cfe..ded591278ec2b3f472d62a9cae7cb2d3f0422d2f 100644 (file)
@@ -43,18 +43,18 @@ PortMatrixRowLabels::compute_dimensions ()
        _longest_port_name = 0;
        _longest_bundle_name = 0;
        _height = 0;
-       ARDOUR::BundleList const r = _matrix->rows()->bundles();
-       for (ARDOUR::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) {
-               for (uint32_t j = 0; j < (*i)->nchannels(); ++j) {
+       PortGroup::BundleList const r = _matrix->rows()->bundles();
+       for (PortGroup::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) {
+               for (uint32_t j = 0; j < i->bundle->nchannels(); ++j) {
                        cairo_text_extents_t ext;
-                       cairo_text_extents (cr, (*i)->channel_name(j).c_str(), &ext);
+                       cairo_text_extents (cr, i->bundle->channel_name(j).c_str(), &ext);
                        if (ext.width > _longest_port_name) {
                                _longest_port_name = ext.width;
                        }
                }
 
                cairo_text_extents_t ext;
-               cairo_text_extents (cr, (*i)->name().c_str(), &ext);
+               cairo_text_extents (cr, i->bundle->name().c_str(), &ext);
                if (ext.width > _longest_bundle_name) {
                        _longest_bundle_name = ext.width;
                }
@@ -62,7 +62,7 @@ PortMatrixRowLabels::compute_dimensions ()
                if (_matrix->show_only_bundles()) {
                        _height += row_height ();
                } else {
-                       _height += (*i)->nchannels() * row_height();
+                       _height += i->bundle->nchannels() * row_height();
                }
        }
 
@@ -150,11 +150,13 @@ PortMatrixRowLabels::render (cairo_t* cr)
        /* BUNDLE NAMES */
 
        y = 0;
-       ARDOUR::BundleList const r = _matrix->rows()->bundles();
-       for (ARDOUR::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) {
-               render_bundle_name (cr, get_a_bundle_colour (i - r.begin ()), 0, y, *i);
-               int const n = _matrix->show_only_bundles() ? 1 : (*i)->nchannels();
+       int N = 0;
+       PortGroup::BundleList const r = _matrix->rows()->bundles();
+       for (PortGroup::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) {
+               render_bundle_name (cr, i->has_colour ? i->colour : get_a_bundle_colour (N), 0, y, i->bundle);
+               int const n = _matrix->show_only_bundles() ? 1 : i->bundle->nchannels();
                y += row_height() * n;
+               ++N;
        }
        
 
@@ -162,11 +164,13 @@ PortMatrixRowLabels::render (cairo_t* cr)
 
         if (!_matrix->show_only_bundles()) {
                y = 0;
-               for (ARDOUR::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) {
-                       for (uint32_t j = 0; j < (*i)->nchannels(); ++j) {
-                               render_channel_name (cr, get_a_bundle_colour (i - r.begin()), 0, y, ARDOUR::BundleChannel (*i, j));
+               N = 0;
+               for (PortGroup::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) {
+                       for (uint32_t j = 0; j < i->bundle->nchannels(); ++j) {
+                               render_channel_name (cr, i->has_colour ? i->colour : get_a_bundle_colour (N), 0, y, ARDOUR::BundleChannel (i->bundle, j));
                                y += row_height();
                        }
+                       ++N;
                }
        }
 }
@@ -312,12 +316,12 @@ PortMatrixRowLabels::channel_y (ARDOUR::BundleChannel const& bc) const
 {
        uint32_t n = 0;
 
-       ARDOUR::BundleList::const_iterator i = _matrix->rows()->bundles().begin();
-       while (i != _matrix->rows()->bundles().end() && *i != bc.bundle) {
+       PortGroup::BundleList::const_iterator i = _matrix->rows()->bundles().begin();
+       while (i != _matrix->rows()->bundles().end() && i->bundle != bc.bundle) {
                if (_matrix->show_only_bundles()) {
                        n += 1;
                } else {
-                       n += (*i)->nchannels ();
+                       n += i->bundle->nchannels ();
                }
                ++i;
        }
index 83aa91e1ae7ba66dca3fb8ef2bcf88b657072a05..7171edf98d214943f423e227f71285191c2049ae 100644 (file)
@@ -333,6 +333,8 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulThingWithGoingAway
        virtual ArdourCanvas::Group* get_background_group () const = 0;
        virtual ArdourCanvas::Group* get_trackview_group () const = 0;
 
+       virtual TimeAxisView* axis_view_from_route (ARDOUR::Route *) const = 0;
+
        /// Singleton instance, set up by Editor::Editor()
 
        static PublicEditor* _instance;