2009-01-20 09:46:00 -05:00
|
|
|
/*
|
|
|
|
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 <iostream>
|
|
|
|
#include "ardour/bundle.h"
|
2009-01-25 01:47:11 -05:00
|
|
|
#include "ardour/types.h"
|
2009-01-20 09:46:00 -05:00
|
|
|
#include "port_matrix_body.h"
|
|
|
|
#include "port_matrix.h"
|
2009-02-04 12:05:26 -05:00
|
|
|
#include "port_matrix_column_labels.h"
|
|
|
|
#include "port_matrix_row_labels.h"
|
|
|
|
#include "port_matrix_grid.h"
|
2009-01-20 09:46:00 -05:00
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
using namespace std;
|
|
|
|
|
2009-01-30 10:08:09 -05:00
|
|
|
PortMatrixBody::PortMatrixBody (PortMatrix* p)
|
|
|
|
: _matrix (p),
|
2009-01-20 09:46:00 -05:00
|
|
|
_xoffset (0),
|
2009-02-02 20:55:25 -05:00
|
|
|
_yoffset (0),
|
|
|
|
_mouse_over_grid (false)
|
2009-01-20 09:46:00 -05:00
|
|
|
{
|
2009-02-04 12:05:26 -05:00
|
|
|
_column_labels = new PortMatrixColumnLabels (p, this);
|
|
|
|
_row_labels = new PortMatrixRowLabels (p, this);
|
|
|
|
_grid = new PortMatrixGrid (p, this);
|
|
|
|
|
2009-02-02 08:59:50 -05:00
|
|
|
add_events (Gdk::LEAVE_NOTIFY_MASK | Gdk::POINTER_MOTION_MASK);
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-02-04 12:05:26 -05:00
|
|
|
PortMatrixBody::~PortMatrixBody ()
|
|
|
|
{
|
|
|
|
delete _column_labels;
|
|
|
|
delete _row_labels;
|
|
|
|
delete _grid;
|
|
|
|
}
|
|
|
|
|
2009-01-20 09:46:00 -05:00
|
|
|
bool
|
|
|
|
PortMatrixBody::on_expose_event (GdkEventExpose* event)
|
|
|
|
{
|
|
|
|
Gdk::Rectangle const exposure (
|
|
|
|
event->area.x, event->area.y, event->area.width, event->area.height
|
|
|
|
);
|
|
|
|
|
|
|
|
bool intersects;
|
2009-02-05 07:56:12 -05:00
|
|
|
|
2009-01-20 09:46:00 -05:00
|
|
|
Gdk::Rectangle r = exposure;
|
2009-02-05 07:56:12 -05:00
|
|
|
/* the get_pixmap call may cause things to be rerendered and sizes to change,
|
2009-02-08 22:18:10 -05:00
|
|
|
so fetch the pixmap before calculating where to put it */
|
2009-02-05 07:56:12 -05:00
|
|
|
GdkPixmap* p = _column_labels->get_pixmap (get_window()->gobj());
|
2009-02-04 12:05:26 -05:00
|
|
|
r.intersect (_column_labels->parent_rectangle(), intersects);
|
2009-01-20 09:46:00 -05:00
|
|
|
|
|
|
|
if (intersects) {
|
2009-02-05 07:56:12 -05:00
|
|
|
|
2009-01-20 09:46:00 -05:00
|
|
|
gdk_draw_drawable (
|
|
|
|
get_window()->gobj(),
|
|
|
|
get_style()->get_fg_gc (Gtk::STATE_NORMAL)->gobj(),
|
2009-02-05 07:56:12 -05:00
|
|
|
p,
|
2009-02-04 12:05:26 -05:00
|
|
|
_column_labels->parent_to_component_x (r.get_x()),
|
|
|
|
_column_labels->parent_to_component_y (r.get_y()),
|
2009-01-20 09:46:00 -05:00
|
|
|
r.get_x(),
|
|
|
|
r.get_y(),
|
|
|
|
r.get_width(),
|
|
|
|
r.get_height()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
r = exposure;
|
2009-02-05 07:56:12 -05:00
|
|
|
p = _row_labels->get_pixmap (get_window()->gobj());
|
2009-02-04 12:05:26 -05:00
|
|
|
r.intersect (_row_labels->parent_rectangle(), intersects);
|
2009-01-20 09:46:00 -05:00
|
|
|
|
|
|
|
if (intersects) {
|
|
|
|
gdk_draw_drawable (
|
|
|
|
get_window()->gobj(),
|
|
|
|
get_style()->get_fg_gc (Gtk::STATE_NORMAL)->gobj(),
|
2009-02-05 07:56:12 -05:00
|
|
|
p,
|
2009-02-04 12:05:26 -05:00
|
|
|
_row_labels->parent_to_component_x (r.get_x()),
|
|
|
|
_row_labels->parent_to_component_y (r.get_y()),
|
2009-01-20 09:46:00 -05:00
|
|
|
r.get_x(),
|
|
|
|
r.get_y(),
|
|
|
|
r.get_width(),
|
|
|
|
r.get_height()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
r = exposure;
|
2009-02-05 07:56:12 -05:00
|
|
|
p = _grid->get_pixmap (get_window()->gobj());
|
2009-02-04 12:05:26 -05:00
|
|
|
r.intersect (_grid->parent_rectangle(), intersects);
|
2009-01-20 09:46:00 -05:00
|
|
|
|
|
|
|
if (intersects) {
|
|
|
|
gdk_draw_drawable (
|
|
|
|
get_window()->gobj(),
|
|
|
|
get_style()->get_fg_gc (Gtk::STATE_NORMAL)->gobj(),
|
2009-02-05 07:56:12 -05:00
|
|
|
p,
|
2009-02-04 12:05:26 -05:00
|
|
|
_grid->parent_to_component_x (r.get_x()),
|
|
|
|
_grid->parent_to_component_y (r.get_y()),
|
2009-01-20 09:46:00 -05:00
|
|
|
r.get_x(),
|
|
|
|
r.get_y(),
|
|
|
|
r.get_width(),
|
|
|
|
r.get_height()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2009-01-26 23:21:13 -05:00
|
|
|
cairo_t* cr = gdk_cairo_create (get_window()->gobj());
|
2009-02-04 09:26:00 -05:00
|
|
|
|
|
|
|
cairo_save (cr);
|
2009-02-04 12:05:26 -05:00
|
|
|
set_cairo_clip (cr, _grid->parent_rectangle ());
|
|
|
|
_grid->draw_extra (cr);
|
2009-02-04 09:26:00 -05:00
|
|
|
cairo_restore (cr);
|
|
|
|
|
|
|
|
cairo_save (cr);
|
2009-02-04 12:05:26 -05:00
|
|
|
set_cairo_clip (cr, _row_labels->parent_rectangle ());
|
|
|
|
_row_labels->draw_extra (cr);
|
2009-02-04 09:26:00 -05:00
|
|
|
cairo_restore (cr);
|
|
|
|
|
|
|
|
cairo_save (cr);
|
2009-02-04 12:05:26 -05:00
|
|
|
set_cairo_clip (cr, _column_labels->parent_rectangle ());
|
|
|
|
_column_labels->draw_extra (cr);
|
2009-02-04 09:26:00 -05:00
|
|
|
cairo_restore (cr);
|
|
|
|
|
2009-01-26 23:21:13 -05:00
|
|
|
cairo_destroy (cr);
|
|
|
|
|
2009-01-20 09:46:00 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PortMatrixBody::on_size_request (Gtk::Requisition *req)
|
|
|
|
{
|
2009-07-17 18:54:45 -04:00
|
|
|
pair<int, int> const col = _column_labels->dimensions ();
|
|
|
|
pair<int, int> const row = _row_labels->dimensions ();
|
|
|
|
pair<int, int> const grid = _grid->dimensions ();
|
2009-01-20 09:46:00 -05:00
|
|
|
|
2009-01-30 10:08:09 -05:00
|
|
|
/* don't ask for the maximum size of our contents, otherwise GTK won't
|
|
|
|
let the containing window shrink below this size */
|
|
|
|
|
2009-02-09 21:09:46 -05:00
|
|
|
/* XXX these shouldn't be hard-coded */
|
|
|
|
int const min_width = 512;
|
|
|
|
int const min_height = 512;
|
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
req->width = min (min_width, max (col.first, grid.first + row.first));
|
|
|
|
req->height = min (min_height / _matrix->min_height_divisor(), col.second + grid.second);
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PortMatrixBody::on_size_allocate (Gtk::Allocation& alloc)
|
|
|
|
{
|
|
|
|
Gtk::EventBox::on_size_allocate (alloc);
|
|
|
|
|
|
|
|
_alloc_width = alloc.get_width ();
|
|
|
|
_alloc_height = alloc.get_height ();
|
|
|
|
|
2009-01-20 20:55:46 -05:00
|
|
|
compute_rectangles ();
|
2009-01-30 10:08:09 -05:00
|
|
|
_matrix->setup_scrollbars ();
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-01-20 20:55:46 -05:00
|
|
|
PortMatrixBody::compute_rectangles ()
|
2009-01-20 09:46:00 -05:00
|
|
|
{
|
2009-01-20 20:55:46 -05:00
|
|
|
/* full sizes of components */
|
2009-07-17 18:54:45 -04:00
|
|
|
pair<uint32_t, uint32_t> const col = _column_labels->dimensions ();
|
|
|
|
uint32_t col_overhang = _column_labels->overhang ();
|
|
|
|
pair<uint32_t, uint32_t> const row = _row_labels->dimensions ();
|
|
|
|
pair<uint32_t, uint32_t> const grid = _grid->dimensions ();
|
2009-01-20 20:55:46 -05:00
|
|
|
|
2009-01-26 23:21:13 -05:00
|
|
|
Gdk::Rectangle col_rect;
|
|
|
|
Gdk::Rectangle row_rect;
|
|
|
|
Gdk::Rectangle grid_rect;
|
|
|
|
|
2009-01-30 10:08:09 -05:00
|
|
|
if (_matrix->arrangement() == PortMatrix::TOP_TO_RIGHT) {
|
2009-01-20 20:55:46 -05:00
|
|
|
|
2009-01-26 23:21:13 -05:00
|
|
|
col_rect.set_x (0);
|
|
|
|
col_rect.set_y (0);
|
|
|
|
grid_rect.set_x (0);
|
2009-01-20 20:55:46 -05:00
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
col_rect.set_width (min (col.first, _alloc_width));
|
2009-01-20 20:55:46 -05:00
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
uint32_t const y = min (_alloc_height, col.second);
|
2009-01-26 23:21:13 -05:00
|
|
|
col_rect.set_height (y);
|
|
|
|
row_rect.set_y (y);
|
|
|
|
row_rect.set_height (_alloc_height - y);
|
|
|
|
grid_rect.set_y (y);
|
|
|
|
grid_rect.set_height (_alloc_height - y);
|
2009-01-20 20:55:46 -05:00
|
|
|
|
|
|
|
uint32_t x = 0;
|
|
|
|
if (_alloc_width > (grid.first + row.first)) {
|
|
|
|
x = grid.first;
|
|
|
|
} else if (_alloc_width > row.first) {
|
|
|
|
x = _alloc_width - row.first;
|
|
|
|
}
|
|
|
|
|
2009-01-26 23:21:13 -05:00
|
|
|
grid_rect.set_width (x);
|
|
|
|
row_rect.set_x (x);
|
|
|
|
row_rect.set_width (_alloc_width - x);
|
2009-01-20 20:55:46 -05:00
|
|
|
|
|
|
|
|
2009-01-30 10:08:09 -05:00
|
|
|
} else if (_matrix->arrangement() == PortMatrix::LEFT_TO_BOTTOM) {
|
2009-01-20 20:55:46 -05:00
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
col_rect.set_height (min (_alloc_height, col.second));
|
2009-07-19 15:07:31 -04:00
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
row_rect.set_x (0);
|
|
|
|
row_rect.set_y (0);
|
|
|
|
row_rect.set_width (min (_alloc_width, row.first));
|
|
|
|
row_rect.set_height (std::min (_alloc_height - col_rect.get_height(), row.second));
|
|
|
|
|
|
|
|
grid_rect.set_x (row_rect.get_width());
|
|
|
|
grid_rect.set_y (0);
|
|
|
|
grid_rect.set_width (std::min (_alloc_width - row_rect.get_width(), grid.first));
|
|
|
|
grid_rect.set_height (row_rect.get_height ());
|
|
|
|
|
|
|
|
col_rect.set_width (grid_rect.get_width () + col_overhang);
|
|
|
|
col_rect.set_x (row_rect.get_width() + grid_rect.get_width() - col_rect.get_width());
|
|
|
|
col_rect.set_y (row_rect.get_height());
|
2009-01-20 20:55:46 -05:00
|
|
|
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
2009-01-26 23:21:13 -05:00
|
|
|
|
2009-02-04 12:05:26 -05:00
|
|
|
_row_labels->set_parent_rectangle (row_rect);
|
|
|
|
_column_labels->set_parent_rectangle (col_rect);
|
|
|
|
_grid->set_parent_rectangle (grid_rect);
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-01-30 10:08:09 -05:00
|
|
|
PortMatrixBody::setup ()
|
2009-01-20 09:46:00 -05:00
|
|
|
{
|
2009-01-30 10:08:09 -05:00
|
|
|
/* Discard any old connections to bundles */
|
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
for (list<sigc::connection>::iterator i = _bundle_connections.begin(); i != _bundle_connections.end(); ++i) {
|
2009-01-20 09:46:00 -05:00
|
|
|
i->disconnect ();
|
|
|
|
}
|
|
|
|
_bundle_connections.clear ();
|
|
|
|
|
2009-01-30 10:08:09 -05:00
|
|
|
/* Connect to bundles so that we find out when their names change */
|
|
|
|
|
2009-07-17 09:18:58 -04:00
|
|
|
PortGroup::BundleList r = _matrix->rows()->bundles ();
|
|
|
|
for (PortGroup::BundleList::iterator i = r.begin(); i != r.end(); ++i) {
|
2009-01-20 09:46:00 -05:00
|
|
|
|
|
|
|
_bundle_connections.push_back (
|
2009-07-17 09:18:58 -04:00
|
|
|
i->bundle->Changed.connect (sigc::hide (sigc::mem_fun (*this, &PortMatrixBody::rebuild_and_draw_row_labels)))
|
2009-01-20 09:46:00 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-07-17 09:18:58 -04:00
|
|
|
PortGroup::BundleList c = _matrix->columns()->bundles ();
|
|
|
|
for (PortGroup::BundleList::iterator i = c.begin(); i != c.end(); ++i) {
|
2009-01-20 09:46:00 -05:00
|
|
|
_bundle_connections.push_back (
|
2009-07-17 09:18:58 -04:00
|
|
|
i->bundle->Changed.connect (sigc::hide (sigc::mem_fun (*this, &PortMatrixBody::rebuild_and_draw_column_labels)))
|
2009-01-20 09:46:00 -05:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2009-02-04 12:05:26 -05:00
|
|
|
_column_labels->setup ();
|
|
|
|
_row_labels->setup ();
|
|
|
|
_grid->setup ();
|
2009-01-20 09:46:00 -05:00
|
|
|
|
2009-02-02 08:59:50 -05:00
|
|
|
set_mouseover (PortMatrixNode ());
|
2009-01-20 20:55:46 -05:00
|
|
|
compute_rectangles ();
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
PortMatrixBody::full_scroll_width ()
|
|
|
|
{
|
2009-02-04 12:05:26 -05:00
|
|
|
return _grid->dimensions().first;
|
2009-01-20 09:46:00 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
PortMatrixBody::alloc_scroll_width ()
|
|
|
|
{
|
2009-02-04 12:05:26 -05:00
|
|
|
return _grid->parent_rectangle().get_width();
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
PortMatrixBody::full_scroll_height ()
|
|
|
|
{
|
2009-02-04 12:05:26 -05:00
|
|
|
return _grid->dimensions().second;
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
PortMatrixBody::alloc_scroll_height ()
|
|
|
|
{
|
2009-02-04 12:05:26 -05:00
|
|
|
return _grid->parent_rectangle().get_height();
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PortMatrixBody::set_xoffset (uint32_t xo)
|
|
|
|
{
|
|
|
|
_xoffset = xo;
|
|
|
|
queue_draw ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PortMatrixBody::set_yoffset (uint32_t yo)
|
|
|
|
{
|
|
|
|
_yoffset = yo;
|
|
|
|
queue_draw ();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PortMatrixBody::on_button_press_event (GdkEventButton* ev)
|
|
|
|
{
|
2009-02-04 12:05:26 -05:00
|
|
|
if (Gdk::Region (_grid->parent_rectangle()).point_in (ev->x, ev->y)) {
|
2009-01-20 20:55:46 -05:00
|
|
|
|
2009-02-04 12:05:26 -05:00
|
|
|
_grid->button_press (
|
|
|
|
_grid->parent_to_component_x (ev->x),
|
|
|
|
_grid->parent_to_component_y (ev->y),
|
2009-07-17 18:54:45 -04:00
|
|
|
ev->button, ev->time
|
2009-01-20 20:55:46 -05:00
|
|
|
);
|
|
|
|
|
2009-02-04 12:05:26 -05:00
|
|
|
} else if (Gdk::Region (_row_labels->parent_rectangle()).point_in (ev->x, ev->y)) {
|
2009-01-20 20:55:46 -05:00
|
|
|
|
2009-02-04 12:05:26 -05:00
|
|
|
_row_labels->button_press (
|
|
|
|
_row_labels->parent_to_component_x (ev->x),
|
|
|
|
_row_labels->parent_to_component_y (ev->y),
|
2009-01-20 20:55:46 -05:00
|
|
|
ev->button, ev->time
|
|
|
|
);
|
|
|
|
|
2009-02-04 12:05:26 -05:00
|
|
|
} else if (Gdk::Region (_column_labels->parent_rectangle()).point_in (ev->x, ev->y)) {
|
2009-01-30 10:08:09 -05:00
|
|
|
|
2009-02-04 12:05:26 -05:00
|
|
|
_column_labels->button_press (
|
|
|
|
_column_labels->parent_to_component_x (ev->x),
|
|
|
|
_column_labels->parent_to_component_y (ev->y),
|
2009-01-30 10:08:09 -05:00
|
|
|
ev->button, ev->time
|
|
|
|
);
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-02-02 20:55:25 -05:00
|
|
|
bool
|
|
|
|
PortMatrixBody::on_button_release_event (GdkEventButton* ev)
|
|
|
|
{
|
2009-02-04 12:05:26 -05:00
|
|
|
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)) {
|
2009-02-02 20:55:25 -05:00
|
|
|
|
2009-02-04 12:05:26 -05:00
|
|
|
_row_labels->clear_channel_highlights ();
|
|
|
|
_column_labels->clear_channel_highlights ();
|
2009-02-02 20:55:25 -05:00
|
|
|
|
2009-07-17 22:10:15 -04:00
|
|
|
} else if (Gdk::Region (_grid->parent_rectangle()).point_in (ev->x, ev->y)) {
|
|
|
|
|
|
|
|
_grid->button_release (
|
|
|
|
_grid->parent_to_component_x (ev->x),
|
|
|
|
_grid->parent_to_component_y (ev->y),
|
|
|
|
ev->button, ev->time
|
|
|
|
);
|
|
|
|
|
2009-02-02 20:55:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-01-20 09:46:00 -05:00
|
|
|
void
|
2009-01-21 22:38:40 -05:00
|
|
|
PortMatrixBody::rebuild_and_draw_grid ()
|
2009-01-20 09:46:00 -05:00
|
|
|
{
|
2009-02-04 12:05:26 -05:00
|
|
|
_grid->require_rebuild ();
|
2009-01-20 09:46:00 -05:00
|
|
|
queue_draw ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-01-21 22:38:40 -05:00
|
|
|
PortMatrixBody::rebuild_and_draw_column_labels ()
|
2009-01-20 09:46:00 -05:00
|
|
|
{
|
2009-02-04 12:05:26 -05:00
|
|
|
_column_labels->require_rebuild ();
|
2009-01-20 09:46:00 -05:00
|
|
|
queue_draw ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-01-21 22:38:40 -05:00
|
|
|
PortMatrixBody::rebuild_and_draw_row_labels ()
|
2009-01-20 09:46:00 -05:00
|
|
|
{
|
2009-02-04 12:05:26 -05:00
|
|
|
_row_labels->require_rebuild ();
|
2009-01-20 09:46:00 -05:00
|
|
|
queue_draw ();
|
|
|
|
}
|
2009-01-26 23:21:13 -05:00
|
|
|
|
|
|
|
bool
|
2009-02-02 08:59:50 -05:00
|
|
|
PortMatrixBody::on_leave_notify_event (GdkEventCrossing* ev)
|
2009-01-26 23:21:13 -05:00
|
|
|
{
|
2009-02-02 08:59:50 -05:00
|
|
|
if (ev->type == GDK_LEAVE_NOTIFY) {
|
|
|
|
set_mouseover (PortMatrixNode ());
|
2009-01-26 23:21:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PortMatrixBody::on_motion_notify_event (GdkEventMotion* ev)
|
|
|
|
{
|
2009-02-04 12:05:26 -05:00
|
|
|
if (Gdk::Region (_grid->parent_rectangle()).point_in (ev->x, ev->y)) {
|
2009-07-17 22:10:15 -04:00
|
|
|
|
|
|
|
_grid->motion (
|
2009-02-04 12:05:26 -05:00
|
|
|
_grid->parent_to_component_x (ev->x),
|
|
|
|
_grid->parent_to_component_y (ev->y)
|
2009-01-26 23:21:13 -05:00
|
|
|
);
|
2009-07-17 22:10:15 -04:00
|
|
|
|
2009-02-02 20:55:25 -05:00
|
|
|
_mouse_over_grid = true;
|
2009-07-17 22:10:15 -04:00
|
|
|
|
2009-02-02 20:55:25 -05:00
|
|
|
} else {
|
|
|
|
if (_mouse_over_grid) {
|
|
|
|
set_mouseover (PortMatrixNode ());
|
|
|
|
_mouse_over_grid = false;
|
|
|
|
}
|
2009-01-26 23:21:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PortMatrixBody::set_mouseover (PortMatrixNode const & n)
|
|
|
|
{
|
|
|
|
if (n == _mouseover) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
PortMatrixNode old = _mouseover;
|
|
|
|
_mouseover = n;
|
|
|
|
|
2009-02-04 12:05:26 -05:00
|
|
|
_grid->mouseover_changed (old);
|
|
|
|
_row_labels->mouseover_changed (old);
|
|
|
|
_column_labels->mouseover_changed (old);
|
2009-01-26 23:21:13 -05:00
|
|
|
}
|
2009-02-02 20:55:25 -05:00
|
|
|
|
|
|
|
void
|
2009-07-17 18:54:45 -04:00
|
|
|
PortMatrixBody::highlight_associated_channels (int dim, ARDOUR::BundleChannel h)
|
2009-02-02 20:55:25 -05:00
|
|
|
{
|
|
|
|
ARDOUR::BundleChannel bc[2];
|
2009-07-17 18:54:45 -04:00
|
|
|
bc[dim] = h;
|
2009-02-02 20:55:25 -05:00
|
|
|
|
|
|
|
if (!bc[dim].bundle) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dim == _matrix->column_index()) {
|
2009-02-04 12:05:26 -05:00
|
|
|
_column_labels->add_channel_highlight (bc[dim]);
|
2009-02-02 20:55:25 -05:00
|
|
|
} else {
|
2009-02-04 12:05:26 -05:00
|
|
|
_row_labels->add_channel_highlight (bc[dim]);
|
2009-02-02 20:55:25 -05:00
|
|
|
}
|
|
|
|
|
2009-07-17 09:18:58 -04:00
|
|
|
PortGroup::BundleList const b = _matrix->ports(1 - dim)->bundles ();
|
2009-02-02 20:55:25 -05:00
|
|
|
|
2009-07-17 09:18:58 -04:00
|
|
|
for (PortGroup::BundleList::const_iterator i = b.begin(); i != b.end(); ++i) {
|
|
|
|
for (uint32_t j = 0; j < i->bundle->nchannels(); ++j) {
|
|
|
|
bc[1 - dim] = ARDOUR::BundleChannel (i->bundle, j);
|
2009-05-03 10:31:42 -04:00
|
|
|
if (_matrix->get_state (bc) == PortMatrixNode::ASSOCIATED) {
|
2009-02-02 20:55:25 -05:00
|
|
|
if (dim == _matrix->column_index()) {
|
2009-02-04 12:05:26 -05:00
|
|
|
_row_labels->add_channel_highlight (bc[1 - dim]);
|
2009-02-02 20:55:25 -05:00
|
|
|
} else {
|
2009-02-04 12:05:26 -05:00
|
|
|
_column_labels->add_channel_highlight (bc[1 - dim]);
|
2009-02-02 20:55:25 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-02-04 09:26:00 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
PortMatrixBody::set_cairo_clip (cairo_t* cr, Gdk::Rectangle const & r) const
|
|
|
|
{
|
|
|
|
cairo_rectangle (cr, r.get_x(), r.get_y(), r.get_width(), r.get_height());
|
|
|
|
cairo_clip (cr);
|
|
|
|
}
|
2009-02-05 07:56:12 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
PortMatrixBody::component_size_changed ()
|
|
|
|
{
|
|
|
|
compute_rectangles ();
|
2009-07-18 09:10:08 -04:00
|
|
|
_matrix->setup_max_size ();
|
2009-02-05 07:56:12 -05:00
|
|
|
_matrix->setup_scrollbars ();
|
|
|
|
}
|
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
pair<uint32_t, uint32_t>
|
|
|
|
PortMatrixBody::max_size () const
|
|
|
|
{
|
|
|
|
pair<uint32_t, uint32_t> const col = _column_labels->dimensions ();
|
|
|
|
pair<uint32_t, uint32_t> const row = _row_labels->dimensions ();
|
|
|
|
pair<uint32_t, uint32_t> const grid = _grid->dimensions ();
|
|
|
|
|
|
|
|
return make_pair (std::max (row.first, _column_labels->overhang()) + grid.first, col.second + grid.second);
|
|
|
|
}
|