summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/SConscript1
-rw-r--r--gtk2_ardour/port_matrix.cc1
-rw-r--r--gtk2_ardour/port_matrix.h4
-rw-r--r--gtk2_ardour/port_matrix_body.cc66
-rw-r--r--gtk2_ardour/port_matrix_body.h4
-rw-r--r--gtk2_ardour/port_matrix_column_labels.cc71
-rw-r--r--gtk2_ardour/port_matrix_column_labels.h14
-rw-r--r--gtk2_ardour/port_matrix_component.h4
-rw-r--r--gtk2_ardour/port_matrix_labels.cc55
-rw-r--r--gtk2_ardour/port_matrix_labels.h49
-rw-r--r--gtk2_ardour/port_matrix_row_labels.cc49
-rw-r--r--gtk2_ardour/port_matrix_row_labels.h14
12 files changed, 263 insertions, 69 deletions
diff --git a/gtk2_ardour/SConscript b/gtk2_ardour/SConscript
index 49980388ca..6c44764179 100644
--- a/gtk2_ardour/SConscript
+++ b/gtk2_ardour/SConscript
@@ -222,6 +222,7 @@ port_matrix_body.cc
port_matrix_column_labels.cc
port_matrix_component.cc
port_matrix_grid.cc
+port_matrix_labels.cc
port_matrix_row_labels.cc
processor_box.cc
prompter.cc
diff --git a/gtk2_ardour/port_matrix.cc b/gtk2_ardour/port_matrix.cc
index 046ad3259f..cf7c8215f9 100644
--- a/gtk2_ardour/port_matrix.cc
+++ b/gtk2_ardour/port_matrix.cc
@@ -427,3 +427,4 @@ PortMatrix::rename_channel_proxy (boost::weak_ptr<ARDOUR::Bundle> b, uint32_t c)
rename_channel (ARDOUR::BundleChannel (sb, c));
}
+
diff --git a/gtk2_ardour/port_matrix.h b/gtk2_ardour/port_matrix.h
index b6e8646500..44dc14acae 100644
--- a/gtk2_ardour/port_matrix.h
+++ b/gtk2_ardour/port_matrix.h
@@ -82,6 +82,10 @@ public:
int row_index () const {
return _row_index;
}
+
+ PortGroupList const * ports (int d) const {
+ return &_ports[d];
+ }
virtual void setup ();
diff --git a/gtk2_ardour/port_matrix_body.cc b/gtk2_ardour/port_matrix_body.cc
index 590ab15669..8c75cac74b 100644
--- a/gtk2_ardour/port_matrix_body.cc
+++ b/gtk2_ardour/port_matrix_body.cc
@@ -29,7 +29,8 @@ PortMatrixBody::PortMatrixBody (PortMatrix* p)
_row_labels (p, this),
_grid (p, this),
_xoffset (0),
- _yoffset (0)
+ _yoffset (0),
+ _mouse_over_grid (false)
{
modify_bg (Gtk::STATE_NORMAL, Gdk::Color ("#00000"));
add_events (Gdk::LEAVE_NOTIFY_MASK | Gdk::POINTER_MOTION_MASK);
@@ -336,6 +337,20 @@ PortMatrixBody::on_button_press_event (GdkEventButton* ev)
return true;
}
+bool
+PortMatrixBody::on_button_release_event (GdkEventButton* ev)
+{
+ if (Gdk::Region (_row_labels.parent_rectangle()).point_in (ev->x, ev->y) ||
+ Gdk::Region (_column_labels.parent_rectangle()).point_in (ev->x, ev->y)) {
+
+ _row_labels.clear_channel_highlights ();
+ _column_labels.clear_channel_highlights ();
+
+ }
+
+ return true;
+}
+
void
PortMatrixBody::rebuild_and_draw_grid ()
{
@@ -375,6 +390,12 @@ PortMatrixBody::on_motion_notify_event (GdkEventMotion* ev)
_grid.parent_to_component_x (ev->x),
_grid.parent_to_component_y (ev->y)
);
+ _mouse_over_grid = true;
+ } else {
+ if (_mouse_over_grid) {
+ set_mouseover (PortMatrixNode ());
+ _mouse_over_grid = false;
+ }
}
return true;
@@ -394,3 +415,46 @@ PortMatrixBody::set_mouseover (PortMatrixNode const & n)
_row_labels.mouseover_changed (old);
_column_labels.mouseover_changed (old);
}
+
+
+
+void
+PortMatrixBody::highlight_associated_channels (int dim, uint32_t N)
+{
+ ARDOUR::BundleChannel bc[2];
+
+ ARDOUR::BundleList const a = _matrix->ports(dim)->bundles ();
+ for (ARDOUR::BundleList::const_iterator i = a.begin(); i != a.end(); ++i) {
+ if (N < (*i)->nchannels ()) {
+ bc[dim] = ARDOUR::BundleChannel (*i, N);
+ break;
+ } else {
+ N -= (*i)->nchannels ();
+ }
+ }
+
+ if (!bc[dim].bundle) {
+ return;
+ }
+
+ if (dim == _matrix->column_index()) {
+ _column_labels.add_channel_highlight (bc[dim]);
+ } else {
+ _row_labels.add_channel_highlight (bc[dim]);
+ }
+
+ ARDOUR::BundleList const b = _matrix->ports(1 - dim)->bundles ();
+
+ for (ARDOUR::BundleList::const_iterator i = b.begin(); i != b.end(); ++i) {
+ for (uint32_t j = 0; j < (*i)->nchannels(); ++j) {
+ bc[1 - dim] = ARDOUR::BundleChannel (*i, j);
+ if (_matrix->get_state (bc) == PortMatrix::ASSOCIATED) {
+ if (dim == _matrix->column_index()) {
+ _row_labels.add_channel_highlight (bc[1 - dim]);
+ } else {
+ _column_labels.add_channel_highlight (bc[1 - dim]);
+ }
+ }
+ }
+ }
+}
diff --git a/gtk2_ardour/port_matrix_body.h b/gtk2_ardour/port_matrix_body.h
index 2e31e3ed9b..2320efe4f2 100644
--- a/gtk2_ardour/port_matrix_body.h
+++ b/gtk2_ardour/port_matrix_body.h
@@ -59,11 +59,14 @@ public:
return _mouseover;
}
+ void highlight_associated_channels (int, uint32_t);
+
protected:
bool on_expose_event (GdkEventExpose *);
void on_size_request (Gtk::Requisition *);
void on_size_allocate (Gtk::Allocation &);
bool on_button_press_event (GdkEventButton *);
+ bool on_button_release_event (GdkEventButton *);
bool on_leave_notify_event (GdkEventCrossing *);
bool on_motion_notify_event (GdkEventMotion *);
@@ -87,6 +90,7 @@ private:
uint32_t _yoffset;
PortMatrixNode _mouseover;
+ bool _mouse_over_grid;
std::list<sigc::connection> _bundle_connections;
};
diff --git a/gtk2_ardour/port_matrix_column_labels.cc b/gtk2_ardour/port_matrix_column_labels.cc
index 2a2fcf80d5..7bbf0e64c0 100644
--- a/gtk2_ardour/port_matrix_column_labels.cc
+++ b/gtk2_ardour/port_matrix_column_labels.cc
@@ -24,7 +24,7 @@
#include "port_matrix.h"
PortMatrixColumnLabels::PortMatrixColumnLabels (PortMatrix* m, PortMatrixBody* b)
- : PortMatrixComponent (m, b)
+ : PortMatrixLabels (m, b)
{
}
@@ -235,7 +235,7 @@ PortMatrixColumnLabels::render (cairo_t* cr)
for (uint32_t j = 0; j < (*i)->nchannels(); ++j) {
- render_port_name (cr, get_a_bundle_colour (i - c.begin()), x, 0, ARDOUR::BundleChannel (*i, j));
+ render_channel_name (cr, get_a_bundle_colour (i - c.begin()), x, 0, ARDOUR::BundleChannel (*i, j));
x += column_width();
}
}
@@ -266,23 +266,11 @@ PortMatrixColumnLabels::parent_to_component_y (double y) const
}
void
-PortMatrixColumnLabels::mouseover_changed (PortMatrixNode const& old)
-{
- queue_draw_for (old);
- queue_draw_for (_body->mouseover());
-}
-
-void
-PortMatrixColumnLabels::draw_extra (cairo_t* cr)
+PortMatrixColumnLabels::mouseover_changed (PortMatrixNode const &)
{
+ clear_channel_highlights ();
if (_body->mouseover().column.bundle) {
- render_port_name (
- cr,
- mouseover_port_colour (),
- component_to_parent_x (channel_x (_body->mouseover().column)),
- component_to_parent_y (0),
- _body->mouseover().column
- );
+ add_channel_highlight (_body->mouseover().column);
}
}
@@ -327,7 +315,7 @@ PortMatrixColumnLabels::port_name_shape (double xoff, double yoff) const
}
void
-PortMatrixColumnLabels::render_port_name (cairo_t* cr, Gdk::Color colour, double xoff, double yoff, ARDOUR::BundleChannel const &bc)
+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);
@@ -389,12 +377,18 @@ PortMatrixColumnLabels::channel_x (ARDOUR::BundleChannel const &bc) const
return n * column_width();
}
+double
+PortMatrixColumnLabels::channel_y (ARDOUR::BundleChannel const &bc) const
+{
+ return 0;
+}
+
void
-PortMatrixColumnLabels::queue_draw_for (PortMatrixNode const& n)
+PortMatrixColumnLabels::queue_draw_for (ARDOUR::BundleChannel const & bc)
{
- if (n.column.bundle) {
+ if (bc.bundle) {
- double const x = channel_x (n.column);
+ 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) {
@@ -426,15 +420,6 @@ PortMatrixColumnLabels::queue_draw_for (PortMatrixNode const& n)
void
PortMatrixColumnLabels::button_press (double x, double y, int b, uint32_t t)
{
- if (b != 3) {
- return;
- }
-
- if (!_matrix->can_rename_channels (_matrix->column_index()) &&
- !_matrix->can_remove_channels (_matrix->column_index())) {
- return;
- }
-
uint32_t N = _matrix->columns()->total_visible_ports ();
uint32_t i = 0;
for (; i < N; ++i) {
@@ -454,8 +439,32 @@ PortMatrixColumnLabels::button_press (double x, double y, int b, uint32_t t)
}
if (j == 4) {
- _matrix->popup_channel_context_menu (_matrix->column_index(), i, t);
break;
}
}
+
+ if (i == N) {
+ return;
+ }
+
+ switch (b) {
+ case 1:
+ _body->highlight_associated_channels (_matrix->column_index(), i);
+ break;
+ case 3:
+ maybe_popup_context_menu (i, t);
+ break;
+ }
+}
+
+
+void
+PortMatrixColumnLabels::maybe_popup_context_menu (int i, uint32_t t)
+{
+ if (!_matrix->can_rename_channels (_matrix->column_index()) &&
+ !_matrix->can_remove_channels (_matrix->column_index())) {
+ return;
+ }
+
+ _matrix->popup_channel_context_menu (_matrix->column_index(), i, t);
}
diff --git a/gtk2_ardour/port_matrix_column_labels.h b/gtk2_ardour/port_matrix_column_labels.h
index 6ed87e9628..4cf59ad732 100644
--- a/gtk2_ardour/port_matrix_column_labels.h
+++ b/gtk2_ardour/port_matrix_column_labels.h
@@ -21,7 +21,7 @@
#define __port_matrix_column_labels_h__
#include <boost/shared_ptr.hpp>
-#include "port_matrix_component.h"
+#include "port_matrix_labels.h"
namespace ARDOUR {
class Bundle;
@@ -31,7 +31,7 @@ namespace ARDOUR {
class PortMatrixNode;
/** The column labels part of the port matrix */
-class PortMatrixColumnLabels : public PortMatrixComponent
+class PortMatrixColumnLabels : public PortMatrixLabels
{
public:
PortMatrixColumnLabels (PortMatrix *, PortMatrixBody *);
@@ -43,15 +43,17 @@ public:
double component_to_parent_y (double y) const;
double parent_to_component_y (double y) const;
void mouseover_changed (PortMatrixNode const &);
- void draw_extra (cairo_t *);
private:
+ 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;
+ void queue_draw_for (ARDOUR::BundleChannel const &);
+ void maybe_popup_context_menu (int, uint32_t);
+
void render (cairo_t *);
void compute_dimensions ();
double basic_text_x_pos (int) const;
- void render_port_name (cairo_t *, Gdk::Color, double, double, ARDOUR::BundleChannel const &);
- double channel_x (ARDOUR::BundleChannel const &) const;
- void queue_draw_for (PortMatrixNode const &);
std::vector<std::pair<double, double> > port_name_shape (double, double) const;
double slanted_height () const {
diff --git a/gtk2_ardour/port_matrix_component.h b/gtk2_ardour/port_matrix_component.h
index 39ea6b3c0d..9eb2c566a5 100644
--- a/gtk2_ardour/port_matrix_component.h
+++ b/gtk2_ardour/port_matrix_component.h
@@ -141,8 +141,8 @@ protected:
return Gdk::Color ("#ff0000");
}
- /** @return colour to paint mouseover lines */
- static Gdk::Color mouseover_port_colour () {
+ /** @return colour to paint channel highlights */
+ static Gdk::Color highlighted_channel_colour () {
return Gdk::Color ("#777777");
}
diff --git a/gtk2_ardour/port_matrix_labels.cc b/gtk2_ardour/port_matrix_labels.cc
new file mode 100644
index 0000000000..3a50edb7c6
--- /dev/null
+++ b/gtk2_ardour/port_matrix_labels.cc
@@ -0,0 +1,55 @@
+/*
+ Copyright (C) 2002-2009 Paul Davis
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "ardour/bundle.h"
+#include "port_matrix_labels.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
+ );
+ }
+}
+
+void
+PortMatrixLabels::clear_channel_highlights ()
+{
+ for (std::vector<ARDOUR::BundleChannel>::const_iterator i = _channel_highlights.begin(); i != _channel_highlights.end(); ++i) {
+
+ queue_draw_for (*i);
+ }
+
+ _channel_highlights.clear ();
+}
+
+void
+PortMatrixLabels::add_channel_highlight (ARDOUR::BundleChannel const & bc)
+{
+ _channel_highlights.push_back (bc);
+ queue_draw_for (bc);
+}
+
diff --git a/gtk2_ardour/port_matrix_labels.h b/gtk2_ardour/port_matrix_labels.h
new file mode 100644
index 0000000000..fff734755c
--- /dev/null
+++ b/gtk2_ardour/port_matrix_labels.h
@@ -0,0 +1,49 @@
+/*
+ Copyright (C) 2002-2009 Paul Davis
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#ifndef __port_matrix_labels_h__
+#define __port_matrix_labels_h__
+
+#include "port_matrix_component.h"
+
+namespace ARDOUR {
+ class BundleChannel;
+}
+
+class PortMatrixLabels : public PortMatrixComponent
+{
+public:
+ PortMatrixLabels (PortMatrix* m, PortMatrixBody* b) : PortMatrixComponent (m, b) {}
+ virtual ~PortMatrixLabels () {}
+
+ void draw_extra (cairo_t *);
+
+ void clear_channel_highlights ();
+ void add_channel_highlight (ARDOUR::BundleChannel const &);
+
+private:
+ virtual void render_channel_name (cairo_t *, Gdk::Color, double, double, ARDOUR::BundleChannel const &) = 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;
+
+ std::vector<ARDOUR::BundleChannel> _channel_highlights;
+};
+
+#endif
diff --git a/gtk2_ardour/port_matrix_row_labels.cc b/gtk2_ardour/port_matrix_row_labels.cc
index 0e48b5b6b2..d8162d715e 100644
--- a/gtk2_ardour/port_matrix_row_labels.cc
+++ b/gtk2_ardour/port_matrix_row_labels.cc
@@ -26,7 +26,7 @@
#include "i18n.h"
PortMatrixRowLabels::PortMatrixRowLabels (PortMatrix* m, PortMatrixBody* b)
- : PortMatrixComponent (m, b)
+ : PortMatrixLabels (m, b)
{
}
@@ -179,7 +179,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()), 0, y, ARDOUR::BundleChannel (*i, j));
+ render_channel_name (cr, get_a_bundle_colour (i - r.begin()), 0, y, ARDOUR::BundleChannel (*i, j));
y += row_height();
}
}
@@ -188,10 +188,19 @@ PortMatrixRowLabels::render (cairo_t* cr)
void
PortMatrixRowLabels::button_press (double x, double y, int b, uint32_t t)
{
- if (b != 3) {
- return;
+ switch (b) {
+ case 1:
+ _body->highlight_associated_channels (_matrix->row_index(), y / row_height ());
+ break;
+ case 3:
+ maybe_popup_context_menu (x, y, t);
+ break;
}
+}
+void
+PortMatrixRowLabels::maybe_popup_context_menu (double x, double y, uint32_t t)
+{
if (!_matrix->can_rename_channels (_matrix->row_index()) &&
!_matrix->can_remove_channels (_matrix->row_index())) {
return;
@@ -243,7 +252,7 @@ PortMatrixRowLabels::port_name_x () const
}
void
-PortMatrixRowLabels::render_port_name (
+PortMatrixRowLabels::render_channel_name (
cairo_t* cr, Gdk::Color colour, double xoff, double yoff, ARDOUR::BundleChannel const& bc
)
{
@@ -264,6 +273,12 @@ PortMatrixRowLabels::render_port_name (
}
double
+PortMatrixRowLabels::channel_x (ARDOUR::BundleChannel const& bc) const
+{
+ return 0;
+}
+
+double
PortMatrixRowLabels::channel_y (ARDOUR::BundleChannel const& bc) const
{
uint32_t n = 0;
@@ -279,13 +294,13 @@ PortMatrixRowLabels::channel_y (ARDOUR::BundleChannel const& bc) const
}
void
-PortMatrixRowLabels::queue_draw_for (PortMatrixNode const& n)
+PortMatrixRowLabels::queue_draw_for (ARDOUR::BundleChannel const & bc)
{
- if (n.row.bundle) {
+ if (bc.bundle) {
_body->queue_draw_area (
component_to_parent_x (port_name_x()),
- component_to_parent_y (channel_y (n.row)),
+ component_to_parent_y (channel_y (bc)),
_longest_port_name + name_pad() * 2,
row_height()
);
@@ -294,22 +309,10 @@ PortMatrixRowLabels::queue_draw_for (PortMatrixNode const& n)
}
void
-PortMatrixRowLabels::mouseover_changed (PortMatrixNode const& old)
-{
- queue_draw_for (old);
- queue_draw_for (_body->mouseover());
-}
-
-void
-PortMatrixRowLabels::draw_extra (cairo_t* cr)
+PortMatrixRowLabels::mouseover_changed (PortMatrixNode const &)
{
+ clear_channel_highlights ();
if (_body->mouseover().row.bundle) {
- render_port_name (
- cr,
- mouseover_port_colour (),
- component_to_parent_x (0),
- component_to_parent_y (channel_y (_body->mouseover().row)),
- _body->mouseover().row
- );
+ add_channel_highlight (_body->mouseover().row);
}
}
diff --git a/gtk2_ardour/port_matrix_row_labels.h b/gtk2_ardour/port_matrix_row_labels.h
index 85d59d139f..ae8319e044 100644
--- a/gtk2_ardour/port_matrix_row_labels.h
+++ b/gtk2_ardour/port_matrix_row_labels.h
@@ -22,7 +22,7 @@
#include <boost/shared_ptr.hpp>
#include <gdkmm/color.h>
-#include "port_matrix_component.h"
+#include "port_matrix_labels.h"
class PortMatrix;
class PortMatrixBody;
@@ -38,7 +38,7 @@ namespace Gtk {
}
/** The row labels part of the port matrix */
-class PortMatrixRowLabels : public PortMatrixComponent
+class PortMatrixRowLabels : public PortMatrixLabels
{
public:
PortMatrixRowLabels (PortMatrix *, PortMatrixBody *);
@@ -50,17 +50,19 @@ public:
double component_to_parent_y (double y) const;
double parent_to_component_y (double y) const;
void mouseover_changed (PortMatrixNode const &);
- void draw_extra (cairo_t* cr);
private:
+ 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;
+
void render (cairo_t *);
void compute_dimensions ();
void remove_channel_proxy (boost::weak_ptr<ARDOUR::Bundle>, uint32_t);
void rename_channel_proxy (boost::weak_ptr<ARDOUR::Bundle>, uint32_t);
- void render_port_name (cairo_t *, Gdk::Color, double, double, ARDOUR::BundleChannel const &);
- double channel_y (ARDOUR::BundleChannel const &) const;
- void queue_draw_for (PortMatrixNode const &);
+ void queue_draw_for (ARDOUR::BundleChannel const &);
double port_name_x () const;
+ void maybe_popup_context_menu (double, double, uint32_t);
double _longest_port_name;
double _longest_bundle_name;