Support for the port matrix working at the bundle level and hiding details of ports.

git-svn-id: svn://localhost/ardour2/branches/3.0@5029 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2009-05-03 14:31:42 +00:00
parent 7e48118bf1
commit 1ae39840b3
19 changed files with 560 additions and 256 deletions

View file

@ -67,17 +67,17 @@ BundleEditorMatrix::set_state (ARDOUR::BundleChannel c[2], bool s)
} }
} }
PortMatrix::State PortMatrixNode::State
BundleEditorMatrix::get_state (ARDOUR::BundleChannel c[2]) const BundleEditorMatrix::get_state (ARDOUR::BundleChannel c[2]) const
{ {
ARDOUR::Bundle::PortList const& pl = c[OTHER].bundle->channel_ports (c[OTHER].channel); ARDOUR::Bundle::PortList const& pl = c[OTHER].bundle->channel_ports (c[OTHER].channel);
for (ARDOUR::Bundle::PortList::const_iterator i = pl.begin(); i != pl.end(); ++i) { for (ARDOUR::Bundle::PortList::const_iterator i = pl.begin(); i != pl.end(); ++i) {
if (!c[OURS].bundle->port_attached_to_channel (c[OURS].channel, *i)) { if (!c[OURS].bundle->port_attached_to_channel (c[OURS].channel, *i)) {
return NOT_ASSOCIATED; return PortMatrixNode::NOT_ASSOCIATED;
} }
} }
return ASSOCIATED; return PortMatrixNode::ASSOCIATED;
} }
void void

View file

@ -37,7 +37,7 @@ class BundleEditorMatrix : public PortMatrix
BundleEditorMatrix (ARDOUR::Session &, boost::shared_ptr<ARDOUR::Bundle>); BundleEditorMatrix (ARDOUR::Session &, boost::shared_ptr<ARDOUR::Bundle>);
void set_state (ARDOUR::BundleChannel c[2], bool s); void set_state (ARDOUR::BundleChannel c[2], bool s);
State get_state (ARDOUR::BundleChannel c[2]) const; PortMatrixNode::State get_state (ARDOUR::BundleChannel c[2]) const;
void add_channel (boost::shared_ptr<ARDOUR::Bundle>); void add_channel (boost::shared_ptr<ARDOUR::Bundle>);
bool can_remove_channels (int d) const { bool can_remove_channels (int d) const {
return d == OURS; return d == OURS;

View file

@ -71,7 +71,7 @@ GlobalPortMatrix::set_state (ARDOUR::BundleChannel c[2], bool s)
} }
} }
PortMatrix::State PortMatrixNode::State
GlobalPortMatrix::get_state (ARDOUR::BundleChannel c[2]) const GlobalPortMatrix::get_state (ARDOUR::BundleChannel c[2]) const
{ {
ARDOUR::Bundle::PortList const & in_ports = c[IN].bundle->channel_ports (c[IN].channel); ARDOUR::Bundle::PortList const & in_ports = c[IN].bundle->channel_ports (c[IN].channel);
@ -79,7 +79,7 @@ GlobalPortMatrix::get_state (ARDOUR::BundleChannel c[2]) const
if (in_ports.empty() || out_ports.empty()) { if (in_ports.empty() || out_ports.empty()) {
/* we're looking at a bundle with no parts associated with this channel, /* we're looking at a bundle with no parts associated with this channel,
so nothing to connect */ so nothing to connect */
return UNKNOWN; return PortMatrixNode::UNKNOWN;
} }
for (ARDOUR::Bundle::PortList::const_iterator i = in_ports.begin(); i != in_ports.end(); ++i) { for (ARDOUR::Bundle::PortList::const_iterator i = in_ports.begin(); i != in_ports.end(); ++i) {
@ -90,22 +90,21 @@ GlobalPortMatrix::get_state (ARDOUR::BundleChannel c[2]) const
/* we don't know the state of connections between two non-Ardour ports */ /* we don't know the state of connections between two non-Ardour ports */
if (!p && !q) { if (!p && !q) {
return UNKNOWN; return PortMatrixNode::UNKNOWN;
} }
if (p && p->connected_to (*j) == false) { if (p && p->connected_to (*j) == false) {
return NOT_ASSOCIATED; return PortMatrixNode::NOT_ASSOCIATED;
} else if (q && q->connected_to (*i) == false) { } else if (q && q->connected_to (*i) == false) {
return NOT_ASSOCIATED; return PortMatrixNode::NOT_ASSOCIATED;
} }
} }
} }
return ASSOCIATED; return PortMatrixNode::ASSOCIATED;
} }
GlobalPortMatrixWindow::GlobalPortMatrixWindow (ARDOUR::Session& s, ARDOUR::DataType t) GlobalPortMatrixWindow::GlobalPortMatrixWindow (ARDOUR::Session& s, ARDOUR::DataType t)
: _port_matrix (s, t) : _port_matrix (s, t)
{ {
@ -124,6 +123,11 @@ GlobalPortMatrixWindow::GlobalPortMatrixWindow (ARDOUR::Session& s, ARDOUR::Data
_rescan_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::REFRESH, Gtk::ICON_SIZE_BUTTON))); _rescan_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::REFRESH, Gtk::ICON_SIZE_BUTTON)));
_rescan_button.signal_clicked().connect (sigc::mem_fun (_port_matrix, &GlobalPortMatrix::setup_all_ports)); _rescan_button.signal_clicked().connect (sigc::mem_fun (_port_matrix, &GlobalPortMatrix::setup_all_ports));
buttons_hbox->pack_start (_rescan_button, Gtk::PACK_SHRINK); buttons_hbox->pack_start (_rescan_button, Gtk::PACK_SHRINK);
_show_ports_button.set_label (_("Show individual ports"));
_show_ports_button.set_active (true);
_show_ports_button.signal_toggled().connect (sigc::mem_fun (*this, &GlobalPortMatrixWindow::show_ports_toggled));
buttons_hbox->pack_start (_show_ports_button, Gtk::PACK_SHRINK);
Gtk::VBox* vbox = Gtk::manage (new Gtk::VBox); Gtk::VBox* vbox = Gtk::manage (new Gtk::VBox);
vbox->pack_start (_port_matrix); vbox->pack_start (_port_matrix);
@ -131,3 +135,9 @@ GlobalPortMatrixWindow::GlobalPortMatrixWindow (ARDOUR::Session& s, ARDOUR::Data
add (*vbox); add (*vbox);
show_all (); show_all ();
} }
void
GlobalPortMatrixWindow::show_ports_toggled ()
{
_port_matrix.set_show_only_bundles (!_show_ports_button.get_active());
}

View file

