Click and hold button 1 over a channel name in the port matrix highlights

connected channels.


git-svn-id: svn://localhost/ardour2/branches/3.0@4484 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2009-02-03 01:55:25 +00:00
parent 6a9dc6b8d0
commit d06d697e41
12 changed files with 264 additions and 70 deletions

View File

@ -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

View File

@ -427,3 +427,4 @@ PortMatrix::rename_channel_proxy (boost::weak_ptr<ARDOUR::Bundle> b, uint32_t c)
rename_channel (ARDOUR::BundleChannel (sb, c));
}

View File

@ -82,6 +82,10 @@ public:
int row_index () const {
return _row_index;
}
PortGroupList const * ports (int d) const {
return &_ports[d];
}
virtual void setup ();

View File

@ -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]);
}
}
}
}
}

View File

@ -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;
};

View File

@ -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();
}
void
PortMatrixColumnLabels::queue_draw_for (PortMatrixNode const& n)
double
PortMatrixColumnLabels::channel_y (ARDOUR::BundleChannel const &bc) const
{
if (n.column.bundle) {
return 0;
}
void
PortMatrixColumnLabels::queue_draw_for (ARDOUR::BundleChannel const & bc)
{
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);
}

View File

@ -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 {

View File

@ -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");
}

View File

@ -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);
}

View File

@ -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

View File

@ -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
)
{
@ -263,6 +272,12 @@ PortMatrixRowLabels::render_port_name (
cairo_show_text (cr, bc.bundle->channel_name(bc.channel).c_str());
}
double
PortMatrixRowLabels::channel_x (ARDOUR::BundleChannel const& bc) const
{
return 0;
}
double
PortMatrixRowLabels::channel_y (ARDOUR::BundleChannel const& bc) const
{
@ -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);
}
}

View File

@ -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;