summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2009-01-27 17:37:07 +0000
committerCarl Hetherington <carl@carlh.net>2009-01-27 17:37:07 +0000
commitb2e163a410a62a20e982b3baac0cf65e611acbce (patch)
tree1e404d3f4f9b33ddde56580d7b4fb02d1432b331
parent9cc7b452ebb8fe8f348ad6aad18054703700da18 (diff)
A few cleanups. Also make port matrix notice when routes or processors change.
git-svn-id: svn://localhost/ardour2/branches/3.0@4447 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/port_matrix.cc22
-rw-r--r--gtk2_ardour/port_matrix.h2
-rw-r--r--gtk2_ardour/port_matrix_column_labels.cc51
-rw-r--r--gtk2_ardour/port_matrix_column_labels.h4
-rw-r--r--gtk2_ardour/port_matrix_row_labels.cc22
-rw-r--r--gtk2_ardour/port_matrix_types.h13
6 files changed, 65 insertions, 49 deletions
diff --git a/gtk2_ardour/port_matrix.cc b/gtk2_ardour/port_matrix.cc
index fccc707694..c080b3365d 100644
--- a/gtk2_ardour/port_matrix.cc
+++ b/gtk2_ardour/port_matrix.cc
@@ -23,6 +23,8 @@
#include <gtkmm/label.h>
#include "ardour/bundle.h"
#include "ardour/types.h"
+#include "ardour/session.h"
+#include "ardour/route.h"
#include "port_matrix.h"
#include "i18n.h"
@@ -65,6 +67,9 @@ PortMatrix::PortMatrix (ARDOUR::Session& session, ARDOUR::DataType type, bool of
_vscroll.signal_value_changed().connect (sigc::mem_fun (*this, &PortMatrix::vscroll_changed));
setup_scrollbars ();
+ _session.RouteAdded.connect (sigc::hide (sigc::mem_fun (*this, &PortMatrix::routes_changed)));
+ routes_changed ();
+
/* XXX hard-coded initial size suggestion */
set_size_request (400, 200);
show_all ();
@@ -78,6 +83,23 @@ PortMatrix::~PortMatrix ()
}
void
+PortMatrix::routes_changed ()
+{
+ for (std::vector<sigc::connection>::iterator i = _route_connections.begin(); i != _route_connections.end(); ++i) {
+ i->disconnect ();
+ }
+
+ boost::shared_ptr<ARDOUR::Session::RouteList> routes = _session.get_routes ();
+ for (ARDOUR::Session::RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
+ _route_connections.push_back (
+ (*i)->processors_changed.connect (sigc::mem_fun (*this, &PortMatrix::setup))
+ );
+ }
+
+ setup ();
+}
+
+void
PortMatrix::setup ()
{
_column_ports.gather (_session);
diff --git a/gtk2_ardour/port_matrix.h b/gtk2_ardour/port_matrix.h
index 85a273265e..425e3915c4 100644
--- a/gtk2_ardour/port_matrix.h
+++ b/gtk2_ardour/port_matrix.h
@@ -121,6 +121,7 @@ private:
void hscroll_changed ();
void vscroll_changed ();
+ void routes_changed ();
ARDOUR::Session& _session;
/// true to offer inputs, otherwise false
@@ -132,6 +133,7 @@ private:
Gtk::HScrollbar _hscroll;
Gtk::VScrollbar _vscroll;
std::list<PortGroupUI*> _port_group_uis;
+ std::vector<sigc::connection> _route_connections;
};
#endif
diff --git a/gtk2_ardour/port_matrix_column_labels.cc b/gtk2_ardour/port_matrix_column_labels.cc
index bd6a14e6fa..d99cb92d86 100644
--- a/gtk2_ardour/port_matrix_column_labels.cc
+++ b/gtk2_ardour/port_matrix_column_labels.cc
@@ -123,7 +123,7 @@ PortMatrixColumnLabels::render (cairo_t* cr)
double y = 0;
if (_location == TOP) {
- x = (_height - _highest_group_name - 2 * name_pad()) / tan (angle());
+ x = slanted_height() / tan (angle());
y = _highest_group_name + name_pad();
} else {
x = 0;
@@ -175,22 +175,21 @@ PortMatrixColumnLabels::render (cairo_t* cr)
set_source_rgb (cr, colour);
double const w = (*i)->nchannels() * column_width();
- double const ph = _height - _highest_group_name - 2 * name_pad();
double x_ = x;
if (_location == TOP) {
y = _height;
} else if (_location == BOTTOM) {
- y = ph;
+ y = slanted_height();
}
double y_ = y;
cairo_move_to (cr, x_, y_);
x_ += w;
cairo_line_to (cr, x_, y_);
- x_ += ph / tan (angle ());
- y_ -= ph;
+ x_ += slanted_height() / tan (angle ());
+ y_ -= slanted_height();
cairo_line_to (cr, x_, y_);
x_ -= w;
cairo_line_to (cr, x_, y_);
@@ -216,7 +215,7 @@ PortMatrixColumnLabels::render (cairo_t* cr)
cairo_move_to (
cr,
x + basic_text_x_pos (0),
- ph - name_pad() * sin (angle())
+ slanted_height() - name_pad() * sin (angle())
);
}
@@ -285,21 +284,19 @@ PortMatrixColumnLabels::draw_extra (cairo_t* cr)
_body->mouseover().column
);
}
-
}
void
-PortMatrixColumnLabels::render_port_name (cairo_t* cr, Gdk::Color colour, double x, double y, PortMatrixBundleChannel const &bc)
+PortMatrixColumnLabels::render_port_name (cairo_t* cr, Gdk::Color colour, double xoff, double yoff, PortMatrixBundleChannel const &bc)
{
double const lc = _longest_channel_name + name_pad();
double const w = column_width();
- double const ph = _height - _highest_group_name - 2 * name_pad();
if (_location == BOTTOM) {
- double x_ = x + ph / tan (angle()) + w;
+ double x_ = xoff + slanted_height() / tan (angle()) + w;
double const ix = x_;
- double y_ = y;
+ double y_ = yoff;
cairo_move_to (cr, x_, y_);
x_ -= w;
cairo_line_to (cr, x_, y_);
@@ -309,12 +306,12 @@ PortMatrixColumnLabels::render_port_name (cairo_t* cr, Gdk::Color colour, double
x_ += w * pow (sin (angle()), 2);
y_ += w * sin (angle()) * cos (angle());
cairo_line_to (cr, x_, y_);
- cairo_line_to (cr, ix, y);
+ cairo_line_to (cr, ix, yoff);
} else if (_location == TOP) {
- double x_ = x;
- double y_ = y + _height;
+ double x_ = xoff;
+ double y_ = yoff + _height;
cairo_move_to (cr, x_, y_);
x_ += w;
cairo_line_to (cr, x_, y_);
@@ -324,7 +321,7 @@ PortMatrixColumnLabels::render_port_name (cairo_t* cr, Gdk::Color colour, double
x_ -= column_width() * pow (sin (angle()), 2);
y_ -= column_width() * sin (angle()) * cos (angle());
cairo_line_to (cr, x_, y_);
- cairo_line_to (cr, x, y + _height);
+ cairo_line_to (cr, xoff, yoff + _height);
}
@@ -340,8 +337,8 @@ PortMatrixColumnLabels::render_port_name (cairo_t* cr, Gdk::Color colour, double
cairo_move_to (
cr,
- x + basic_text_x_pos(bc.channel),
- y + _height - name_pad() * sin (angle())
+ xoff + basic_text_x_pos(bc.channel),
+ yoff + _height - name_pad() * sin (angle())
);
} else if (_location == BOTTOM) {
@@ -349,8 +346,8 @@ PortMatrixColumnLabels::render_port_name (cairo_t* cr, Gdk::Color colour, double
double const rl = 3 * name_pad() + _longest_bundle_name;
cairo_move_to (
cr,
- x + basic_text_x_pos(bc.channel) + rl * cos (angle ()),
- y + ph - rl * sin (angle())
+ xoff + basic_text_x_pos(bc.channel) + rl * cos (angle ()),
+ yoff + slanted_height() - rl * sin (angle())
);
}
@@ -368,17 +365,7 @@ PortMatrixColumnLabels::render_port_name (cairo_t* cr, Gdk::Color colour, double
double
PortMatrixColumnLabels::channel_x (PortMatrixBundleChannel const &bc) const
{
- double x = 0;
-
- ARDOUR::BundleList::const_iterator i = _body->column_ports().bundles().begin();
- while (i != _body->column_ports().bundles().end() && *i != bc.bundle) {
- x += column_width() * (*i)->nchannels();
- ++i;
- }
-
- x += column_width() * bc.channel;
-
- return x;
+ return bc.nchannels (_body->column_ports().bundles()) * column_width();
}
void
@@ -400,9 +387,7 @@ PortMatrixColumnLabels::queue_draw_for (PortMatrixNode const& n)
} else if (_location == BOTTOM) {
- double const ph = _height - _highest_group_name - 2 * name_pad();
- double const w = column_width() + lc * cos (angle());
- double const x_ = x + ph / tan (angle()) - lc * cos (angle());
+ double const x_ = x + slanted_height() / tan (angle()) - lc * cos (angle());
_body->queue_draw_area (
component_to_parent_x (x_),
diff --git a/gtk2_ardour/port_matrix_column_labels.h b/gtk2_ardour/port_matrix_column_labels.h
index 213b760a25..9021ec55e3 100644
--- a/gtk2_ardour/port_matrix_column_labels.h
+++ b/gtk2_ardour/port_matrix_column_labels.h
@@ -57,6 +57,10 @@ private:
double channel_x (PortMatrixBundleChannel const &) const;
void queue_draw_for (PortMatrixNode const &);
+ double slanted_height () const {
+ return _height - _highest_group_name - 2 * name_pad();
+ }
+
std::vector<boost::shared_ptr<ARDOUR::Bundle> > _bundles;
double _longest_bundle_name;
double _longest_channel_name;
diff --git a/gtk2_ardour/port_matrix_row_labels.cc b/gtk2_ardour/port_matrix_row_labels.cc
index 278ae8e003..b938f22a21 100644
--- a/gtk2_ardour/port_matrix_row_labels.cc
+++ b/gtk2_ardour/port_matrix_row_labels.cc
@@ -187,7 +187,7 @@ PortMatrixRowLabels::render (cairo_t* cr)
y = 0;
for (ARDOUR::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) {
for (uint32_t j = 0; j < (*i)->nchannels(); ++j) {
- render_port_name (cr, get_a_bundle_colour (i - r.begin()), port_name_x(), y, PortMatrixBundleChannel (*i, j));
+ render_port_name (cr, get_a_bundle_colour (i - r.begin()), 0, y, PortMatrixBundleChannel (*i, j));
y += row_height();
}
}
@@ -316,11 +316,11 @@ PortMatrixRowLabels::port_name_x () const
void
PortMatrixRowLabels::render_port_name (
- cairo_t* cr, Gdk::Color colour, double x, double y, PortMatrixBundleChannel const& bc
+ cairo_t* cr, Gdk::Color colour, double xoff, double yoff, PortMatrixBundleChannel const& bc
)
{
set_source_rgb (cr, colour);
- cairo_rectangle (cr, x, y, _longest_port_name + name_pad() * 2, row_height());
+ cairo_rectangle (cr, port_name_x() + xoff, yoff, _longest_port_name + name_pad() * 2, row_height());
cairo_fill_preserve (cr);
set_source_rgb (cr, background_colour());
cairo_set_line_width (cr, label_border_width ());
@@ -331,24 +331,14 @@ PortMatrixRowLabels::render_port_name (
double const off = (row_height() - ext.height) / 2;
set_source_rgb (cr, text_colour());
- cairo_move_to (cr, x + name_pad(), y + name_pad() + off);
+ cairo_move_to (cr, port_name_x() + xoff + name_pad(), yoff + name_pad() + off);
cairo_show_text (cr, bc.bundle->channel_name(bc.channel).c_str());
}
double
PortMatrixRowLabels::channel_y (PortMatrixBundleChannel const& bc) const
{
- double y = 0;
-
- ARDOUR::BundleList::const_iterator i = _body->row_ports().bundles().begin();
- while (i != _body->row_ports().bundles().end() && *i != bc.bundle) {
- y += row_height() * (*i)->nchannels();
- ++i;
- }
-
- y += row_height() * bc.channel;
-
- return y;
+ return bc.nchannels (_body->row_ports().bundles()) * row_height();
}
void
@@ -380,7 +370,7 @@ PortMatrixRowLabels::draw_extra (cairo_t* cr)
render_port_name (
cr,
mouseover_port_colour (),
- component_to_parent_x (port_name_x()),
+ component_to_parent_x (0),
component_to_parent_y (channel_y (_body->mouseover().row)),
_body->mouseover().row
);
diff --git a/gtk2_ardour/port_matrix_types.h b/gtk2_ardour/port_matrix_types.h
index 66dcf619b7..16fb440ace 100644
--- a/gtk2_ardour/port_matrix_types.h
+++ b/gtk2_ardour/port_matrix_types.h
@@ -20,6 +20,8 @@
#ifndef __ardour_gtk_port_matrix_types_h__
#define __ardour_gtk_port_matrix_types_h__
+#include "ardour/bundle.h"
+
struct PortMatrixBundleChannel {
PortMatrixBundleChannel () : channel (0) {}
PortMatrixBundleChannel (boost::shared_ptr<ARDOUR::Bundle> b, uint32_t c)
@@ -31,6 +33,17 @@ struct PortMatrixBundleChannel {
bool operator!= (PortMatrixBundleChannel const& other) const {
return bundle != other.bundle || channel != other.channel;
}
+
+ uint32_t nchannels (ARDOUR::BundleList const& bl) const {
+ uint32_t n = 0;
+ ARDOUR::BundleList::const_iterator i = bl.begin();
+ while (i != bl.end() && *i != bundle) {
+ n += (*i)->nchannels ();
+ ++i;
+ }
+ n += channel;
+ return n;
+ }
boost::shared_ptr<ARDOUR::Bundle> bundle;
uint32_t channel;