@ -33,7 +33,7 @@ public:
void setup_ports (int); void setup_ports (int);
void set_state (ARDOUR::BundleChannel c[2], bool); void set_state (ARDOUR::BundleChannel c[2], bool);
State get_state (ARDOUR::BundleChannel c[2]) const; PortMatrixNode::State get_state (ARDOUR::BundleChannel c[2]) const;
void add_channel (boost::shared_ptr<ARDOUR::Bundle>) {} void add_channel (boost::shared_ptr<ARDOUR::Bundle>) {}
bool can_remove_channels (int d) const { bool can_remove_channels (int d) const {
@ -63,8 +63,11 @@ public:
GlobalPortMatrixWindow (ARDOUR::Session&, ARDOUR::DataType); GlobalPortMatrixWindow (ARDOUR::Session&, ARDOUR::DataType);
private: private:
void show_ports_toggled ();
GlobalPortMatrix _port_matrix; GlobalPortMatrix _port_matrix;
Gtk::Button _rescan_button; Gtk::Button _rescan_button;
Gtk::CheckButton _show_ports_button;
}; };

View file

@ -112,7 +112,7 @@ IOSelector::set_state (ARDOUR::BundleChannel c[2], bool s)
} }
} }
PortMatrix::State PortMatrixNode::State
IOSelector::get_state (ARDOUR::BundleChannel c[2]) const IOSelector::get_state (ARDOUR::BundleChannel c[2]) const
{ {
ARDOUR::Bundle::PortList const & our_ports = c[_ours].bundle->channel_ports (c[_ours].channel); ARDOUR::Bundle::PortList const & our_ports = c[_ours].bundle->channel_ports (c[_ours].channel);
@ -121,7 +121,7 @@ IOSelector::get_state (ARDOUR::BundleChannel c[2]) const
if (our_ports.empty() || other_ports.empty()) { if (our_ports.empty() || other_ports.empty()) {
/* we're looking at a bundle with no parts associated with this channel, /* we're looking at a bundle with no parts associated with this channel,
so nothing to connect */ so nothing to connect */
return UNKNOWN; return PortMatrixNode::UNKNOWN;
} }
for (ARDOUR::Bundle::PortList::const_iterator i = our_ports.begin(); i != our_ports.end(); ++i) { for (ARDOUR::Bundle::PortList::const_iterator i = our_ports.begin(); i != our_ports.end(); ++i) {
@ -135,12 +135,12 @@ IOSelector::get_state (ARDOUR::BundleChannel c[2]) const
if (!f->connected_to (*j)) { if (!f->connected_to (*j)) {
/* if any one thing is not connected, all bets are off */ /* if any one thing is not connected, all bets are off */
return NOT_ASSOCIATED; return PortMatrixNode::NOT_ASSOCIATED;
} }
} }
} }
return ASSOCIATED; return PortMatrixNode::ASSOCIATED;
} }
uint32_t uint32_t

View file

