summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2009-05-03 14:31:42 +0000
committerCarl Hetherington <carl@carlh.net>2009-05-03 14:31:42 +0000
commit1ae39840b3e7b1740b44e5889983e93d837f8e90 (patch)
tree3d0e33c90ae040fff6f4b30250d0a22d0ce2c0c8 /gtk2_ardour
parent7e48118bf16702dc174875510b935f37290d56a7 (diff)
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
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/bundle_manager.cc6
-rw-r--r--gtk2_ardour/bundle_manager.h2
-rw-r--r--gtk2_ardour/global_port_matrix.cc24
-rw-r--r--gtk2_ardour/global_port_matrix.h5
-rw-r--r--gtk2_ardour/io_selector.cc8
-rw-r--r--gtk2_ardour/io_selector.h2
-rw-r--r--gtk2_ardour/port_matrix.cc40
-rw-r--r--gtk2_ardour/port_matrix.h21
-rw-r--r--gtk2_ardour/port_matrix_body.cc2
-rw-r--r--gtk2_ardour/port_matrix_column_labels.cc193
-rw-r--r--gtk2_ardour/port_matrix_column_labels.h1
-rw-r--r--gtk2_ardour/port_matrix_component.h1
-rw-r--r--gtk2_ardour/port_matrix_grid.cc315
-rw-r--r--gtk2_ardour/port_matrix_grid.h4
-rw-r--r--gtk2_ardour/port_matrix_labels.cc25
-rw-r--r--gtk2_ardour/port_matrix_labels.h1
-rw-r--r--gtk2_ardour/port_matrix_row_labels.cc147
-rw-r--r--gtk2_ardour/port_matrix_row_labels.h2
-rw-r--r--gtk2_ardour/port_matrix_types.h7
19 files changed, 555 insertions, 251 deletions
diff --git a/gtk2_ardour/bundle_manager.cc b/gtk2_ardour/bundle_manager.cc
index 91b06e3df1..16d9500d51 100644
--- a/gtk2_ardour/bundle_manager.cc
+++ b/gtk2_ardour/bundle_manager.cc
@@ -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
{
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) {
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
diff --git a/gtk2_ardour/bundle_manager.h b/gtk2_ardour/bundle_manager.h
index 266e9eadad..2d0f41e10e 100644
--- a/gtk2_ardour/bundle_manager.h
+++ b/gtk2_ardour/bundle_manager.h
@@ -37,7 +37,7 @@ class BundleEditorMatrix : public PortMatrix
BundleEditorMatrix (ARDOUR::Session &, boost::shared_ptr<ARDOUR::Bundle>);
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>);
bool can_remove_channels (int d) const {
return d == OURS;
diff --git a/gtk2_ardour/global_port_matrix.cc b/gtk2_ardour/global_port_matrix.cc
index bc63237244..b2e6568a30 100644
--- a/gtk2_ardour/global_port_matrix.cc
+++ b/gtk2_ardour/global_port_matrix.cc
@@ -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
{
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()) {
/* we're looking at a bundle with no parts associated with this channel,
so nothing to connect */
- return UNKNOWN;
+ return PortMatrixNode::UNKNOWN;
}
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 */
if (!p && !q) {
- return UNKNOWN;
+ return PortMatrixNode::UNKNOWN;
}
if (p && p->connected_to (*j) == false) {
- return NOT_ASSOCIATED;
+ return PortMatrixNode::NOT_ASSOCIATED;
} 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)
: _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.signal_clicked().connect (sigc::mem_fun (_port_matrix, &GlobalPortMatrix::setup_all_ports));
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);
vbox->pack_start (_port_matrix);
@@ -131,3 +135,9 @@ GlobalPortMatrixWindow::GlobalPortMatrixWindow (ARDOUR::Session& s, ARDOUR::Data
add (*vbox);
show_all ();
}
+
+void
+GlobalPortMatrixWindow::show_ports_toggled ()
+{
+ _port_matrix.set_show_only_bundles (!_show_ports_button.get_active());
+}
diff --git a/gtk2_ardour/global_port_matrix.h b/gtk2_ardour/global_port_matrix.h
index 5a00ed4c75..98b898f8aa 100644
--- a/gtk2_ardour/global_port_matrix.h
+++ b/gtk2_ardour/global_port_matrix.h
@@ -33,7 +33,7 @@ public:
void setup_ports (int);
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>) {}
bool can_remove_channels (int d) const {
@@ -63,8 +63,11 @@ public:
GlobalPortMatrixWindow (ARDOUR::Session&, ARDOUR::DataType);
private:
+ void show_ports_toggled ();
+
GlobalPortMatrix _port_matrix;
Gtk::Button _rescan_button;
+ Gtk::CheckButton _show_ports_button;
};
diff --git a/gtk2_ardour/io_selector.cc b/gtk2_ardour/io_selector.cc
index fb2c66a4be..93ade90dca 100644
--- a/gtk2_ardour/io_selector.cc
+++ b/gtk2_ardour/io_selector.cc
@@ -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
{
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()) {
/* we're looking at a bundle with no parts associated with this channel,
so nothing to connect */
- return UNKNOWN;
+ return PortMatrixNode::UNKNOWN;
}
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 any one thing is not connected, all bets are off */
- return NOT_ASSOCIATED;
+ return PortMatrixNode::NOT_ASSOCIATED;
}
}
}
- return ASSOCIATED;
+ return PortMatrixNode::ASSOCIATED;
}
uint32_t
diff --git a/gtk2_ardour/io_selector.h b/gtk2_ardour/io_selector.h
index 9125a418ca..ccd3bc929f 100644
--- a/gtk2_ardour/io_selector.h
+++ b/gtk2_ardour/io_selector.h
@@ -33,7 +33,7 @@ class IOSelector : public PortMatrix
IOSelector (ARDOUR::Session&, boost::shared_ptr<ARDOUR::IO>, 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>);
bool can_remove_channels (int d) const {
diff --git a/gtk2_ardour/port_matrix.cc b/gtk2_ardour/port_matrix.cc
index 63779a6083..79256df6e0 100644
--- a/gtk2_ardour/port_matrix.cc
+++ b/gtk2_ardour/port_matrix.cc
@@ -37,7 +37,8 @@
* @param type Port type that we are handling.
*/
PortMatrix::PortMatrix (ARDOUR::Session& session, ARDOUR::DataType type)
- : _session (session),
+ : Gtk::Table (2, 2),
+ _session (session),
_type (type),
_column_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),
_row_index (0),
_column_index (1),
- _min_height_divisor (1)
+ _min_height_divisor (1),
+ _show_only_bundles (false)
{
_body = new PortMatrixBody (this);
@@ -147,15 +149,14 @@ PortMatrix::setup ()
_scroller_table.remove (*_body);
_scroller_table.remove (_hscroll);
- _main_hbox.remove (_scroller_table);
+ remove (_scroller_table);
if (_row_visibility_box_added) {
- _main_hbox.remove (_row_visibility_box);
+ remove (_row_visibility_box);
}
if (_column_visibility_box_added) {
remove (_column_visibility_box);
}
- remove (_main_hbox);
}
if (_column_index == 0) {
@@ -190,42 +191,38 @@ PortMatrix::setup ()
_scroller_table.attach (*_body, 0, 1, 1, 2);
_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) {
- _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;
} else {
_row_visibility_box_added = false;
}
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;
} else {
_column_visibility_box_added = false;
}
- pack_start (_main_hbox);
-
} else {
_scroller_table.attach (_vscroll, 0, 1, 0, 1, Gtk::SHRINK);
_scroller_table.attach (*_body, 1, 2, 0, 1);
_scroller_table.attach (_hscroll, 1, 2, 1, 2, Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK);
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;
} else {
_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) {
- 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;
} else {
_column_visibility_box_added = false;
@@ -294,7 +291,7 @@ PortMatrix::disassociate_all ()
ARDOUR::BundleChannel (*k, l)
};
- if (get_state (c) == ASSOCIATED) {
+ if (get_state (c) == PortMatrixNode::ASSOCIATED) {
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[1-dim] = ARDOUR::BundleChannel (*i, j);
- if (get_state (c) == ASSOCIATED) {
+ if (get_state (c) == PortMatrixNode::ASSOCIATED) {
set_state (c, false);
}
}
@@ -501,3 +498,12 @@ PortMatrix::setup_all_ports ()
setup_ports (0);
setup_ports (1);
}
+
+void
+PortMatrix::set_show_only_bundles (bool s)
+{
+ _show_only_bundles = s;
+ _body->setup ();
+ setup_scrollbars ();
+ queue_draw ();
+}
diff --git a/gtk2_ardour/port_matrix.h b/gtk2_ardour/port_matrix.h
index d397c5df05..531fdf6978 100644
--- a/gtk2_ardour/port_matrix.h
+++ b/gtk2_ardour/port_matrix.h
@@ -29,6 +29,7 @@
#include <boost/shared_ptr.hpp>
#include "ardour/bundle.h"
#include "port_group.h"
+#include "port_matrix_types.h"
/** 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
@@ -36,7 +37,7 @@
*
* 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
- * VBox that we inherit from.
+ * Table that we inherit from.
*/
namespace ARDOUR {
@@ -45,7 +46,7 @@ namespace ARDOUR {
class PortMatrixBody;
-class PortMatrix : public Gtk::VBox
+class PortMatrix : public Gtk::Table
{
public:
PortMatrix (ARDOUR::Session&, ARDOUR::DataType);
@@ -78,6 +79,12 @@ public:
return _arrangement;
}
+ bool show_only_bundles () const {
+ return _show_only_bundles;
+ }
+
+ void set_show_only_bundles (bool);
+
PortGroupList const * columns () const;
/** @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;
- 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].
* @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 void add_channel (boost::shared_ptr<ARDOUR::Bundle>) = 0;
@@ -161,7 +162,6 @@ private:
PortMatrixBody* _body;
Gtk::HScrollbar _hscroll;
Gtk::VScrollbar _vscroll;
- Gtk::HBox _main_hbox;
Gtk::HBox _column_visibility_box;
bool _column_visibility_box_added;
Gtk::Label _column_visibility_label;
@@ -177,6 +177,7 @@ private:
int _row_index;
int _column_index;
int _min_height_divisor;
+ bool _show_only_bundles;
};
#endif
diff --git a/gtk2_ardour/port_matrix_body.cc b/gtk2_ardour/port_matrix_body.cc
index 205e6d4bdd..75bf42c9b7 100644
--- a/gtk2_ardour/port_matrix_body.cc
+++ b/gtk2_ardour/port_matrix_body.cc
@@ -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 (uint32_t j = 0; j < (*i)->nchannels(); ++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()) {
_row_labels->add_channel_highlight (bc[1 - dim]);
} else {
diff --git a/gtk2_ardour/port_matrix_column_labels.cc b/gtk2_ardour/port_matrix_column_labels.cc
index 2790c0537e..5c1749c4bc 100644
--- a/gtk2_ardour/port_matrix_column_labels.cc
+++ b/gtk2_ardour/port_matrix_column_labels.cc
@@ -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;
@@ -93,9 +97,12 @@ PortMatrixColumnLabels::compute_dimensions ()
/* height of the whole thing */
- double const parallelogram_height =
- (_longest_bundle_name + _longest_channel_name + 4 * name_pad()) * sin (angle())
- + _highest_text * cos (angle());
+ int a = _longest_bundle_name + 4 * name_pad();
+ if (!_matrix->show_only_bundles()) {
+ a += _longest_channel_name;
+ }
+
+ double const parallelogram_height = a * sin (angle()) + _highest_text * cos (angle());
_height = parallelogram_height + _highest_group_name + 2 * name_pad();
@@ -139,7 +146,12 @@ PortMatrixColumnLabels::render (cairo_t* cr)
}
/* 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 */
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();
for (ARDOUR::BundleList::const_iterator i = c.begin (); i != c.end(); ++i) {
- Gdk::Color colour = get_a_bundle_colour (i - c.begin ());
- set_source_rgb (cr, colour);
+ render_bundle_name (cr, get_a_bundle_colour (i - c.begin ()), x, 0, *i);
- double const w = (*i)->nchannels() * column_width();
-
- double x_ = x;
-
- if (_matrix->arrangement() == PortMatrix::TOP_TO_RIGHT) {
- y = _height;
+ if (_matrix->show_only_bundles()) {
+ x += column_width();
} 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 */
- x = 0;
- for (ARDOUR::BundleList::const_iterator i = c.begin (); i != c.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));
- x += column_width();
+ if (!_matrix->show_only_bundles()) {
+ x = 0;
+ for (ARDOUR::BundleList::const_iterator i = c.begin (); i != c.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));
+ x += column_width();
+ }
}
}
}
@@ -312,7 +279,78 @@ PortMatrixColumnLabels::port_name_shape (double xoff, double yoff) const
}
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);
@@ -366,11 +404,18 @@ PortMatrixColumnLabels::channel_x (ARDOUR::BundleChannel const &bc) const
ARDOUR::BundleList::const_iterator i = _matrix->columns()->bundles().begin();
while (i != _matrix->columns()->bundles().end() && *i != bc.bundle) {
- n += (*i)->nchannels ();
+ if (_matrix->show_only_bundles()) {
+ n += 1;
+ } else {
+ n += (*i)->nchannels ();
+ }
++i;
}
- n += bc.channel;
+ if (!_matrix->show_only_bundles()) {
+ n += bc.channel;
+ }
+
return n * column_width();
}
@@ -383,11 +428,25 @@ PortMatrixColumnLabels::channel_y (ARDOUR::BundleChannel const &bc) const
void
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 lc = _longest_channel_name + name_pad();
double const h = lc * sin (angle ()) + column_width() * sin (angle()) * cos (angle());
+
if (_matrix->arrangement() == PortMatrix::TOP_TO_RIGHT) {
_body->queue_draw_area (
diff --git a/gtk2_ardour/port_matrix_column_labels.h b/gtk2_ardour/port_matrix_column_labels.h
index c58a1e5054..d4e06226b1 100644
--- a/gtk2_ardour/port_matrix_column_labels.h
+++ b/gtk2_ardour/port_matrix_column_labels.h
@@ -45,6 +45,7 @@ public:
void mouseover_changed (PortMatrixNode const &);
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 &);
double channel_x (ARDOUR::BundleChannel const &) const;
double channel_y (ARDOUR::BundleChannel const &) const;
diff --git a/gtk2_ardour/port_matrix_component.h b/gtk2_ardour/port_matrix_component.h
index 9eb2c566a5..6e1f37eae1 100644
--- a/gtk2_ardour/port_matrix_component.h
+++ b/gtk2_ardour/port_matrix_component.h
@@ -42,6 +42,7 @@ public:
virtual void mouseover_changed (PortMatrixNode const &) = 0;
virtual void draw_extra (cairo_t *) = 0;
+ void set_show_ports (bool);
void setup ();
GdkPixmap* get_pixmap (GdkDrawable *);
std::pair<uint32_t, uint32_t> dimensions ();
diff --git a/gtk2_ardour/port_matrix_grid.cc b/gtk2_ardour/port_matrix_grid.cc
index 6e7fad7091..bbf5447160 100644
--- a/gtk2_ardour/port_matrix_grid.cc
+++ b/gtk2_ardour/port_matrix_grid.cc
@@ -36,14 +36,22 @@ PortMatrixGrid::compute_dimensions ()
{
_width = 0;
ARDOUR::BundleList const c = _matrix->columns()->bundles();
- for (ARDOUR::BundleList::const_iterator i = c.begin(); i != c.end(); ++i) {
- _width += (*i)->nchannels() * column_width();
+ 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();
+ }
}
_height = 0;
ARDOUR::BundleList const r = _matrix->rows()->bundles();
- for (ARDOUR::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) {
- _height += (*i)->nchannels() * row_height();
+ 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();
+ }
}
}
@@ -64,12 +72,14 @@ PortMatrixGrid::render (cairo_t* cr)
ARDOUR::BundleList const c = _matrix->columns()->bundles();
for (ARDOUR::BundleList::size_type i = 0; i < c.size(); ++i) {
- cairo_set_line_width (cr, thin_grid_line_width());
- for (uint32_t j = 1; j < c[i]->nchannels(); ++j) {
- x += column_width();
- cairo_move_to (cr, x, 0);
- cairo_line_to (cr, x, _height);
- cairo_stroke (cr);
+ if (!_matrix->show_only_bundles()) {
+ cairo_set_line_width (cr, thin_grid_line_width());
+ for (uint32_t j = 1; j < c[i]->nchannels(); ++j) {
+ x += column_width();
+ cairo_move_to (cr, x, 0);
+ cairo_line_to (cr, x, _height);
+ cairo_stroke (cr);
+ }
}
if (i < (c.size() - 1)) {
@@ -89,12 +99,14 @@ PortMatrixGrid::render (cairo_t* cr)
ARDOUR::BundleList const r = _matrix->rows()->bundles();
for (ARDOUR::BundleList::size_type i = 0; i < r.size(); ++i) {
- cairo_set_line_width (cr, thin_grid_line_width());
- for (uint32_t j = 1; j < r[i]->nchannels(); ++j) {
- y += row_height();
- cairo_move_to (cr, 0, y);
- cairo_line_to (cr, grid_width, y);
- cairo_stroke (cr);
+ if (!_matrix->show_only_bundles()) {
+ cairo_set_line_width (cr, thin_grid_line_width());
+ for (uint32_t j = 1; j < r[i]->nchannels(); ++j) {
+ y += row_height();
+ cairo_move_to (cr, 0, y);
+ cairo_line_to (cr, grid_width, y);
+ cairo_stroke (cr);
+ }
}
if (i < (r.size() - 1)) {
@@ -110,67 +122,108 @@ PortMatrixGrid::render (cairo_t* cr)
uint32_t bx = 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;
- for (uint32_t k = 0; k < (*i)->nchannels (); k++) {
+ if (_matrix->show_only_bundles()) {
+
+ 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) {
+
+ PortMatrixNode::State s = bundle_to_bundle_state (*i, *j);
+ switch (s) {
+ case PortMatrixNode::UNKNOWN:
+ draw_unknown_indicator (cr, bx, by);
+ break;
+ case PortMatrixNode::ASSOCIATED:
+ draw_association_indicator (cr, bx, by);
+ break;
+ case PortMatrixNode::PARTIAL:
+ draw_association_indicator (cr, bx, by, 0.5);
+ break;
+ }
+
+ by += row_height();
+ }
+
+ bx += column_width();
+ }
- y = by;
- for (uint32_t l = 0; l < (*j)->nchannels (); ++l) {
+ } else {
- ARDOUR::BundleChannel c[2];
- c[_matrix->column_index()] = ARDOUR::BundleChannel (*i, k);
- c[_matrix->row_index()] = ARDOUR::BundleChannel (*j, l);
+ 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) {
- PortMatrix::State const s = _matrix->get_state (c);
+ y = by;
+ for (uint32_t l = 0; l < (*j)->nchannels (); ++l) {
- switch (s) {
- case PortMatrix::ASSOCIATED:
- 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,
- 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;
+ 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();
}
-
- y += row_height();
+
+ x += column_width();
}
- x += column_width();
+
+ by += (*j)->nchannels () * row_height();
}
- 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
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;
- 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();
+ if (_matrix->show_only_bundles()) {
+
+ for (ARDOUR::BundleList::const_iterator i = bundles.begin(); i != bundles.end(); ++i) {
+ if (pos == 0) {
+ 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);
@@ -209,7 +276,13 @@ PortMatrixGrid::channel_position (
ARDOUR::BundleList::const_iterator i = bundles.begin ();
while (i != bundles.end() && *i != bc.bundle) {
- p += inc * (*i)->nchannels();
+
+ if (_matrix->show_only_bundles()) {
+ p += inc;
+ } else {
+ p += inc * (*i)->nchannels();
+ }
+
++i;
}
@@ -226,29 +299,51 @@ void
PortMatrixGrid::button_press (double x, double y, int b)
{
PortMatrixNode const node = position_to_node (x, y);
-
- 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) {
+ if (_matrix->show_only_bundles()) {
- bool const n = !(s == PortMatrix::ASSOCIATED);
+ 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) {
+
ARDOUR::BundleChannel c[2];
c[_matrix->row_index()] = node.row;
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
@@ -352,3 +447,55 @@ PortMatrixGrid::parent_to_component_y (double y) const
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;
+}
+
+
diff --git a/gtk2_ardour/port_matrix_grid.h b/gtk2_ardour/port_matrix_grid.h
index 77a0a7eefc..4a05c3138d 100644
--- a/gtk2_ardour/port_matrix_grid.h
+++ b/gtk2_ardour/port_matrix_grid.h
@@ -59,6 +59,10 @@ private:
PortMatrixNode position_to_node (double, double) const;
ARDOUR::BundleChannel position_to_channel (double, ARDOUR::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);
+ PortMatrixNode::State bundle_to_bundle_state (boost::shared_ptr<ARDOUR::Bundle>, boost::shared_ptr<ARDOUR::Bundle>) const;
+
};
#endif
diff --git a/gtk2_ardour/port_matrix_labels.cc b/gtk2_ardour/port_matrix_labels.cc
index 2734a193ef..8b34b71ffb 100644
--- a/gtk2_ardour/port_matrix_labels.cc
+++ b/gtk2_ardour/port_matrix_labels.cc
@@ -19,19 +19,30 @@
#include "ardour/bundle.h"
#include "port_matrix_labels.h"
+#include "port_matrix.h"
void
PortMatrixLabels::draw_extra (cairo_t* cr)
{
for (std::vector<ARDOUR::BundleChannel>::const_iterator i = _channel_highlights.begin(); i != _channel_highlights.end(); ++i) {
- render_channel_name (
- cr,
- highlighted_channel_colour(),
- component_to_parent_x (channel_x (*i)),
- component_to_parent_y (channel_y (*i)),
- *i
- );
+ if (_matrix->show_only_bundles()) {
+ render_bundle_name (
+ cr,
+ highlighted_channel_colour(),
+ component_to_parent_x (channel_x (*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
+ );
+ }
}
}
diff --git a/gtk2_ardour/port_matrix_labels.h b/gtk2_ardour/port_matrix_labels.h
index fff734755c..9ace58b3e8 100644
--- a/gtk2_ardour/port_matrix_labels.h
+++ b/gtk2_ardour/port_matrix_labels.h
@@ -39,6 +39,7 @@ public:
private:
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_y (ARDOUR::BundleChannel const &) const = 0;
virtual void queue_draw_for (ARDOUR::BundleChannel const &) = 0;
diff --git a/gtk2_ardour/port_matrix_row_labels.cc b/gtk2_ardour/port_matrix_row_labels.cc
index 98b185591d..8334b7b44f 100644
--- a/gtk2_ardour/port_matrix_row_labels.cc
+++ b/gtk2_ardour/port_matrix_row_labels.cc
@@ -58,7 +58,11 @@ PortMatrixRowLabels::compute_dimensions ()
_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;
@@ -76,9 +80,13 @@ PortMatrixRowLabels::compute_dimensions ()
gdk_pixmap_unref (pm);
_width = _highest_group_name +
- _longest_port_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 */
- 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 */
set_source_rgb (cr, get_a_group_colour (g));
@@ -134,50 +147,24 @@ PortMatrixRowLabels::render (cairo_t* cr)
/* 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;
ARDOUR::BundleList const r = _matrix->rows()->bundles();
for (ARDOUR::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) {
-
- Gdk::Color const colour = get_a_bundle_colour (i - r.begin ());
- set_source_rgb (cr, colour);
- 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 ();
+ render_bundle_name (cr, get_a_bundle_colour (i - r.begin ()), 0, y, *i);
+ int const n = _matrix->show_only_bundles() ? 1 : (*i)->nchannels();
+ y += row_height() * n;
}
/* PORT NAMES */
- 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));
- y += row_height();
+ 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));
+ y += row_height();
+ }
}
}
}
@@ -231,6 +218,25 @@ PortMatrixRowLabels::parent_to_component_y (double y) const
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
PortMatrixRowLabels::port_name_x () const
{
@@ -244,6 +250,35 @@ PortMatrixRowLabels::port_name_x () const
}
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
PortMatrixRowLabels::render_channel_name (
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();
while (i != _matrix->rows()->bundles().end() && *i != bc.bundle) {
- n += (*i)->nchannels ();
+ if (_matrix->show_only_bundles()) {
+ n += 1;
+ } else {
+ n += (*i)->nchannels ();
+ }
++i;
}
+
+ if (!_matrix->show_only_bundles()) {
+ n += bc.channel;
+ }
- n += bc.channel;
return n * row_height();
}
@@ -290,12 +332,21 @@ PortMatrixRowLabels::queue_draw_for (ARDOUR::BundleChannel const & bc)
{
if (bc.bundle) {
- _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()
- );
+ if (_matrix->show_only_bundles()) {
+ _body->queue_draw_area (
+ component_to_parent_x (bundle_name_x()),
+ component_to_parent_y (channel_y (bc)),
+ _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()
+ );
+ }
}
}
diff --git a/gtk2_ardour/port_matrix_row_labels.h b/gtk2_ardour/port_matrix_row_labels.h
index ae8319e044..130469a607 100644
--- a/gtk2_ardour/port_matrix_row_labels.h
+++ b/gtk2_ardour/port_matrix_row_labels.h
@@ -53,6 +53,7 @@ public:
private:
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_y (ARDOUR::BundleChannel const &) const;
@@ -63,6 +64,7 @@ private:
void queue_draw_for (ARDOUR::BundleChannel const &);
double port_name_x () const;
void maybe_popup_context_menu (double, double, uint32_t);
+ double bundle_name_x () const;
double _longest_port_name;
double _longest_bundle_name;
diff --git a/gtk2_ardour/port_matrix_types.h b/gtk2_ardour/port_matrix_types.h
index 2c80c24cce..cdc458061f 100644
--- a/gtk2_ardour/port_matrix_types.h
+++ b/gtk2_ardour/port_matrix_types.h
@@ -36,6 +36,13 @@ struct PortMatrixNode
ARDOUR::BundleChannel row;
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