Use track colours in the port matrix.

git-svn-id: svn://localhost/ardour2/branches/3.0@5367 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2009-07-17 13:18:58 +00:00
parent 939cff5150
commit 7eea227bcd
12 changed files with 229 additions and 158 deletions

View file

@ -4863,19 +4863,31 @@ Editor::streamview_height_changed ()
_summary->set_dirty (); _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 TrackSelection
Editor::axis_views_from_routes (list<Route*> r) const Editor::axis_views_from_routes (list<Route*> r) const
{ {
TrackSelection t; TrackSelection t;
for (list<Route*>::const_iterator i = r.begin(); i != r.end(); ++i) { for (list<Route*>::const_iterator i = r.begin(); i != r.end(); ++i) {
TrackViewList::const_iterator j = track_views.begin (); TimeAxisView* tv = axis_view_from_route (*i);
while (j != track_views.end()) { if (tv) {
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*j); t.push_back (tv);
if (rtv && rtv->route().get() == *i) {
t.push_back (rtv);
}
++j;
} }
} }

View file

@ -970,6 +970,7 @@ class Editor : public PublicEditor
/* track views */ /* track views */
TrackViewList track_views; TrackViewList track_views;
std::pair<TimeAxisView*, ARDOUR::layer_t> trackview_by_y_position (double); 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; TrackSelection axis_views_from_routes (std::list<ARDOUR::Route *>) const;
static Gdk::Cursor* cross_hair_cursor; static Gdk::Cursor* cross_hair_cursor;

View file

@ -31,6 +31,8 @@
#include "port_group.h" #include "port_group.h"
#include "port_matrix.h" #include "port_matrix.h"
#include "time_axis_view.h"
#include "public_editor.h"
#include "i18n.h" #include "i18n.h"
@ -54,11 +56,34 @@ void
PortGroup::add_bundle (boost::shared_ptr<Bundle> b) PortGroup::add_bundle (boost::shared_ptr<Bundle> b)
{ {
assert (b.get()); assert (b.get());
_bundles.push_back (b);
_bundle_changed_connections[b] = BundleRecord r;
b->Changed.connect (sigc::mem_fun (*this, &PortGroup::bundle_changed)); 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 (); Modified ();
} }
@ -67,13 +92,17 @@ PortGroup::remove_bundle (boost::shared_ptr<Bundle> b)
{ {
assert (b.get()); 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()) { if (i == _bundles.end()) {
return; return;
} }
i->changed_connection.disconnect ();
_bundles.erase (i); _bundles.erase (i);
_bundle_changed_connections[b].disconnect ();
Modified (); Modified ();
} }
@ -88,16 +117,11 @@ PortGroup::bundle_changed (Bundle::Change c)
void void
PortGroup::clear () PortGroup::clear ()
{ {
_bundles.clear (); for (BundleList::iterator i = _bundles.begin(); i != _bundles.end(); ++i) {
i->changed_connection.disconnect ();
for (ConnectionList::iterator i = _bundle_changed_connections.begin(); i != _bundle_changed_connections.end(); ++i) {
i->second.disconnect ();
} }
_bundle_changed_connections.clear ();
_bundles.clear ();
Modified (); Modified ();
} }
@ -105,7 +129,7 @@ bool
PortGroup::has_port (std::string const& p) const PortGroup::has_port (std::string const& p) const
{ {
for (BundleList::const_iterator i = _bundles.begin(); i != _bundles.end(); ++i) { 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; return true;
} }
} }
@ -117,7 +141,7 @@ boost::shared_ptr<Bundle>
PortGroup::only_bundle () PortGroup::only_bundle ()
{ {
assert (_bundles.size() == 1); assert (_bundles.size() == 1);
return _bundles.front(); return _bundles.front().bundle;
} }
@ -126,13 +150,12 @@ PortGroup::total_channels () const
{ {
uint32_t n = 0; uint32_t n = 0;
for (BundleList::const_iterator i = _bundles.begin(); i != _bundles.end(); ++i) { for (BundleList::const_iterator i = _bundles.begin(); i != _bundles.end(); ++i) {
n += (*i)->nchannels (); n += i->bundle->nchannels ();
} }
return n; return n;
} }
/** PortGroupList constructor. /** PortGroupList constructor.
*/ */
PortGroupList::PortGroupList () 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 */ /** Gather bundles from around the system and put them in this PortGroupList */
void void
PortGroupList::gather (Session& session, bool inputs) PortGroupList::gather (ARDOUR::Session& session, bool inputs)
{ {
clear (); clear ();
@ -222,7 +245,13 @@ PortGroupList::gather (Session& session, bool inputs)
} }
if (g) { 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; std::vector<std::string> extra_other;
const char **ports = session.engine().get_ports ("", _type.to_jack_type(), inputs ? const char **ports = session.engine().get_ports ("", _type.to_jack_type(), inputs ?
JackPortIsInput : JackPortIsOutput); JackPortIsInput : JackPortIsOutput);
if (ports) { if (ports) {
int n = 0; int n = 0;
@ -376,7 +405,7 @@ PortGroupList::clear ()
} }
BundleList const & PortGroup::BundleList const &
PortGroupList::bundles () const PortGroupList::bundles () const
{ {
_bundles.clear (); _bundles.clear ();

View file

@ -38,6 +38,7 @@ namespace ARDOUR {
class PortMatrix; class PortMatrix;
class RouteBundle; class RouteBundle;
class PublicEditor;
/** A list of bundles and ports, grouped by some aspect of their /** 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 * type e.g. busses, tracks, system. Each group has 0 or more bundles
@ -49,6 +50,7 @@ public:
PortGroup (std::string const & n); PortGroup (std::string const & n);
void add_bundle (boost::shared_ptr<ARDOUR::Bundle>); 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>); void remove_bundle (boost::shared_ptr<ARDOUR::Bundle>);
boost::shared_ptr<ARDOUR::Bundle> only_bundle (); boost::shared_ptr<ARDOUR::Bundle> only_bundle ();
void clear (); void clear ();
@ -56,10 +58,6 @@ public:
std::string name; ///< name for the group std::string name; ///< name for the group
ARDOUR::BundleList const & bundles () const {
return _bundles;
}
bool visible () const { bool visible () const {
return _visible; return _visible;
} }
@ -74,14 +72,23 @@ public:
sigc::signal<void> Modified; sigc::signal<void> Modified;
sigc::signal<void, ARDOUR::Bundle::Change> BundleChanged; 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: private:
void bundle_changed (ARDOUR::Bundle::Change); void bundle_changed (ARDOUR::Bundle::Change);
ARDOUR::BundleList _bundles;
typedef std::map<boost::shared_ptr<ARDOUR::Bundle>, sigc::connection> ConnectionList; BundleList _bundles;
ConnectionList _bundle_changed_connections;
bool _visible; ///< true if the group is visible in the UI 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 add_group (boost::shared_ptr<PortGroup>);
void set_type (ARDOUR::DataType); void set_type (ARDOUR::DataType);
void gather (ARDOUR::Session &, bool); void gather (ARDOUR::Session &, bool);
ARDOUR::BundleList const & bundles () const; PortGroup::BundleList const & bundles () const;
void clear (); void clear ();
void remove_bundle (boost::shared_ptr<ARDOUR::Bundle>); void remove_bundle (boost::shared_ptr<ARDOUR::Bundle>);
uint32_t total_visible_channels () const; 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> > &); 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; ARDOUR::DataType _type;
mutable ARDOUR::BundleList _bundles; mutable PortGroup::BundleList _bundles;
List _groups; List _groups;
std::vector<sigc::connection> _bundle_changed_connections; std::vector<sigc::connection> _bundle_changed_connections;
bool _signals_suspended; bool _signals_suspended;

View file

@ -278,17 +278,17 @@ PortMatrix::setup_scrollbars ()
void void
PortMatrix::disassociate_all () PortMatrix::disassociate_all ()
{ {
ARDOUR::BundleList a = _ports[0].bundles (); PortGroup::BundleList a = _ports[0].bundles ();
ARDOUR::BundleList b = _ports[1].bundles (); PortGroup::BundleList b = _ports[1].bundles ();
for (ARDOUR::BundleList::iterator i = a.begin(); i != a.end(); ++i) { for (PortGroup::BundleList::iterator i = a.begin(); i != a.end(); ++i) {
for (uint32_t j = 0; j < (*i)->nchannels(); ++j) { for (uint32_t j = 0; j < i->bundle->nchannels(); ++j) {
for (ARDOUR::BundleList::iterator k = b.begin(); k != b.end(); ++k) { for (PortGroup::BundleList::iterator k = b.begin(); k != b.end(); ++k) {
for (uint32_t l = 0; l < (*k)->nchannels(); ++l) { for (uint32_t l = 0; l < k->bundle->nchannels(); ++l) {
ARDOUR::BundleChannel c[2] = { ARDOUR::BundleChannel c[2] = {
ARDOUR::BundleChannel (*i, j), ARDOUR::BundleChannel (i->bundle, j),
ARDOUR::BundleChannel (*k, l) ARDOUR::BundleChannel (k->bundle, l)
}; };
if (get_state (c) == PortMatrixNode::ASSOCIATED) { 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::BundleChannel bc;
ARDOUR::BundleList const r = _ports[dim].bundles(); PortGroup::BundleList const r = _ports[dim].bundles();
for (ARDOUR::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) { for (PortGroup::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) {
if (N < (*i)->nchannels ()) { if (N < i->bundle->nchannels ()) {
bc = ARDOUR::BundleChannel (*i, N); bc = ARDOUR::BundleChannel (i->bundle, N);
break; break;
} else { } else {
N -= (*i)->nchannels (); N -= i->bundle->nchannels ();
} }
} }
@ -464,14 +464,14 @@ PortMatrix::disassociate_all_on_channel (boost::weak_ptr<ARDOUR::Bundle> bundle,
return; 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 (PortGroup::BundleList::iterator i = a.begin(); i != a.end(); ++i) {
for (uint32_t j = 0; j < (*i)->nchannels(); ++j) { for (uint32_t j = 0; j < i->bundle->nchannels(); ++j) {
ARDOUR::BundleChannel c[2]; ARDOUR::BundleChannel c[2];
c[dim] = ARDOUR::BundleChannel (sb, channel); 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) { if (get_state (c) == PortMatrixNode::ASSOCIATED) {
set_state (c, false); set_state (c, false);

View file

@ -278,19 +278,19 @@ PortMatrixBody::setup ()
/* Connect to bundles so that we find out when their names change */ /* Connect to bundles so that we find out when their names change */
ARDOUR::BundleList r = _matrix->rows()->bundles (); PortGroup::BundleList r = _matrix->rows()->bundles ();
for (ARDOUR::BundleList::iterator i = r.begin(); i != r.end(); ++i) { for (PortGroup::BundleList::iterator i = r.begin(); i != r.end(); ++i) {
_bundle_connections.push_back ( _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 (); PortGroup::BundleList c = _matrix->columns()->bundles ();
for (ARDOUR::BundleList::iterator i = c.begin(); i != c.end(); ++i) { for (PortGroup::BundleList::iterator i = c.begin(); i != c.end(); ++i) {
_bundle_connections.push_back ( _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::BundleChannel bc[2];
ARDOUR::BundleList const a = _matrix->ports(dim)->bundles (); PortGroup::BundleList const a = _matrix->ports(dim)->bundles ();
for (ARDOUR::BundleList::const_iterator i = a.begin(); i != a.end(); ++i) { for (PortGroup::BundleList::const_iterator i = a.begin(); i != a.end(); ++i) {
if (N < (*i)->nchannels ()) { if (N < i->bundle->nchannels ()) {
bc[dim] = ARDOUR::BundleChannel (*i, N); bc[dim] = ARDOUR::BundleChannel (i->bundle, N);
break; break;
} else { } 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]); _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 (PortGroup::BundleList::const_iterator i = b.begin(); i != b.end(); ++i) {
for (uint32_t j = 0; j < (*i)->nchannels(); ++j) { for (uint32_t j = 0; j < i->bundle->nchannels(); ++j) {
bc[1 - dim] = ARDOUR::BundleChannel (*i, j); bc[1 - dim] = ARDOUR::BundleChannel (i->bundle, j);
if (_matrix->get_state (bc) == PortMatrixNode::ASSOCIATED) { if (_matrix->get_state (bc) == PortMatrixNode::ASSOCIATED) {
if (dim == _matrix->column_index()) { if (dim == _matrix->column_index()) {
_row_labels->add_channel_highlight (bc[1 - dim]); _row_labels->add_channel_highlight (bc[1 - dim]);

View file

@ -25,6 +25,8 @@
#include "port_matrix_body.h" #include "port_matrix_body.h"
#include "utils.h" #include "utils.h"
using namespace std;
PortMatrixColumnLabels::PortMatrixColumnLabels (PortMatrix* m, PortMatrixBody* b) PortMatrixColumnLabels::PortMatrixColumnLabels (PortMatrix* m, PortMatrixBody* b)
: PortMatrixLabels (m, b) : PortMatrixLabels (m, b)
{ {
@ -47,11 +49,11 @@ PortMatrixColumnLabels::compute_dimensions ()
/* width of the whole thing */ /* width of the whole thing */
_width = 0; _width = 0;
ARDOUR::BundleList const c = _matrix->columns()->bundles(); PortGroup::BundleList const c = _matrix->columns()->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) {
cairo_text_extents_t ext; 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) { if (ext.width > _longest_bundle_name) {
_longest_bundle_name = ext.width; _longest_bundle_name = ext.width;
} }
@ -59,11 +61,11 @@ PortMatrixColumnLabels::compute_dimensions ()
_highest_text = ext.height; _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 ( cairo_text_extents (
cr, cr,
(*i)->channel_name (j).c_str(), i->bundle->channel_name (j).c_str(),
&ext &ext
); );
@ -78,7 +80,7 @@ PortMatrixColumnLabels::compute_dimensions ()
if (_matrix->show_only_bundles()) { if (_matrix->show_only_bundles()) {
_width += column_width(); _width += column_width();
} else { } else {
_width += (*i)->nchannels() * column_width(); _width += i->bundle->nchannels() * column_width();
} }
} }
@ -164,8 +166,8 @@ PortMatrixColumnLabels::render (cairo_t* cr)
} }
cairo_fill (cr); cairo_fill (cr);
std::string const upper = Glib::ustring ((*i)->name).uppercase (); string const upper = Glib::ustring ((*i)->name).uppercase ();
std::pair<std::string, double> const display = fit_to_pixels (cr, upper, w); pair<string, double> const display = fit_to_pixels (cr, upper, w);
/* plot it */ /* plot it */
set_source_rgb (cr, text_colour()); set_source_rgb (cr, text_colour());
@ -179,16 +181,20 @@ PortMatrixColumnLabels::render (cairo_t* cr)
/* BUNDLE PARALLELOGRAM-TYPE-THING AND NAME */ /* BUNDLE PARALLELOGRAM-TYPE-THING AND NAME */
x = 0; x = 0;
ARDOUR::BundleList const c = _matrix->columns()->bundles(); int N = 0;
for (ARDOUR::BundleList::const_iterator i = c.begin (); i != c.end(); ++i) { 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()) { if (_matrix->show_only_bundles()) {
x += column_width(); x += column_width();
} else { } 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()) { if (!_matrix->show_only_bundles()) {
x = 0; 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) { 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, get_a_bundle_colour (i - c.begin()), x, 0, ARDOUR::BundleChannel (*i, j)); render_channel_name (cr, c, x, 0, ARDOUR::BundleChannel (i->bundle, j));
x += column_width(); 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 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 lc = _longest_channel_name + name_pad();
double const w = column_width(); 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 x_ = xoff + slanted_height() / tan (angle()) + w;
double y_ = yoff; double y_ = yoff;
shape.push_back (std::make_pair (x_, y_)); shape.push_back (make_pair (x_, y_));
x_ -= w; x_ -= w;
shape.push_back (std::make_pair (x_, y_)); shape.push_back (make_pair (x_, y_));
x_ -= lc * cos (angle()); x_ -= lc * cos (angle());
y_ += lc * sin (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); x_ += w * pow (sin (angle()), 2);
y_ += w * sin (angle()) * cos (angle()); y_ += w * sin (angle()) * cos (angle());
shape.push_back (std::make_pair (x_, y_)); shape.push_back (make_pair (x_, y_));
} else { } else {
double x_ = xoff; double x_ = xoff;
double y_ = yoff + _height; double y_ = yoff + _height;
shape.push_back (std::make_pair (x_, y_)); shape.push_back (make_pair (x_, y_));
x_ += w; x_ += w;
shape.push_back (std::make_pair (x_, y_)); shape.push_back (make_pair (x_, y_));
x_ += lc * cos (angle()); x_ += lc * cos (angle());
y_ -= lc * sin (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); x_ -= column_width() * pow (sin (angle()), 2);
y_ -= column_width() * sin (angle()) * cos (angle()); y_ -= column_width() * sin (angle()) * cos (angle());
shape.push_back (std::make_pair (x_, y_)); shape.push_back (make_pair (x_, y_));
} }
return shape; return shape;
@ -354,7 +363,7 @@ PortMatrixColumnLabels::render_channel_name (
cairo_t* cr, Gdk::Color colour, double xoff, double yoff, ARDOUR::BundleChannel const &bc 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); cairo_move_to (cr, shape[0].first, shape[0].second);
for (uint32_t i = 1; i < 4; ++i) { for (uint32_t i = 1; i < 4; ++i) {
@ -404,12 +413,12 @@ PortMatrixColumnLabels::channel_x (ARDOUR::BundleChannel const &bc) const
{ {
uint32_t n = 0; uint32_t n = 0;
ARDOUR::BundleList::const_iterator i = _matrix->columns()->bundles().begin(); PortGroup::BundleList::const_iterator i = _matrix->columns()->bundles().begin();
while (i != _matrix->columns()->bundles().end() && *i != bc.bundle) { while (i != _matrix->columns()->bundles().end() && i->bundle != bc.bundle) {
if (_matrix->show_only_bundles()) { if (_matrix->show_only_bundles()) {
n += 1; n += 1;
} else { } else {
n += (*i)->nchannels (); n += i->bundle->nchannels ();
} }
++i; ++i;
} }
@ -481,7 +490,7 @@ PortMatrixColumnLabels::button_press (double x, double y, int b, uint32_t t)
uint32_t i = 0; uint32_t i = 0;
for (; i < N; ++i) { 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; uint32_t j = 0;
for (; j < 4; ++j) { for (; j < 4; ++j) {

View file

@ -60,7 +60,7 @@ private:
return _height - _highest_group_name - 2 * name_pad(); 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_bundle_name;
double _longest_channel_name; double _longest_channel_name;
double _highest_text; double _highest_text;

View file

@ -35,22 +35,22 @@ void
PortMatrixGrid::compute_dimensions () PortMatrixGrid::compute_dimensions ()
{ {
_width = 0; _width = 0;
ARDOUR::BundleList const c = _matrix->columns()->bundles(); PortGroup::BundleList const c = _matrix->columns()->bundles();
if (_matrix->show_only_bundles()) { if (_matrix->show_only_bundles()) {
_width = c.size() * column_width(); _width = c.size() * column_width();
} else { } 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) {
_width += (*i)->nchannels() * column_width(); _width += i->bundle->nchannels() * column_width();
} }
} }
_height = 0; _height = 0;
ARDOUR::BundleList const r = _matrix->rows()->bundles(); PortGroup::BundleList const r = _matrix->rows()->bundles();
if (_matrix->show_only_bundles()) { if (_matrix->show_only_bundles()) {
_height = r.size() * column_width(); _height = r.size() * column_width();
} else { } else {
for (ARDOUR::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) { for (PortGroup::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) {
_height += (*i)->nchannels() * row_height(); _height += i->bundle->nchannels() * row_height();
} }
} }
} }
@ -69,12 +69,13 @@ PortMatrixGrid::render (cairo_t* cr)
set_source_rgb (cr, grid_colour()); set_source_rgb (cr, grid_colour());
uint32_t x = 0; uint32_t x = 0;
ARDOUR::BundleList const c = _matrix->columns()->bundles(); PortGroup::BundleList const c = _matrix->columns()->bundles();
for (ARDOUR::BundleList::size_type i = 0; i < c.size(); ++i) { uint32_t N = 0;
for (PortGroup::BundleList::const_iterator i = c.begin(); i != c.end(); ++i) {
if (!_matrix->show_only_bundles()) { if (!_matrix->show_only_bundles()) {
cairo_set_line_width (cr, thin_grid_line_width()); 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(); x += column_width();
cairo_move_to (cr, x, 0); cairo_move_to (cr, x, 0);
cairo_line_to (cr, x, _height); 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(); x += column_width();
cairo_set_line_width (cr, thick_grid_line_width()); cairo_set_line_width (cr, thick_grid_line_width());
cairo_move_to (cr, x, 0); cairo_move_to (cr, x, 0);
cairo_line_to (cr, x, _height); cairo_line_to (cr, x, _height);
cairo_stroke (cr); cairo_stroke (cr);
} }
++N;
} }
uint32_t grid_width = x + column_width(); uint32_t grid_width = x + column_width();
@ -96,12 +99,13 @@ PortMatrixGrid::render (cairo_t* cr)
/* HORIZONTAL GRID LINES */ /* HORIZONTAL GRID LINES */
uint32_t y = 0; uint32_t y = 0;
ARDOUR::BundleList const r = _matrix->rows()->bundles(); N = 0;
for (ARDOUR::BundleList::size_type i = 0; i < r.size(); ++i) { PortGroup::BundleList const r = _matrix->rows()->bundles();
for (PortGroup::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) {
if (!_matrix->show_only_bundles()) { if (!_matrix->show_only_bundles()) {
cairo_set_line_width (cr, thin_grid_line_width()); 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(); y += row_height();
cairo_move_to (cr, 0, y); cairo_move_to (cr, 0, y);
cairo_line_to (cr, grid_width, 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(); y += row_height();
cairo_set_line_width (cr, thick_grid_line_width()); cairo_set_line_width (cr, thick_grid_line_width());
cairo_move_to (cr, 0, y); cairo_move_to (cr, 0, y);
cairo_line_to (cr, grid_width, y); cairo_line_to (cr, grid_width, y);
cairo_stroke (cr); cairo_stroke (cr);
} }
++N;
} }
/* ASSOCIATION INDICATORS */ /* ASSOCIATION INDICATORS */
@ -125,12 +131,12 @@ PortMatrixGrid::render (cairo_t* cr)
if (_matrix->show_only_bundles()) { 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; 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) { switch (s) {
case PortMatrixNode::UNKNOWN: case PortMatrixNode::UNKNOWN:
draw_unknown_indicator (cr, bx, by); draw_unknown_indicator (cr, bx, by);
@ -153,20 +159,20 @@ PortMatrixGrid::render (cairo_t* cr)
} else { } 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; 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; x = bx;
for (uint32_t k = 0; k < (*i)->nchannels (); ++k) { for (uint32_t k = 0; k < i->bundle->nchannels (); ++k) {
y = by; 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]; ARDOUR::BundleChannel c[2];
c[_matrix->column_index()] = ARDOUR::BundleChannel (*i, k); c[_matrix->column_index()] = ARDOUR::BundleChannel (i->bundle, k);
c[_matrix->row_index()] = ARDOUR::BundleChannel (*j, l); c[_matrix->row_index()] = ARDOUR::BundleChannel (j->bundle, l);
PortMatrixNode::State const s = _matrix->get_state (c); PortMatrixNode::State const s = _matrix->get_state (c);
@ -192,10 +198,10 @@ PortMatrixGrid::render (cairo_t* cr)
x += column_width(); 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 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; uint32_t pos = p / inc;
if (_matrix->show_only_bundles()) { 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) { if (pos == 0) {
return ARDOUR::BundleChannel (*i, 0); return ARDOUR::BundleChannel (i->bundle, 0);
} else { } else {
pos--; pos--;
} }
@ -257,11 +263,11 @@ PortMatrixGrid::position_to_channel (double p, ARDOUR::BundleList const& bundles
} else { } else {
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 < (*i)->nchannels()) { if (pos < i->bundle->nchannels()) {
return ARDOUR::BundleChannel (*i, pos); return ARDOUR::BundleChannel (i->bundle, pos);
} else { } else {
pos -= (*i)->nchannels(); pos -= i->bundle->nchannels();
} }
} }
@ -274,18 +280,18 @@ PortMatrixGrid::position_to_channel (double p, ARDOUR::BundleList const& bundles
double double
PortMatrixGrid::channel_position ( PortMatrixGrid::channel_position (
ARDOUR::BundleChannel bc, ARDOUR::BundleChannel bc,
ARDOUR::BundleList const& bundles, PortGroup::BundleList const& bundles,
double inc) const double inc) const
{ {
double p = 0; double p = 0;
ARDOUR::BundleList::const_iterator i = bundles.begin (); PortGroup::BundleList::const_iterator i = bundles.begin ();
while (i != bundles.end() && *i != bc.bundle) { while (i != bundles.end() && i->bundle != bc.bundle) {
if (_matrix->show_only_bundles()) { if (_matrix->show_only_bundles()) {
p += inc; p += inc;
} else { } else {
p += inc * (*i)->nchannels(); p += inc * i->bundle->nchannels();
} }
++i; ++i;

View file

@ -26,6 +26,7 @@
#include "ardour/types.h" #include "ardour/types.h"
#include "port_matrix_component.h" #include "port_matrix_component.h"
#include "port_matrix_types.h" #include "port_matrix_types.h"
#include "port_group.h"
class PortMatrix; class PortMatrix;
class PortMatrixBody; class PortMatrixBody;
@ -55,9 +56,9 @@ private:
void compute_dimensions (); void compute_dimensions ();
void render (cairo_t *); 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; 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 queue_draw_for (PortMatrixNode const &);
void draw_association_indicator (cairo_t *, uint32_t, uint32_t, double p = 1); void draw_association_indicator (cairo_t *, uint32_t, uint32_t, double p = 1);
void draw_unknown_indicator (cairo_t *, uint32_t, uint32_t); void draw_unknown_indicator (cairo_t *, uint32_t, uint32_t);

View file

@ -43,18 +43,18 @@ PortMatrixRowLabels::compute_dimensions ()
_longest_port_name = 0; _longest_port_name = 0;
_longest_bundle_name = 0; _longest_bundle_name = 0;
_height = 0; _height = 0;
ARDOUR::BundleList const r = _matrix->rows()->bundles(); PortGroup::BundleList const r = _matrix->rows()->bundles();
for (ARDOUR::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) { for (PortGroup::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) {
for (uint32_t j = 0; j < (*i)->nchannels(); ++j) { for (uint32_t j = 0; j < i->bundle->nchannels(); ++j) {
cairo_text_extents_t ext; 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) { if (ext.width > _longest_port_name) {
_longest_port_name = ext.width; _longest_port_name = ext.width;
} }
} }
cairo_text_extents_t ext; 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) { if (ext.width > _longest_bundle_name) {
_longest_bundle_name = ext.width; _longest_bundle_name = ext.width;
} }
@ -62,7 +62,7 @@ PortMatrixRowLabels::compute_dimensions ()
if (_matrix->show_only_bundles()) { if (_matrix->show_only_bundles()) {
_height += row_height (); _height += row_height ();
} else { } else {
_height += (*i)->nchannels() * row_height(); _height += i->bundle->nchannels() * row_height();
} }
} }
@ -150,11 +150,13 @@ PortMatrixRowLabels::render (cairo_t* cr)
/* BUNDLE NAMES */ /* BUNDLE NAMES */
y = 0; y = 0;
ARDOUR::BundleList const r = _matrix->rows()->bundles(); int N = 0;
for (ARDOUR::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) { PortGroup::BundleList const r = _matrix->rows()->bundles();
render_bundle_name (cr, get_a_bundle_colour (i - r.begin ()), 0, y, *i); for (PortGroup::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) {
int const n = _matrix->show_only_bundles() ? 1 : (*i)->nchannels(); 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; y += row_height() * n;
++N;
} }
@ -162,11 +164,13 @@ PortMatrixRowLabels::render (cairo_t* cr)
if (!_matrix->show_only_bundles()) { if (!_matrix->show_only_bundles()) {
y = 0; y = 0;
for (ARDOUR::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) { N = 0;
for (uint32_t j = 0; j < (*i)->nchannels(); ++j) { for (PortGroup::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) {
render_channel_name (cr, get_a_bundle_colour (i - r.begin()), 0, y, ARDOUR::BundleChannel (*i, j)); 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(); y += row_height();
} }
++N;
} }
} }
} }
@ -312,12 +316,12 @@ PortMatrixRowLabels::channel_y (ARDOUR::BundleChannel const& bc) const
{ {
uint32_t n = 0; uint32_t n = 0;
ARDOUR::BundleList::const_iterator i = _matrix->rows()->bundles().begin(); PortGroup::BundleList::const_iterator i = _matrix->rows()->bundles().begin();
while (i != _matrix->rows()->bundles().end() && *i != bc.bundle) { while (i != _matrix->rows()->bundles().end() && i->bundle != bc.bundle) {
if (_matrix->show_only_bundles()) { if (_matrix->show_only_bundles()) {
n += 1; n += 1;
} else { } else {
n += (*i)->nchannels (); n += i->bundle->nchannels ();
} }
++i; ++i;
} }

View 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_background_group () const = 0;
virtual ArdourCanvas::Group* get_trackview_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() /// Singleton instance, set up by Editor::Editor()
static PublicEditor* _instance; static PublicEditor* _instance;