@ -33,7 +33,7 @@ class IOSelector : public PortMatrix
IOSelector (ARDOUR::Session&, boost::shared_ptr<ARDOUR::IO>, bool); IOSelector (ARDOUR::Session&, boost::shared_ptr<ARDOUR::IO>, bool);
void set_state (ARDOUR::BundleChannel c[2], bool); void set_state (ARDOUR::BundleChannel c[2], bool);
State get_state (ARDOUR::BundleChannel c[2]) const; PortMatrixNode::State get_state (ARDOUR::BundleChannel c[2]) const;
void add_channel (boost::shared_ptr<ARDOUR::Bundle>); void add_channel (boost::shared_ptr<ARDOUR::Bundle>);
bool can_remove_channels (int d) const { bool can_remove_channels (int d) const {

View file

@ -37,7 +37,8 @@
* @param type Port type that we are handling. * @param type Port type that we are handling.
*/ */
PortMatrix::PortMatrix (ARDOUR::Session& session, ARDOUR::DataType type) PortMatrix::PortMatrix (ARDOUR::Session& session, ARDOUR::DataType type)
: _session (session), : Gtk::Table (2, 2),
_session (session),
_type (type), _type (type),
_column_visibility_box_added (false), _column_visibility_box_added (false),
_row_visibility_box_added (false), _row_visibility_box_added (false),
@ -46,7 +47,8 @@ PortMatrix::PortMatrix (ARDOUR::Session& session, ARDOUR::DataType type)
_arrangement (TOP_TO_RIGHT), _arrangement (TOP_TO_RIGHT),
_row_index (0), _row_index (0),
_column_index (1), _column_index (1),
_min_height_divisor (1) _min_height_divisor (1),
_show_only_bundles (false)
{ {
_body = new PortMatrixBody (this); _body = new PortMatrixBody (this);
@ -147,15 +149,14 @@ PortMatrix::setup ()
_scroller_table.remove (*_body); _scroller_table.remove (*_body);
_scroller_table.remove (_hscroll); _scroller_table.remove (_hscroll);
_main_hbox.remove (_scroller_table); remove (_scroller_table);
if (_row_visibility_box_added) { if (_row_visibility_box_added) {
_main_hbox.remove (_row_visibility_box); remove (_row_visibility_box);
} }
if (_column_visibility_box_added) { if (_column_visibility_box_added) {
remove (_column_visibility_box); remove (_column_visibility_box);
} }
remove (_main_hbox);
} }
if (_column_index == 0) { if (_column_index == 0) {
@ -190,42 +191,38 @@ PortMatrix::setup ()
_scroller_table.attach (*_body, 0, 1, 1, 2); _scroller_table.attach (*_body, 0, 1, 1, 2);
_scroller_table.attach (_vscroll, 1, 2, 1, 2, Gtk::SHRINK); _scroller_table.attach (_vscroll, 1, 2, 1, 2, Gtk::SHRINK);
_main_hbox.pack_start (_scroller_table); attach (_scroller_table, 0, 1, 1, 2, Gtk::FILL | Gtk::EXPAND, Gtk::FILL | Gtk::EXPAND);
if (rows()->size() > 1) { if (rows()->size() > 1) {
_main_hbox.pack_start (_row_visibility_box, Gtk::PACK_SHRINK); attach (_row_visibility_box, 1, 2, 1, 2, Gtk::SHRINK, Gtk::SHRINK);
_row_visibility_box_added = true; _row_visibility_box_added = true;
} else { } else {
_row_visibility_box_added = false; _row_visibility_box_added = false;
} }
if (columns()->size() > 1) { if (columns()->size() > 1) {
pack_start (_column_visibility_box, Gtk::PACK_SHRINK); attach (_column_visibility_box, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
_column_visibility_box_added = true; _column_visibility_box_added = true;
} else { } else {
_column_visibility_box_added = false; _column_visibility_box_added = false;
} }
pack_start (_main_hbox);
} else { } else {
_scroller_table.attach (_vscroll, 0, 1, 0, 1, Gtk::SHRINK); _scroller_table.attach (_vscroll, 0, 1, 0, 1, Gtk::SHRINK);
_scroller_table.attach (*_body, 1, 2, 0, 1); _scroller_table.attach (*_body, 1, 2, 0, 1);
_scroller_table.attach (_hscroll, 1, 2, 1, 2, Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK); _scroller_table.attach (_hscroll, 1, 2, 1, 2, Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK);
if (rows()->size() > 1) { if (rows()->size() > 1) {
_main_hbox.pack_start (_row_visibility_box, Gtk::PACK_SHRINK); attach (_row_visibility_box, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
_row_visibility_box_added = true; _row_visibility_box_added = true;
} else { } else {
_row_visibility_box_added = false; _row_visibility_box_added = false;
} }
_main_hbox.pack_start (_scroller_table); attach (_scroller_table, 1, 2, 0, 1, Gtk::FILL | Gtk::EXPAND, Gtk::FILL | Gtk::EXPAND);
pack_start (_main_hbox);
if (columns()->size() > 1) { if (columns()->size() > 1) {
pack_start (_column_visibility_box, Gtk::PACK_SHRINK); attach (_column_visibility_box, 1, 2, 1, 2, Gtk::SHRINK, Gtk::SHRINK);
_column_visibility_box_added = true; _column_visibility_box_added = true;
} else { } else {
_column_visibility_box_added = false; _column_visibility_box_added = false;
@ -294,7 +291,7 @@ PortMatrix::disassociate_all ()
ARDOUR::BundleChannel (*k, l) ARDOUR::BundleChannel (*k, l)
}; };
if (get_state (c) == ASSOCIATED) { if (get_state (c) == PortMatrixNode::ASSOCIATED) {
set_state (c, false); set_state (c, false);
} }
@ -476,7 +473,7 @@ PortMatrix::disassociate_all_on_channel (boost::weak_ptr<ARDOUR::Bundle> bundle,
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, j);
if (get_state (c) == ASSOCIATED) { if (get_state (c) == PortMatrixNode::ASSOCIATED) {
set_state (c, false); set_state (c, false);
} }
} }
@ -501,3 +498,12 @@ PortMatrix::setup_all_ports ()
setup_ports (0); setup_ports (0);
setup_ports (1); setup_ports (1);
} }
void
PortMatrix::set_show_only_bundles (bool s)
{
_show_only_bundles = s;
_body->setup ();
setup_scrollbars ();
queue_draw ();
}

View file

@ -29,6 +29,7 @@
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include "ardour/bundle.h" #include "ardour/bundle.h"
#include "port_group.h" #include "port_group.h"
#include "port_matrix_types.h"
/** The `port matrix' UI. This is a widget which lets the user alter /** The `port matrix' UI. This is a widget which lets the user alter
* associations between one set of ports and another. e.g. to connect * associations between one set of ports and another. e.g. to connect
@ -36,7 +37,7 @@
* *
* It is made up of a body, PortMatrixBody, which is rendered using cairo, * It is made up of a body, PortMatrixBody, which is rendered using cairo,
* and some scrollbars and other stuff. All of this is arranged inside the * and some scrollbars and other stuff. All of this is arranged inside the
* VBox that we inherit from. * Table that we inherit from.
*/ */
namespace ARDOUR { namespace ARDOUR {
@ -45,7 +46,7 @@ namespace ARDOUR {
class PortMatrixBody; class PortMatrixBody;
class PortMatrix : public Gtk::VBox class PortMatrix : public Gtk::Table
{ {
public: public:
PortMatrix (ARDOUR::Session&, ARDOUR::DataType); PortMatrix (ARDOUR::Session&, ARDOUR::DataType);
@ -78,6 +79,12 @@ public:
return _arrangement; return _arrangement;
} }
bool show_only_bundles () const {
return _show_only_bundles;
}
void set_show_only_bundles (bool);
PortGroupList const * columns () const; PortGroupList const * columns () const;
/** @return index into the _ports array for the list which is displayed as columns */ /** @return index into the _ports array for the list which is displayed as columns */
@ -105,16 +112,10 @@ public:
*/ */
virtual void set_state (ARDOUR::BundleChannel c[2], bool s) = 0; virtual void set_state (ARDOUR::BundleChannel c[2], bool s) = 0;
enum State {
ASSOCIATED, ///< the ports are associaed
NOT_ASSOCIATED, ///< the ports are not associated
UNKNOWN ///< we don't know anything about these two ports' relationship
};
/** @param c Channels; where c[0] is from _ports[0] and c[1] is from _ports[1]. /** @param c Channels; where c[0] is from _ports[0] and c[1] is from _ports[1].
* @return state * @return state
*/ */
virtual State get_state (ARDOUR::BundleChannel c[2]) const = 0; virtual PortMatrixNode::State get_state (ARDOUR::BundleChannel c[2]) const = 0;
virtual bool list_is_global (int) const = 0; virtual bool list_is_global (int) const = 0;
virtual void add_channel (boost::shared_ptr<ARDOUR::Bundle>) = 0; virtual void add_channel (boost::shared_ptr<ARDOUR::Bundle>) = 0;
@ -161,7 +162,6 @@ private:
PortMatrixBody* _body; PortMatrixBody* _body;
Gtk::HScrollbar _hscroll; Gtk::HScrollbar _hscroll;
Gtk::VScrollbar _vscroll; Gtk::VScrollbar _vscroll;
Gtk::HBox _main_hbox;
Gtk::HBox _column_visibility_box; Gtk::HBox _column_visibility_box;
bool _column_visibility_box_added; bool _column_visibility_box_added;
Gtk::Label _column_visibility_label; Gtk::Label _column_visibility_label;
@ -177,6 +177,7 @@ private:
int _row_index; int _row_index;
int _column_index; int _column_index;
int _min_height_divisor; int _min_height_divisor;
bool _show_only_bundles;
}; };
#endif #endif

View file

@ -483,7 +483,7 @@ PortMatrixBody::highlight_associated_channels (int dim, uint32_t N)
for (ARDOUR::BundleList::const_iterator i = b.begin(); i != b.end(); ++i) { for (ARDOUR::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)->nchannels(); ++j) {
bc[1 - dim] = ARDOUR::BundleChannel (*i, j); bc[1 - dim] = ARDOUR::BundleChannel (*i, j);
if (_matrix->get_state (bc) == PortMatrix::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]);
} else { } else {

View file

@ -74,7 +74,11 @@ PortMatrixColumnLabels::compute_dimensions ()
} }
} }
_width += (*i)->nchannels() * column_width(); if (_matrix->show_only_bundles()) {
_width += column_width();
} else {
_width += (*i)->nchannels() * column_width();
}
} }
_highest_group_name = 0; _highest_group_name = 0;
@ -93,9 +97,12 @@ PortMatrixColumnLabels::compute_dimensions ()
/* height of the whole thing */ /* height of the whole thing */
double const parallelogram_height = int a = _longest_bundle_name + 4 * name_pad();
(_longest_bundle_name + _longest_channel_name + 4 * name_pad()) * sin (angle()) if (!_matrix->show_only_bundles()) {
+ _highest_text * cos (angle()); a += _longest_channel_name;
}
double const parallelogram_height = a * sin (angle()) + _highest_text * cos (angle());
_height = parallelogram_height + _highest_group_name + 2 * name_pad(); _height = parallelogram_height + _highest_group_name + 2 * name_pad();
@ -139,7 +146,12 @@ PortMatrixColumnLabels::render (cairo_t* cr)
} }
/* compute width of this group */ /* compute width of this group */
uint32_t w = (*i)->total_channels() * column_width(); uint32_t w = 0;
if (_matrix->show_only_bundles()) {
w = (*i)->bundles().size() * column_width();
} else {
w = (*i)->total_channels() * column_width();
}
/* rectangle */ /* rectangle */
set_source_rgb (cr, get_a_group_colour (g)); set_source_rgb (cr, get_a_group_colour (g));
@ -168,72 +180,27 @@ PortMatrixColumnLabels::render (cairo_t* cr)
ARDOUR::BundleList const c = _matrix->columns()->bundles(); ARDOUR::BundleList const c = _matrix->columns()->bundles();
for (ARDOUR::BundleList::const_iterator i = c.begin (); i != c.end(); ++i) { for (ARDOUR::BundleList::const_iterator i = c.begin (); i != c.end(); ++i) {
Gdk::Color colour = get_a_bundle_colour (i - c.begin ()); render_bundle_name (cr, get_a_bundle_colour (i - c.begin ()), x, 0, *i);
set_source_rgb (cr, colour);
double const w = (*i)->nchannels() * column_width(); if (_matrix->show_only_bundles()) {
x += column_width();
double x_ = x;
if (_matrix->arrangement() == PortMatrix::TOP_TO_RIGHT) {
y = _height;
} else { } else {
y = slanted_height(); x += (*i)->nchannels () * column_width();
} }
double y_ = y;
cairo_move_to (cr, x_, y_);
x_ += w;
cairo_line_to (cr, x_, y_);
x_ += slanted_height() / tan (angle ());
y_ -= slanted_height();
cairo_line_to (cr, x_, y_);
x_ -= w;
cairo_line_to (cr, x_, y_);
cairo_line_to (cr, x, y);
cairo_fill_preserve (cr);
set_source_rgb (cr, background_colour());
cairo_set_line_width (cr, label_border_width());
cairo_stroke (cr);
set_source_rgb (cr, text_colour());
if (_matrix->arrangement() == PortMatrix::TOP_TO_RIGHT) {
double const rl = 3 * name_pad() + _longest_channel_name;
cairo_move_to (
cr,
x + basic_text_x_pos (0) + rl * cos (angle()),
_height - rl * sin (angle())
);
} else {
cairo_move_to (
cr,
x + basic_text_x_pos (0),
slanted_height() - name_pad() * sin (angle())
);
}
cairo_save (cr);
cairo_rotate (cr, -angle());
cairo_show_text (cr, (*i)->name().c_str());
cairo_restore (cr);
x += (*i)->nchannels () * column_width();
} }
/* PORT NAMES */ /* PORT NAMES */
x = 0; if (!_matrix->show_only_bundles()) {
for (ARDOUR::BundleList::const_iterator i = c.begin (); i != c.end(); ++i) { x = 0;
for (ARDOUR::BundleList::const_iterator i = c.begin (); i != c.end(); ++i) {
for (uint32_t j = 0; j < (*i)->nchannels(); ++j) {
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));
x += column_width(); render_channel_name (cr, get_a_bundle_colour (i - c.begin()), x, 0, ARDOUR::BundleChannel (*i, j));
x += column_width();
}
} }
} }
} }
@ -312,7 +279,78 @@ PortMatrixColumnLabels::port_name_shape (double xoff, double yoff) const
} }
void void
PortMatrixColumnLabels::render_channel_name (cairo_t* cr, Gdk::Color colour, double xoff, double yoff, ARDOUR::BundleChannel const &bc) PortMatrixColumnLabels::render_bundle_name (
cairo_t* cr, Gdk::Color colour, double xoff, double yoff, boost::shared_ptr<ARDOUR::Bundle> b
)
{
set_source_rgb (cr, colour);
double w = 0;
if (_matrix->show_only_bundles()) {
w = column_width ();
} else {
w = b->nchannels() * column_width();
}
double x_ = xoff;
uint32_t y = yoff;
if (_matrix->arrangement() == PortMatrix::TOP_TO_RIGHT) {
y += _height;
} else {
y += slanted_height();
}
double y_ = y;
cairo_move_to (cr, x_, y_);
x_ += w;
cairo_line_to (cr, x_, y_);
x_ += slanted_height() / tan (angle ());
y_ -= slanted_height();
cairo_line_to (cr, x_, y_);
x_ -= w;
cairo_line_to (cr, x_, y_);
cairo_line_to (cr, xoff, y);
cairo_fill_preserve (cr);
set_source_rgb (cr, background_colour());
cairo_set_line_width (cr, label_border_width());
cairo_stroke (cr);
set_source_rgb (cr, text_colour());
if (_matrix->arrangement() == PortMatrix::TOP_TO_RIGHT) {
double rl = 0;
if (_matrix->show_only_bundles()) {
rl = name_pad();
} else {
rl = 3 * name_pad() + _longest_channel_name;
}
cairo_move_to (
cr,
xoff + basic_text_x_pos (0) + rl * cos (angle()),
yoff + _height - rl * sin (angle())
);
} else {
cairo_move_to (
cr,
xoff + basic_text_x_pos (0),
yoff + slanted_height() - name_pad() * sin (angle())
);
}
cairo_save (cr);
cairo_rotate (cr, -angle());
cairo_show_text (cr, b->name().c_str());
cairo_restore (cr);
}
void
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); std::vector<std::pair<double, double> > const shape = port_name_shape (xoff, yoff);
@ -366,11 +404,18 @@ PortMatrixColumnLabels::channel_x (ARDOUR::BundleChannel const &bc) const
ARDOUR::BundleList::const_iterator i = _matrix->columns()->bundles().begin(); ARDOUR::BundleList::const_iterator i = _matrix->columns()->bundles().begin();
while (i != _matrix->columns()->bundles().end() && *i != bc.bundle) { while (i != _matrix->columns()->bundles().end() && *i != bc.bundle) {
n += (*i)->nchannels (); if (_matrix->show_only_bundles()) {
n += 1;
} else {
n += (*i)->nchannels ();
}
++i; ++i;
} }
n += bc.channel; if (!_matrix->show_only_bundles()) {
n += bc.channel;
}
return n * column_width(); return n * column_width();
} }
@ -383,11 +428,25 @@ PortMatrixColumnLabels::channel_y (ARDOUR::BundleChannel const &bc) const
void void
PortMatrixColumnLabels::queue_draw_for (ARDOUR::BundleChannel const & bc) PortMatrixColumnLabels::queue_draw_for (ARDOUR::BundleChannel const & bc)
{ {
if (bc.bundle) { if (!bc.bundle) {
return;
}
if (_matrix->show_only_bundles()) {
_body->queue_draw_area (
component_to_parent_x (channel_x (bc)),
component_to_parent_y (0),
column_width() + _height * tan (angle()),
_height
);
} else {
double const x = channel_x (bc); double const x = channel_x (bc);
double const lc = _longest_channel_name + name_pad(); double const lc = _longest_channel_name + name_pad();
double const h = lc * sin (angle ()) + column_width() * sin (angle()) * cos (angle()); double const h = lc * sin (angle ()) + column_width() * sin (angle()) * cos (angle());
if (_matrix->arrangement() == PortMatrix::TOP_TO_RIGHT) { if (_matrix->arrangement() == PortMatrix::TOP_TO_RIGHT) {
_body->queue_draw_area ( _body->queue_draw_area (

View file

@ -45,6 +45,7 @@ public:
void mouseover_changed (PortMatrixNode const &); void mouseover_changed (PortMatrixNode const &);
private: private:
void render_bundle_name (cairo_t *, Gdk::Color, double, double, boost::shared_ptr<ARDOUR::Bundle>);
void render_channel_name (cairo_t *, Gdk::Color, double, double, ARDOUR::BundleChannel const &); void render_channel_name (cairo_t *, Gdk::Color, double, double, ARDOUR::BundleChannel const &);
double channel_x (ARDOUR::BundleChannel const &) const; double channel_x (ARDOUR::BundleChannel const &) const;
double channel_y (ARDOUR::BundleChannel const &) const; double channel_y (ARDOUR::BundleChannel const &) const;

View file

@ -42,6 +42,7 @@ public:
virtual void mouseover_changed (PortMatrixNode const &) = 0; virtual void mouseover_changed (PortMatrixNode const &) = 0;
virtual void draw_extra (cairo_t *) = 0; virtual void draw_extra (cairo_t *) = 0;
void set_show_ports (bool);
void setup (); void setup ();
GdkPixmap* get_pixmap (GdkDrawable *); GdkPixmap* get_pixmap (GdkDrawable *);
std::pair<uint32_t, uint32_t> dimensions (); std::pair<uint32_t, uint32_t> dimensions ();

View file

@ -36,14 +36,22 @@ PortMatrixGrid::compute_dimensions ()
{ {
_width = 0; _width = 0;
ARDOUR::BundleList const c = _matrix->columns()->bundles(); ARDOUR::BundleList const c = _matrix->columns()->bundles();
for (ARDOUR::BundleList::const_iterator i = c.begin(); i != c.end(); ++i) { if (_matrix->show_only_bundles()) {
_width += (*i)->nchannels() * column_width(); _width = c.size() * column_width();
} else {
for (ARDOUR::BundleList::const_iterator i = c.begin(); i != c.end(); ++i) {
_width += (*i)->nchannels() * column_width();
}
} }
_height = 0; _height = 0;
ARDOUR::BundleList const r = _matrix->rows()->bundles(); ARDOUR::BundleList const r = _matrix->rows()->bundles();
for (ARDOUR::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) { if (_matrix->show_only_bundles()) {
_height += (*i)->nchannels() * row_height(); _height = r.size() * column_width();
} else {
for (ARDOUR::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) {
_height += (*i)->nchannels() * row_height();
}
} }
} }
@ -64,12 +72,14 @@ PortMatrixGrid::render (cairo_t* cr)
ARDOUR::BundleList const c = _matrix->columns()->bundles(); ARDOUR::BundleList const c = _matrix->columns()->bundles();
for (ARDOUR::BundleList::size_type i = 0; i < c.size(); ++i) { for (ARDOUR::BundleList::size_type i = 0; i < c.size(); ++i) {
cairo_set_line_width (cr, thin_grid_line_width()); if (!_matrix->show_only_bundles()) {
for (uint32_t j = 1; j < c[i]->nchannels(); ++j) { cairo_set_line_width (cr, thin_grid_line_width());
x += column_width(); for (uint32_t j = 1; j < c[i]->nchannels(); ++j) {
cairo_move_to (cr, x, 0); x += column_width();
cairo_line_to (cr, x, _height); cairo_move_to (cr, x, 0);
cairo_stroke (cr); cairo_line_to (cr, x, _height);
cairo_stroke (cr);
}
} }
if (i < (c.size() - 1)) { if (i < (c.size() - 1)) {
@ -89,12 +99,14 @@ PortMatrixGrid::render (cairo_t* cr)
ARDOUR::BundleList const r = _matrix->rows()->bundles(); ARDOUR::BundleList const r = _matrix->rows()->bundles();
for (ARDOUR::BundleList::size_type i = 0; i < r.size(); ++i) { for (ARDOUR::BundleList::size_type i = 0; i < r.size(); ++i) {
cairo_set_line_width (cr, thin_grid_line_width()); if (!_matrix->show_only_bundles()) {
for (uint32_t j = 1; j < r[i]->nchannels(); ++j) { cairo_set_line_width (cr, thin_grid_line_width());
y += row_height(); for (uint32_t j = 1; j < r[i]->nchannels(); ++j) {
cairo_move_to (cr, 0, y); y += row_height();
cairo_line_to (cr, grid_width, y); cairo_move_to (cr, 0, y);
cairo_stroke (cr); cairo_line_to (cr, grid_width, y);
cairo_stroke (cr);
}
} }
if (i < (r.size() - 1)) { if (i < (r.size() - 1)) {
@ -110,67 +122,108 @@ PortMatrixGrid::render (cairo_t* cr)
uint32_t bx = 0; uint32_t bx = 0;
uint32_t by = 0; uint32_t by = 0;
for (ARDOUR::BundleList::const_iterator i = c.begin(); i < c.end(); ++i) {
by = 0;
for (ARDOUR::BundleList::const_iterator j = r.begin(); j < r.end(); ++j) {
x = bx; if (_matrix->show_only_bundles()) {
for (uint32_t k = 0; k < (*i)->nchannels (); k++) {
y = by; for (ARDOUR::BundleList::const_iterator i = c.begin(); i < c.end(); ++i) {
for (uint32_t l = 0; l < (*j)->nchannels (); ++l) { by = 0;
for (ARDOUR::BundleList::const_iterator j = r.begin(); j < r.end(); ++j) {
ARDOUR::BundleChannel c[2]; PortMatrixNode::State s = bundle_to_bundle_state (*i, *j);
c[_matrix->column_index()] = ARDOUR::BundleChannel (*i, k); switch (s) {
c[_matrix->row_index()] = ARDOUR::BundleChannel (*j, l); case PortMatrixNode::UNKNOWN:
draw_unknown_indicator (cr, bx, by);
PortMatrix::State const s = _matrix->get_state (c); break;
case PortMatrixNode::ASSOCIATED:
switch (s) { draw_association_indicator (cr, bx, by);
case PortMatrix::ASSOCIATED: break;
set_source_rgba (cr, association_colour(), 0.5); case PortMatrixNode::PARTIAL:
cairo_arc ( draw_association_indicator (cr, bx, by, 0.5);
cr, break;
x + column_width() / 2,
y + column_width() / 2,
(column_width() - (2 * connection_indicator_pad())) / 2,
0,
2 * M_PI
);
cairo_fill (cr);
break;
case PortMatrix::UNKNOWN:
set_source_rgba (cr, unknown_colour(), 0.5);
cairo_rectangle (
cr,
x + thick_grid_line_width(),
y + thick_grid_line_width(),
column_width() - 2 * thick_grid_line_width(),
row_height() - 2 * thick_grid_line_width()
);
cairo_fill (cr);
break;
case PortMatrix::NOT_ASSOCIATED:
break;
}
y += row_height();
} }
x += column_width();
by += row_height();
} }
by += (*j)->nchannels () * row_height(); bx += column_width();
}
} else {
for (ARDOUR::BundleList::const_iterator i = c.begin(); i < c.end(); ++i) {
by = 0;
for (ARDOUR::BundleList::const_iterator j = r.begin(); j < r.end(); ++j) {
x = bx;
for (uint32_t k = 0; k < (*i)->nchannels (); ++k) {
y = by;
for (uint32_t l = 0; l < (*j)->nchannels (); ++l) {
ARDOUR::BundleChannel c[2];
c[_matrix->column_index()] = ARDOUR::BundleChannel (*i, k);
c[_matrix->row_index()] = ARDOUR::BundleChannel (*j, l);
PortMatrixNode::State const s = _matrix->get_state (c);
switch (s) {
case PortMatrixNode::ASSOCIATED:
draw_association_indicator (cr, x, y);
break;
case PortMatrixNode::UNKNOWN:
draw_unknown_indicator (cr, x, y);
break;
case PortMatrixNode::NOT_ASSOCIATED:
break;
}
y += row_height();
}
x += column_width();
}
by += (*j)->nchannels () * row_height();
}
bx += (*i)->nchannels () * column_width();
} }
bx += (*i)->nchannels () * column_width();
} }
} }
void
PortMatrixGrid::draw_association_indicator (cairo_t* cr, uint32_t x, uint32_t y, double p)
{
set_source_rgba (cr, association_colour(), 0.5);
cairo_arc (
cr,
x + column_width() / 2,
y + column_width() / 2,
(column_width() - (2 * connection_indicator_pad())) / 2,
0,
p * 2 * M_PI
);
cairo_fill (cr);
}
void
PortMatrixGrid::draw_unknown_indicator (cairo_t* cr, uint32_t x, uint32_t y)
{
set_source_rgba (cr, unknown_colour(), 0.5);
cairo_rectangle (
cr,
x + thick_grid_line_width(),
y + thick_grid_line_width(),
column_width() - 2 * thick_grid_line_width(),
row_height() - 2 * thick_grid_line_width()
);
cairo_fill (cr);
}
PortMatrixNode PortMatrixNode
PortMatrixGrid::position_to_node (double x, double y) const PortMatrixGrid::position_to_node (double x, double y) const
@ -187,12 +240,26 @@ PortMatrixGrid::position_to_channel (double p, ARDOUR::BundleList const& bundles
{ {
uint32_t pos = p / inc; uint32_t pos = p / inc;
for (ARDOUR::BundleList::const_iterator i = bundles.begin(); i != bundles.end(); ++i) { if (_matrix->show_only_bundles()) {
if (pos < (*i)->nchannels()) {
return ARDOUR::BundleChannel (*i, pos); for (ARDOUR::BundleList::const_iterator i = bundles.begin(); i != bundles.end(); ++i) {
} else { if (pos == 0) {
pos -= (*i)->nchannels(); return ARDOUR::BundleChannel (*i, 0);
} else {
pos--;
}
} }
} else {
for (ARDOUR::BundleList::const_iterator i = bundles.begin(); i != bundles.end(); ++i) {
if (pos < (*i)->nchannels()) {
return ARDOUR::BundleChannel (*i, pos);
} else {
pos -= (*i)->nchannels();
}
}
} }
return ARDOUR::BundleChannel (boost::shared_ptr<ARDOUR::Bundle> (), 0); return ARDOUR::BundleChannel (boost::shared_ptr<ARDOUR::Bundle> (), 0);
@ -209,7 +276,13 @@ PortMatrixGrid::channel_position (
ARDOUR::BundleList::const_iterator i = bundles.begin (); ARDOUR::BundleList::const_iterator i = bundles.begin ();
while (i != bundles.end() && *i != bc.bundle) { while (i != bundles.end() && *i != bc.bundle) {
p += inc * (*i)->nchannels();
if (_matrix->show_only_bundles()) {
p += inc;
} else {
p += inc * (*i)->nchannels();
}
++i; ++i;
} }
@ -226,29 +299,51 @@ void
PortMatrixGrid::button_press (double x, double y, int b) PortMatrixGrid::button_press (double x, double y, int b)
{ {
PortMatrixNode const node = position_to_node (x, y); PortMatrixNode const node = position_to_node (x, y);
if (_matrix->show_only_bundles()) {
PortMatrixNode::State const s = bundle_to_bundle_state (node.column.bundle, node.row.bundle);
for (uint32_t i = 0; i < node.column.bundle->nchannels(); ++i) {
for (uint32_t j = 0; j < node.row.bundle->nchannels(); ++j) {
ARDOUR::BundleChannel c[2];
c[_matrix->column_index()] = ARDOUR::BundleChannel (node.column.bundle, i);
c[_matrix->row_index()] = ARDOUR::BundleChannel (node.row.bundle, j);
if (s == PortMatrixNode::NOT_ASSOCIATED || s == PortMatrixNode::PARTIAL) {
_matrix->set_state (c, i == j);
} else {
_matrix->set_state (c, false);
}
}
}
} else {
if (node.row.bundle && node.column.bundle) { if (node.row.bundle && node.column.bundle) {
ARDOUR::BundleChannel c[2];
c[_matrix->row_index()] = node.row;
c[_matrix->column_index()] = node.column;
PortMatrix::State const s = _matrix->get_state (c);
if (s == PortMatrix::ASSOCIATED || s == PortMatrix::NOT_ASSOCIATED) {
bool const n = !(s == PortMatrix::ASSOCIATED);
ARDOUR::BundleChannel c[2]; ARDOUR::BundleChannel c[2];
c[_matrix->row_index()] = node.row; c[_matrix->row_index()] = node.row;
c[_matrix->column_index()] = node.column; c[_matrix->column_index()] = node.column;
_matrix->set_state (c, n); PortMatrixNode::State const s = _matrix->get_state (c);
if (s == PortMatrixNode::ASSOCIATED || s == PortMatrixNode::NOT_ASSOCIATED) {
bool const n = !(s == PortMatrixNode::ASSOCIATED);
ARDOUR::BundleChannel c[2];
c[_matrix->row_index()] = node.row;
c[_matrix->column_index()] = node.column;
_matrix->set_state (c, n);
}
} }
require_render ();
_body->queue_draw ();
} }
require_render ();
_body->queue_draw ();
} }
void void
@ -352,3 +447,55 @@ PortMatrixGrid::parent_to_component_y (double y) const
return y + _body->yoffset() - _parent_rectangle.get_y(); return y + _body->yoffset() - _parent_rectangle.get_y();
} }
PortMatrixNode::State
PortMatrixGrid::bundle_to_bundle_state (boost::shared_ptr<ARDOUR::Bundle> a, boost::shared_ptr<ARDOUR::Bundle> b) const
{
bool have_unknown = false;
bool have_off_diagonal_association = false;
bool have_diagonal_association = false;
bool have_diagonal_not_association = false;
for (uint32_t i = 0; i < a->nchannels (); ++i) {
for (uint32_t j = 0; j < b->nchannels (); ++j) {
ARDOUR::BundleChannel c[2];
c[_matrix->column_index()] = ARDOUR::BundleChannel (a, i);
c[_matrix->row_index()] = ARDOUR::BundleChannel (b, j);
PortMatrixNode::State const s = _matrix->get_state (c);
switch (s) {
case PortMatrixNode::ASSOCIATED:
if (i == j) {
have_diagonal_association = true;
} else {
have_off_diagonal_association = true;
}
break;
case PortMatrixNode::UNKNOWN:
have_unknown = true;
break;
case PortMatrixNode::NOT_ASSOCIATED:
if (i == j) {
have_diagonal_not_association = true;
}
break;
}
}
}
if (have_unknown) {
return PortMatrixNode::UNKNOWN;
} else if (have_diagonal_association && !have_off_diagonal_association && !have_diagonal_not_association) {
return PortMatrixNode::ASSOCIATED;
} else if (!have_diagonal_association && !have_off_diagonal_association) {
return PortMatrixNode::NOT_ASSOCIATED;
}
return PortMatrixNode::PARTIAL;
}

View file

@ -59,6 +59,10 @@ private:
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, ARDOUR::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_unknown_indicator (cairo_t *, uint32_t, uint32_t);
PortMatrixNode::State bundle_to_bundle_state (boost::shared_ptr<ARDOUR::Bundle>, boost::shared_ptr<ARDOUR::Bundle>) const;
}; };
#endif #endif

View file

@ -19,19 +19,30 @@
#include "ardour/bundle.h" #include "ardour/bundle.h"
#include "port_matrix_labels.h" #include "port_matrix_labels.h"
#include "port_matrix.h"
void void
PortMatrixLabels::draw_extra (cairo_t* cr) PortMatrixLabels::draw_extra (cairo_t* cr)
{ {
for (std::vector<ARDOUR::BundleChannel>::const_iterator i = _channel_highlights.begin(); i != _channel_highlights.end(); ++i) { for (std::vector<ARDOUR::BundleChannel>::const_iterator i = _channel_highlights.begin(); i != _channel_highlights.end(); ++i) {
render_channel_name ( if (_matrix->show_only_bundles()) {
cr, render_bundle_name (
highlighted_channel_colour(), cr,
component_to_parent_x (channel_x (*i)), highlighted_channel_colour(),
component_to_parent_y (channel_y (*i)), component_to_parent_x (channel_x (*i)),
*i component_to_parent_y (channel_y (*i)),
); i->bundle
);
} else {
render_channel_name (
cr,
highlighted_channel_colour(),
component_to_parent_x (channel_x (*i)),
component_to_parent_y (channel_y (*i)),
*i
);
}
} }
} }

View file

@ -39,6 +39,7 @@ public:
private: private:
virtual void render_channel_name (cairo_t *, Gdk::Color, double, double, ARDOUR::BundleChannel const &) = 0; virtual void render_channel_name (cairo_t *, Gdk::Color, double, double, ARDOUR::BundleChannel const &) = 0;
virtual void render_bundle_name (cairo_t *, Gdk::Color, double, double, boost::shared_ptr<ARDOUR::Bundle>) = 0;
virtual double channel_x (ARDOUR::BundleChannel const &) const = 0; virtual double channel_x (ARDOUR::BundleChannel const &) const = 0;
virtual double channel_y (ARDOUR::BundleChannel const &) const = 0; virtual double channel_y (ARDOUR::BundleChannel const &) const = 0;
virtual void queue_draw_for (ARDOUR::BundleChannel const &) = 0; virtual void queue_draw_for (ARDOUR::BundleChannel const &) = 0;

View file

@ -58,7 +58,11 @@ PortMatrixRowLabels::compute_dimensions ()
_longest_bundle_name = ext.width; _longest_bundle_name = ext.width;
} }
_height += (*i)->nchannels() * row_height(); if (_matrix->show_only_bundles()) {
_height += row_height ();
} else {
_height += (*i)->nchannels() * row_height();
}
} }
_highest_group_name = 0; _highest_group_name = 0;
@ -76,9 +80,13 @@ PortMatrixRowLabels::compute_dimensions ()
gdk_pixmap_unref (pm); gdk_pixmap_unref (pm);
_width = _highest_group_name + _width = _highest_group_name +
_longest_port_name +
_longest_bundle_name + _longest_bundle_name +
name_pad() * 6; name_pad() * 4;
if (!_matrix->show_only_bundles()) {
_width += _longest_port_name;
_width += name_pad() * 2;
}
} }
@ -109,7 +117,12 @@ PortMatrixRowLabels::render (cairo_t* cr)
} }
/* compute height of this group */ /* compute height of this group */
double h = (*i)->total_channels () * row_height(); double h = 0;
if (_matrix->show_only_bundles()) {
h = (*i)->bundles().size() * row_height();
} else {
h = (*i)->total_channels () * row_height();
}
/* rectangle */ /* rectangle */
set_source_rgb (cr, get_a_group_colour (g)); set_source_rgb (cr, get_a_group_colour (g));
@ -134,50 +147,24 @@ PortMatrixRowLabels::render (cairo_t* cr)
/* BUNDLE NAMES */ /* BUNDLE NAMES */
x = 0;
if (_matrix->arrangement() == PortMatrix::LEFT_TO_BOTTOM) {
x = _highest_group_name + 2 * name_pad();
} else {
x = _longest_port_name + name_pad() * 2;
}
y = 0; y = 0;
ARDOUR::BundleList const r = _matrix->rows()->bundles(); ARDOUR::BundleList const r = _matrix->rows()->bundles();
for (ARDOUR::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) { 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);
Gdk::Color const colour = get_a_bundle_colour (i - r.begin ()); int const n = _matrix->show_only_bundles() ? 1 : (*i)->nchannels();
set_source_rgb (cr, colour); y += row_height() * n;
cairo_rectangle (cr, x, y, _longest_bundle_name + name_pad() * 2, row_height() * (*i)->nchannels());
cairo_fill_preserve (cr);
set_source_rgb (cr, background_colour());
cairo_set_line_width (cr, label_border_width ());
cairo_stroke (cr);
double off = 0;
if ((*i)->nchannels () > 0) {
/* use the extent of our first channel name so that the bundle name is vertically aligned with it */
cairo_text_extents_t ext;
cairo_text_extents (cr, (*i)->channel_name(0).c_str(), &ext);
off = (row_height() - ext.height) / 2;
} else {
off = row_height() / 2;
}
set_source_rgb (cr, text_colour());
cairo_move_to (cr, x + name_pad(), y + name_pad() + off);
cairo_show_text (cr, (*i)->name().c_str());
y += row_height() * (*i)->nchannels ();
} }
/* PORT NAMES */ /* PORT NAMES */
y = 0; if (!_matrix->show_only_bundles()) {
for (ARDOUR::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) { y = 0;
for (uint32_t j = 0; j < (*i)->nchannels(); ++j) { for (ARDOUR::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)->nchannels(); ++j) {
y += row_height(); render_channel_name (cr, get_a_bundle_colour (i - r.begin()), 0, y, ARDOUR::BundleChannel (*i, j));
y += row_height();
}
} }
} }
} }
@ -231,6 +218,25 @@ PortMatrixRowLabels::parent_to_component_y (double y) const
return y + _body->yoffset() - _parent_rectangle.get_y(); return y + _body->yoffset() - _parent_rectangle.get_y();
} }
double
PortMatrixRowLabels::bundle_name_x () const
{
double x = 0;
if (_matrix->arrangement() == PortMatrix::LEFT_TO_BOTTOM) {
x = _highest_group_name + 2 * name_pad();
} else {
if (_matrix->show_only_bundles()) {
x = 0;
} else {
x = _longest_port_name + name_pad() * 2;
}
}
return x;
}
double double
PortMatrixRowLabels::port_name_x () const PortMatrixRowLabels::port_name_x () const
{ {
@ -243,6 +249,35 @@ PortMatrixRowLabels::port_name_x () const
return 0; return 0;
} }
void
PortMatrixRowLabels::render_bundle_name (
cairo_t* cr, Gdk::Color colour, double xoff, double yoff, boost::shared_ptr<ARDOUR::Bundle> b
)
{
double const x = bundle_name_x ();
int const n = _matrix->show_only_bundles() ? 1 : b->nchannels();
set_source_rgb (cr, colour);
cairo_rectangle (cr, xoff + x, yoff, _longest_bundle_name + name_pad() * 2, row_height() * n);
cairo_fill_preserve (cr);
set_source_rgb (cr, background_colour());
cairo_set_line_width (cr, label_border_width ());
cairo_stroke (cr);
double const off = row_height() / 2;
// if ((*i)->nchannels () > 0 && !_matrix->show_only_bundles()) {
// /* use the extent of our first channel name so that the bundle name is vertically aligned with it */
// cairo_text_extents_t ext;
// cairo_text_extents (cr, (*i)->channel_name(0).c_str(), &ext);
// off = (row_height() - ext.height) / 2;
// }
set_source_rgb (cr, text_colour());
cairo_move_to (cr, xoff + x + name_pad(), yoff + name_pad() + off);
cairo_show_text (cr, b->name().c_str());
}
void void
PortMatrixRowLabels::render_channel_name ( PortMatrixRowLabels::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
@ -277,11 +312,18 @@ PortMatrixRowLabels::channel_y (ARDOUR::BundleChannel const& bc) const
ARDOUR::BundleList::const_iterator i = _matrix->rows()->bundles().begin(); ARDOUR::BundleList::const_iterator i = _matrix->rows()->bundles().begin();
while (i != _matrix->rows()->bundles().end() && *i != bc.bundle) { while (i != _matrix->rows()->bundles().end() && *i != bc.bundle) {
n += (*i)->nchannels (); if (_matrix->show_only_bundles()) {
n += 1;
} else {
n += (*i)->nchannels ();
}
++i; ++i;
} }
if (!_matrix->show_only_bundles()) {
n += bc.channel;
}
n += bc.channel;
return n * row_height(); return n * row_height();
} }
@ -290,12 +332,21 @@ PortMatrixRowLabels::queue_draw_for (ARDOUR::BundleChannel const & bc)
{ {
if (bc.bundle) { if (bc.bundle) {
_body->queue_draw_area ( if (_matrix->show_only_bundles()) {
component_to_parent_x (port_name_x()), _body->queue_draw_area (
component_to_parent_y (channel_y (bc)), component_to_parent_x (bundle_name_x()),
_longest_port_name + name_pad() * 2, component_to_parent_y (channel_y (bc)),
row_height() _longest_bundle_name + name_pad() * 2,
); row_height()
);
} else {
_body->queue_draw_area (
component_to_parent_x (port_name_x()),
component_to_parent_y (channel_y (bc)),
_longest_port_name + name_pad() * 2,
row_height()
);
}
} }
} }

View file

@ -53,6 +53,7 @@ public:
private: private:
void render_channel_name (cairo_t *, Gdk::Color, double, double, ARDOUR::BundleChannel const &); void render_channel_name (cairo_t *, Gdk::Color, double, double, ARDOUR::BundleChannel const &);
void render_bundle_name (cairo_t *, Gdk::Color, double, double, boost::shared_ptr<ARDOUR::Bundle>);
double channel_x (ARDOUR::BundleChannel const &) const; double channel_x (ARDOUR::BundleChannel const &) const;
double channel_y (ARDOUR::BundleChannel const &) const; double channel_y (ARDOUR::BundleChannel const &) const;
@ -63,6 +64,7 @@ private:
void queue_draw_for (ARDOUR::BundleChannel const &); void queue_draw_for (ARDOUR::BundleChannel const &);
double port_name_x () const; double port_name_x () const;
void maybe_popup_context_menu (double, double, uint32_t); void maybe_popup_context_menu (double, double, uint32_t);
double bundle_name_x () const;
double _longest_port_name; double _longest_port_name;
double _longest_bundle_name; double _longest_bundle_name;

View file

@ -36,6 +36,13 @@ struct PortMatrixNode
ARDOUR::BundleChannel row; ARDOUR::BundleChannel row;
ARDOUR::BundleChannel column; ARDOUR::BundleChannel column;
enum State {
ASSOCIATED, ///< the ports are associated
NOT_ASSOCIATED, ///< the ports are not associated
UNKNOWN, ///< we don't know anything about these two ports' relationship
PARTIAL ///< used when we are examining bundles; the bundles are partially associated
};
}; };
#endif #endif