mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-09 00:04:56 +01:00
More logical arrangement of port matrix inputs and outputs, hopefully;
signal show notionally "flow" from left to bottom or from top to right. Some layout cleanups. git-svn-id: svn://localhost/ardour2/branches/3.0@4416 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
61db2175eb
commit
4476461443
7 changed files with 246 additions and 109 deletions
|
|
@ -35,7 +35,7 @@ PortMatrix::PortMatrix (ARDOUR::Session& session, ARDOUR::DataType type, bool of
|
||||||
: _offer_inputs (offer_inputs),
|
: _offer_inputs (offer_inputs),
|
||||||
_port_group_list (session, type, offer_inputs, mask),
|
_port_group_list (session, type, offer_inputs, mask),
|
||||||
_type (type),
|
_type (type),
|
||||||
_body (this)
|
_body (this, offer_inputs ? PortMatrixBody::BOTTOM_AND_LEFT : PortMatrixBody::TOP_AND_RIGHT)
|
||||||
{
|
{
|
||||||
/* checkbuttons for visibility of groups */
|
/* checkbuttons for visibility of groups */
|
||||||
Gtk::HBox* visibility_buttons = Gtk::manage (new Gtk::HBox);
|
Gtk::HBox* visibility_buttons = Gtk::manage (new Gtk::HBox);
|
||||||
|
|
|
||||||
|
|
@ -22,19 +22,16 @@
|
||||||
#include "port_matrix_body.h"
|
#include "port_matrix_body.h"
|
||||||
#include "port_matrix.h"
|
#include "port_matrix.h"
|
||||||
|
|
||||||
PortMatrixBody::PortMatrixBody (PortMatrix* p)
|
PortMatrixBody::PortMatrixBody (PortMatrix* p, Arrangement a)
|
||||||
: _port_matrix (p),
|
: _port_matrix (p),
|
||||||
_column_labels (this),
|
_column_labels (this, a == TOP_AND_RIGHT ? PortMatrixColumnLabels::TOP : PortMatrixColumnLabels::BOTTOM),
|
||||||
_row_labels (p, this),
|
_row_labels (p, this, a == BOTTOM_AND_LEFT ? PortMatrixRowLabels::LEFT : PortMatrixRowLabels::RIGHT),
|
||||||
_grid (p, this),
|
_grid (p, this),
|
||||||
_alloc_width (0),
|
_arrangement (a),
|
||||||
_alloc_height (0),
|
|
||||||
_alloc_xdiv (0),
|
|
||||||
_alloc_ydiv (0),
|
|
||||||
_xoffset (0),
|
_xoffset (0),
|
||||||
_yoffset (0)
|
_yoffset (0)
|
||||||
{
|
{
|
||||||
|
modify_bg (Gtk::STATE_NORMAL, Gdk::Color ("#00000"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -45,21 +42,17 @@ PortMatrixBody::on_expose_event (GdkEventExpose* event)
|
||||||
event->area.x, event->area.y, event->area.width, event->area.height
|
event->area.x, event->area.y, event->area.width, event->area.height
|
||||||
);
|
);
|
||||||
|
|
||||||
Gdk::Rectangle const col (0, 0, _alloc_width, _alloc_ydiv);
|
|
||||||
Gdk::Rectangle const row (_alloc_xdiv, _alloc_ydiv, _alloc_width - _alloc_xdiv, _alloc_height - _alloc_ydiv);
|
|
||||||
Gdk::Rectangle const grid (0, _alloc_ydiv, _alloc_xdiv, _alloc_height - _alloc_ydiv);
|
|
||||||
|
|
||||||
bool intersects;
|
bool intersects;
|
||||||
Gdk::Rectangle r = exposure;
|
Gdk::Rectangle r = exposure;
|
||||||
r.intersect (col, intersects);
|
r.intersect (_column_labels_rect, intersects);
|
||||||
|
|
||||||
if (intersects) {
|
if (intersects) {
|
||||||
gdk_draw_drawable (
|
gdk_draw_drawable (
|
||||||
get_window()->gobj(),
|
get_window()->gobj(),
|
||||||
get_style()->get_fg_gc (Gtk::STATE_NORMAL)->gobj(),
|
get_style()->get_fg_gc (Gtk::STATE_NORMAL)->gobj(),
|
||||||
_column_labels.get_pixmap (get_window()->gobj()),
|
_column_labels.get_pixmap (get_window()->gobj()),
|
||||||
r.get_x() + _xoffset,
|
r.get_x() - _column_labels_rect.get_x() + _xoffset,
|
||||||
r.get_y(),
|
r.get_y() - _column_labels_rect.get_y(),
|
||||||
r.get_x(),
|
r.get_x(),
|
||||||
r.get_y(),
|
r.get_y(),
|
||||||
r.get_width(),
|
r.get_width(),
|
||||||
|
|
@ -68,15 +61,15 @@ PortMatrixBody::on_expose_event (GdkEventExpose* event)
|
||||||
}
|
}
|
||||||
|
|
||||||
r = exposure;
|
r = exposure;
|
||||||
r.intersect (row, intersects);
|
r.intersect (_row_labels_rect, intersects);
|
||||||
|
|
||||||
if (intersects) {
|
if (intersects) {
|
||||||
gdk_draw_drawable (
|
gdk_draw_drawable (
|
||||||
get_window()->gobj(),
|
get_window()->gobj(),
|
||||||
get_style()->get_fg_gc (Gtk::STATE_NORMAL)->gobj(),
|
get_style()->get_fg_gc (Gtk::STATE_NORMAL)->gobj(),
|
||||||
_row_labels.get_pixmap (get_window()->gobj()),
|
_row_labels.get_pixmap (get_window()->gobj()),
|
||||||
r.get_x() - _alloc_xdiv,
|
r.get_x() - _row_labels_rect.get_x(),
|
||||||
r.get_y() + _yoffset - _alloc_ydiv,
|
r.get_y() - _row_labels_rect.get_y() + _yoffset,
|
||||||
r.get_x(),
|
r.get_x(),
|
||||||
r.get_y(),
|
r.get_y(),
|
||||||
r.get_width(),
|
r.get_width(),
|
||||||
|
|
@ -85,15 +78,15 @@ PortMatrixBody::on_expose_event (GdkEventExpose* event)
|
||||||
}
|
}
|
||||||
|
|
||||||
r = exposure;
|
r = exposure;
|
||||||
r.intersect (grid, intersects);
|
r.intersect (_grid_rect, intersects);
|
||||||
|
|
||||||
if (intersects) {
|
if (intersects) {
|
||||||
gdk_draw_drawable (
|
gdk_draw_drawable (
|
||||||
get_window()->gobj(),
|
get_window()->gobj(),
|
||||||
get_style()->get_fg_gc (Gtk::STATE_NORMAL)->gobj(),
|
get_style()->get_fg_gc (Gtk::STATE_NORMAL)->gobj(),
|
||||||
_grid.get_pixmap (get_window()->gobj()),
|
_grid.get_pixmap (get_window()->gobj()),
|
||||||
r.get_x() + _xoffset,
|
r.get_x() - _grid_rect.get_x() + _xoffset,
|
||||||
r.get_y() + _yoffset - _alloc_ydiv,
|
r.get_y() - _grid_rect.get_y() + _yoffset,
|
||||||
r.get_x(),
|
r.get_x(),
|
||||||
r.get_y(),
|
r.get_y(),
|
||||||
r.get_width(),
|
r.get_width(),
|
||||||
|
|
@ -124,37 +117,100 @@ PortMatrixBody::on_size_allocate (Gtk::Allocation& alloc)
|
||||||
_alloc_width = alloc.get_width ();
|
_alloc_width = alloc.get_width ();
|
||||||
_alloc_height = alloc.get_height ();
|
_alloc_height = alloc.get_height ();
|
||||||
|
|
||||||
compute_divs ();
|
compute_rectangles ();
|
||||||
_port_matrix->setup_scrollbars ();
|
_port_matrix->setup_scrollbars ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PortMatrixBody::compute_divs ()
|
PortMatrixBody::compute_rectangles ()
|
||||||
{
|
{
|
||||||
|
/* full sizes of components */
|
||||||
std::pair<uint32_t, uint32_t> const col = _column_labels.dimensions ();
|
std::pair<uint32_t, uint32_t> const col = _column_labels.dimensions ();
|
||||||
if (_alloc_height > col.second) {
|
std::pair<uint32_t, uint32_t> const row = _row_labels.dimensions ();
|
||||||
/* allocated height is enough for the column labels */
|
std::pair<uint32_t, uint32_t> const grid = _grid.dimensions ();
|
||||||
_alloc_ydiv = col.second;
|
|
||||||
|
if (_arrangement == TOP_AND_RIGHT) {
|
||||||
|
|
||||||
|
/* build from top left */
|
||||||
|
|
||||||
|
_column_labels_rect.set_x (0);
|
||||||
|
_column_labels_rect.set_y (0);
|
||||||
|
_grid_rect.set_x (0);
|
||||||
|
|
||||||
|
if (_alloc_width > col.first) {
|
||||||
|
_column_labels_rect.set_width (col.first);
|
||||||
} else {
|
} else {
|
||||||
/* not enough space for the column labels */
|
_column_labels_rect.set_width (_alloc_width);
|
||||||
_alloc_ydiv = _alloc_height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<uint32_t, uint32_t> const grid = _grid.dimensions ();
|
/* move down to y division */
|
||||||
std::pair<uint32_t, uint32_t> const row = _row_labels.dimensions ();
|
|
||||||
|
|
||||||
if (_alloc_width > (grid.first + row.first)) {
|
uint32_t y = 0;
|
||||||
/* allocated width is larger than we need, so
|
if (_alloc_height > col.second) {
|
||||||
put the x division at the extent of the grid */
|
y = col.second;
|
||||||
_alloc_xdiv = grid.first;
|
|
||||||
} else if (_alloc_width > row.first) {
|
|
||||||
/* allocated width is large enough for the row labels
|
|
||||||
but not for the whole grid, so display the whole
|
|
||||||
row label section and cut part of the grid off */
|
|
||||||
_alloc_xdiv = _alloc_width - row.first;
|
|
||||||
} else {
|
} else {
|
||||||
/* allocated width isn't even enough for the row labels */
|
y = _alloc_height;
|
||||||
_alloc_xdiv = 0;
|
}
|
||||||
|
|
||||||
|
_column_labels_rect.set_height (y);
|
||||||
|
_row_labels_rect.set_y (y);
|
||||||
|
_row_labels_rect.set_height (_alloc_height - y);
|
||||||
|
_grid_rect.set_y (y);
|
||||||
|
_grid_rect.set_height (_alloc_height - y);
|
||||||
|
|
||||||
|
/* move right to x division */
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
_grid_rect.set_width (x);
|
||||||
|
_row_labels_rect.set_x (x);
|
||||||
|
_row_labels_rect.set_width (_alloc_width - x);
|
||||||
|
|
||||||
|
|
||||||
|
} else if (_arrangement == BOTTOM_AND_LEFT) {
|
||||||
|
|
||||||
|
/* build from bottom right */
|
||||||
|
|
||||||
|
/* move left to x division */
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
_grid_rect.set_x (_alloc_width - x);
|
||||||
|
_grid_rect.set_width (x);
|
||||||
|
_column_labels_rect.set_width (std::min (_alloc_width, col.first));
|
||||||
|
_column_labels_rect.set_x (_alloc_width - _column_labels_rect.get_width());
|
||||||
|
|
||||||
|
_row_labels_rect.set_width (std::min (_alloc_width - x, row.first));
|
||||||
|
_row_labels_rect.set_x (_alloc_width - x - _row_labels_rect.get_width());
|
||||||
|
|
||||||
|
/* move up to the y division */
|
||||||
|
|
||||||
|
uint32_t y = 0;
|
||||||
|
if (_alloc_height > col.second) {
|
||||||
|
y = col.second;
|
||||||
|
} else {
|
||||||
|
y = _alloc_height;
|
||||||
|
}
|
||||||
|
|
||||||
|
_column_labels_rect.set_y (_alloc_height - y);
|
||||||
|
_column_labels_rect.set_height (y);
|
||||||
|
|
||||||
|
_grid_rect.set_height (std::min (grid.second, _alloc_height - y));
|
||||||
|
_grid_rect.set_y (_alloc_height - y - _grid_rect.get_height());
|
||||||
|
|
||||||
|
_row_labels_rect.set_height (_grid_rect.get_height());
|
||||||
|
_row_labels_rect.set_y (_grid_rect.get_y());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -191,7 +247,7 @@ PortMatrixBody::setup (
|
||||||
_row_labels.setup ();
|
_row_labels.setup ();
|
||||||
_grid.setup ();
|
_grid.setup ();
|
||||||
|
|
||||||
compute_divs ();
|
compute_rectangles ();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
|
|
@ -204,7 +260,7 @@ PortMatrixBody::full_scroll_width ()
|
||||||
uint32_t
|
uint32_t
|
||||||
PortMatrixBody::alloc_scroll_width ()
|
PortMatrixBody::alloc_scroll_width ()
|
||||||
{
|
{
|
||||||
return _alloc_xdiv;
|
return _grid_rect.get_width();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
|
|
@ -216,7 +272,7 @@ PortMatrixBody::full_scroll_height ()
|
||||||
uint32_t
|
uint32_t
|
||||||
PortMatrixBody::alloc_scroll_height ()
|
PortMatrixBody::alloc_scroll_height ()
|
||||||
{
|
{
|
||||||
return _alloc_height - _alloc_ydiv;
|
return _grid_rect.get_height();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -236,12 +292,26 @@ PortMatrixBody::set_yoffset (uint32_t yo)
|
||||||
bool
|
bool
|
||||||
PortMatrixBody::on_button_press_event (GdkEventButton* ev)
|
PortMatrixBody::on_button_press_event (GdkEventButton* ev)
|
||||||
{
|
{
|
||||||
if (ev->x < _alloc_xdiv && ev->y > _alloc_ydiv) {
|
if (Gdk::Region (_grid_rect).point_in (ev->x, ev->y)) {
|
||||||
_grid.button_press (ev->x + _xoffset, ev->y + _yoffset - _alloc_ydiv, ev->button);
|
|
||||||
} else if (ev->x > _alloc_xdiv && ev->y > _alloc_ydiv) {
|
_grid.button_press (
|
||||||
_row_labels.button_press (ev->x - _alloc_xdiv, ev->y + _yoffset - _alloc_ydiv, ev->button, ev->time);
|
ev->x - _grid_rect.get_x() + _xoffset,
|
||||||
|
ev->y - _grid_rect.get_y() + _yoffset,
|
||||||
|
ev->button
|
||||||
|
);
|
||||||
|
|
||||||
|
} else if (Gdk::Region (_row_labels_rect).point_in (ev->x, ev->y)) {
|
||||||
|
|
||||||
|
_row_labels.button_press (
|
||||||
|
ev->x - _row_labels_rect.get_x(),
|
||||||
|
ev->y - _row_labels_rect.get_y() + _yoffset,
|
||||||
|
ev->button, ev->time
|
||||||
|
);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,12 @@ class PortMatrix;
|
||||||
class PortMatrixBody : public Gtk::EventBox
|
class PortMatrixBody : public Gtk::EventBox
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PortMatrixBody (PortMatrix *);
|
enum Arrangement {
|
||||||
|
TOP_AND_RIGHT,
|
||||||
|
BOTTOM_AND_LEFT
|
||||||
|
};
|
||||||
|
|
||||||
|
PortMatrixBody (PortMatrix *, Arrangement);
|
||||||
|
|
||||||
/** @return bundles to offer for columns */
|
/** @return bundles to offer for columns */
|
||||||
std::vector<boost::shared_ptr<ARDOUR::Bundle> > const & column_bundles () {
|
std::vector<boost::shared_ptr<ARDOUR::Bundle> > const & column_bundles () {
|
||||||
|
|
@ -67,7 +72,7 @@ protected:
|
||||||
bool on_button_press_event (GdkEventButton *);
|
bool on_button_press_event (GdkEventButton *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void compute_divs ();
|
void compute_rectangles ();
|
||||||
void repaint_column_labels ();
|
void repaint_column_labels ();
|
||||||
void repaint_row_labels ();
|
void repaint_row_labels ();
|
||||||
|
|
||||||
|
|
@ -76,10 +81,12 @@ private:
|
||||||
PortMatrixRowLabels _row_labels;
|
PortMatrixRowLabels _row_labels;
|
||||||
PortMatrixGrid _grid;
|
PortMatrixGrid _grid;
|
||||||
|
|
||||||
|
Arrangement _arrangement;
|
||||||
uint32_t _alloc_width; ///< allocated width
|
uint32_t _alloc_width; ///< allocated width
|
||||||
uint32_t _alloc_height; ///< allocated height
|
uint32_t _alloc_height; ///< allocated height
|
||||||
uint32_t _alloc_xdiv; ///< position of the division between grid and row labels
|
Gdk::Rectangle _column_labels_rect;
|
||||||
uint32_t _alloc_ydiv; ///< position of the division between column labels and grid
|
Gdk::Rectangle _row_labels_rect;
|
||||||
|
Gdk::Rectangle _grid_rect;
|
||||||
uint32_t _xoffset;
|
uint32_t _xoffset;
|
||||||
uint32_t _yoffset;
|
uint32_t _yoffset;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@
|
||||||
#include "port_matrix_column_labels.h"
|
#include "port_matrix_column_labels.h"
|
||||||
#include "port_matrix.h"
|
#include "port_matrix.h"
|
||||||
|
|
||||||
PortMatrixColumnLabels::PortMatrixColumnLabels (PortMatrixBody* b)
|
PortMatrixColumnLabels::PortMatrixColumnLabels (PortMatrixBody* b, Location l)
|
||||||
: PortMatrixComponent (b)
|
: PortMatrixComponent (b), _location (l)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -87,7 +87,7 @@ PortMatrixColumnLabels::compute_dimensions ()
|
||||||
_width += _height / tan (angle ());
|
_width += _height / tan (angle ());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
double
|
||||||
PortMatrixColumnLabels::basic_text_x_pos (int c) const
|
PortMatrixColumnLabels::basic_text_x_pos (int c) const
|
||||||
{
|
{
|
||||||
return column_width() / 2 +
|
return column_width() / 2 +
|
||||||
|
|
@ -105,16 +105,16 @@ PortMatrixColumnLabels::render (cairo_t* cr)
|
||||||
|
|
||||||
/* BUNDLE PARALLELOGRAM-TYPE-THING AND NAME */
|
/* BUNDLE PARALLELOGRAM-TYPE-THING AND NAME */
|
||||||
|
|
||||||
uint32_t x = 0;
|
double x = 0;
|
||||||
for (std::vector<boost::shared_ptr<ARDOUR::Bundle> >::const_iterator i = _body->column_bundles().begin (); i != _body->column_bundles().end(); ++i) {
|
for (std::vector<boost::shared_ptr<ARDOUR::Bundle> >::const_iterator i = _body->column_bundles().begin (); i != _body->column_bundles().end(); ++i) {
|
||||||
|
|
||||||
Gdk::Color colour = get_a_bundle_colour (i - _body->column_bundles().begin ());
|
Gdk::Color colour = get_a_bundle_colour (i - _body->column_bundles().begin ());
|
||||||
set_source_rgb (cr, colour);
|
set_source_rgb (cr, colour);
|
||||||
|
|
||||||
uint32_t const w = (*i)->nchannels() * column_width();
|
double const w = (*i)->nchannels() * column_width();
|
||||||
|
|
||||||
uint32_t x_ = x;
|
double x_ = x;
|
||||||
uint32_t y_ = _height;
|
double y_ = _height;
|
||||||
|
|
||||||
cairo_move_to (cr, x_, y_);
|
cairo_move_to (cr, x_, y_);
|
||||||
x_ += w;
|
x_ += w;
|
||||||
|
|
@ -132,14 +132,25 @@ PortMatrixColumnLabels::render (cairo_t* cr)
|
||||||
|
|
||||||
set_source_rgb (cr, text_colour());
|
set_source_rgb (cr, text_colour());
|
||||||
|
|
||||||
uint32_t const rl = 3 * name_pad() + _longest_channel_name;
|
|
||||||
|
|
||||||
|
if (_location == TOP) {
|
||||||
|
|
||||||
|
double const rl = 3 * name_pad() + _longest_channel_name;
|
||||||
cairo_move_to (
|
cairo_move_to (
|
||||||
cr,
|
cr,
|
||||||
x + basic_text_x_pos (0) + rl * cos (angle()),
|
x + basic_text_x_pos (0) + rl * cos (angle()),
|
||||||
_height - rl * sin (angle())
|
_height - rl * sin (angle())
|
||||||
);
|
);
|
||||||
|
|
||||||
|
} else if (_location == BOTTOM) {
|
||||||
|
|
||||||
|
cairo_move_to (
|
||||||
|
cr,
|
||||||
|
x + basic_text_x_pos (0),
|
||||||
|
_height - name_pad() * sin (angle())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
cairo_save (cr);
|
cairo_save (cr);
|
||||||
cairo_rotate (cr, -angle());
|
cairo_rotate (cr, -angle());
|
||||||
cairo_show_text (cr, (*i)->name().c_str());
|
cairo_show_text (cr, (*i)->name().c_str());
|
||||||
|
|
@ -156,22 +167,43 @@ PortMatrixColumnLabels::render (cairo_t* cr)
|
||||||
|
|
||||||
for (uint32_t j = 0; j < (*i)->nchannels(); ++j) {
|
for (uint32_t j = 0; j < (*i)->nchannels(); ++j) {
|
||||||
|
|
||||||
uint32_t const p = _longest_channel_name + (2 * name_pad());
|
double const lc = _longest_channel_name + (2 * name_pad());
|
||||||
uint32_t const w = column_width();
|
double const lb = _longest_bundle_name + (2 * name_pad());
|
||||||
|
double const w = column_width();
|
||||||
|
|
||||||
uint32_t x_ = x;
|
if (_location == BOTTOM) {
|
||||||
uint32_t y_ = _height;
|
|
||||||
|
double x_ = x + _height / tan (angle()) + w;
|
||||||
|
double const ix = x_;
|
||||||
|
double y_ = 0;
|
||||||
|
cairo_move_to (cr, x_, y_);
|
||||||
|
x_ -= w;
|
||||||
|
cairo_line_to (cr, x_, y_);
|
||||||
|
x_ -= lb * cos (angle());
|
||||||
|
y_ += lb * sin (angle());
|
||||||
|
cairo_line_to (cr, x_, y_);
|
||||||
|
x_ += w * pow (sin (angle()), 2);
|
||||||
|
y_ += w * sin (angle()) * cos (angle());
|
||||||
|
cairo_line_to (cr, x_, y_);
|
||||||
|
cairo_line_to (cr, ix, 0);
|
||||||
|
|
||||||
|
} else if (_location == TOP) {
|
||||||
|
|
||||||
|
double x_ = x;
|
||||||
|
double y_ = _height;
|
||||||
cairo_move_to (cr, x_, y_);
|
cairo_move_to (cr, x_, y_);
|
||||||
x_ += w;
|
x_ += w;
|
||||||
cairo_line_to (cr, x_, y_);
|
cairo_line_to (cr, x_, y_);
|
||||||
x_ += p * cos (angle());
|
x_ += lc * cos (angle());
|
||||||
y_ -= p * sin (angle());
|
y_ -= lc * sin (angle());
|
||||||
cairo_line_to (cr, x_, y_);
|
cairo_line_to (cr, x_, y_);
|
||||||
x_ -= column_width() * pow (sin (angle()), 2);
|
x_ -= column_width() * pow (sin (angle()), 2);
|
||||||
y_ -= column_width() * sin (angle()) * cos (angle());
|
y_ -= column_width() * sin (angle()) * cos (angle());
|
||||||
cairo_line_to (cr, x_, y_);
|
cairo_line_to (cr, x_, y_);
|
||||||
cairo_line_to (cr, x, _height);
|
cairo_line_to (cr, x, _height);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Gdk::Color colour = get_a_bundle_colour (i - _body->column_bundles().begin());
|
Gdk::Color colour = get_a_bundle_colour (i - _body->column_bundles().begin());
|
||||||
set_source_rgb (cr, colour);
|
set_source_rgb (cr, colour);
|
||||||
cairo_fill_preserve (cr);
|
cairo_fill_preserve (cr);
|
||||||
|
|
@ -180,7 +212,13 @@ PortMatrixColumnLabels::render (cairo_t* cr)
|
||||||
cairo_stroke (cr);
|
cairo_stroke (cr);
|
||||||
|
|
||||||
set_source_rgb (cr, text_colour());
|
set_source_rgb (cr, text_colour());
|
||||||
|
|
||||||
|
if (_location == TOP) {
|
||||||
cairo_move_to (cr, x + basic_text_x_pos(j), _height - name_pad() * sin (angle()));
|
cairo_move_to (cr, x + basic_text_x_pos(j), _height - name_pad() * sin (angle()));
|
||||||
|
} else if (_location == BOTTOM) {
|
||||||
|
double const rl = 3 * name_pad() + _longest_bundle_name;
|
||||||
|
cairo_move_to (cr, x + basic_text_x_pos(j) + rl * cos (angle ()), _height - rl * sin (angle()));
|
||||||
|
}
|
||||||
|
|
||||||
cairo_save (cr);
|
cairo_save (cr);
|
||||||
cairo_rotate (cr, -angle());
|
cairo_rotate (cr, -angle());
|
||||||
|
|
|
||||||
|
|
@ -33,17 +33,24 @@ namespace ARDOUR {
|
||||||
class PortMatrixColumnLabels : public PortMatrixComponent
|
class PortMatrixColumnLabels : public PortMatrixComponent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PortMatrixColumnLabels (PortMatrixBody *);
|
|
||||||
|
enum Location {
|
||||||
|
TOP,
|
||||||
|
BOTTOM
|
||||||
|
};
|
||||||
|
|
||||||
|
PortMatrixColumnLabels (PortMatrixBody *, Location);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void render (cairo_t *);
|
void render (cairo_t *);
|
||||||
void compute_dimensions ();
|
void compute_dimensions ();
|
||||||
uint32_t basic_text_x_pos (int) const;
|
double basic_text_x_pos (int) const;
|
||||||
|
|
||||||
std::vector<boost::shared_ptr<ARDOUR::Bundle> > _bundles;
|
std::vector<boost::shared_ptr<ARDOUR::Bundle> > _bundles;
|
||||||
uint32_t _longest_bundle_name;
|
double _longest_bundle_name;
|
||||||
uint32_t _longest_channel_name;
|
double _longest_channel_name;
|
||||||
uint32_t _highest_text;
|
double _highest_text;
|
||||||
|
Location _location;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@
|
||||||
#include "port_matrix.h"
|
#include "port_matrix.h"
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
|
|
||||||
PortMatrixRowLabels::PortMatrixRowLabels (PortMatrix* p, PortMatrixBody* b)
|
PortMatrixRowLabels::PortMatrixRowLabels (PortMatrix* p, PortMatrixBody* b, Location l)
|
||||||
: PortMatrixComponent (b), _port_matrix (p), _menu (0)
|
: PortMatrixComponent (b), _port_matrix (p), _menu (0), _location (l)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -74,9 +74,7 @@ PortMatrixRowLabels::compute_dimensions ()
|
||||||
_height += (*i)->nchannels() * row_height();
|
_height += (*i)->nchannels() * row_height();
|
||||||
}
|
}
|
||||||
|
|
||||||
_width = _longest_port_name +
|
_width = _longest_port_name + name_pad() * 4 + _longest_bundle_name;
|
||||||
name_pad() * 4 +
|
|
||||||
_longest_bundle_name + name_pad() * 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -91,20 +89,19 @@ PortMatrixRowLabels::render (cairo_t* cr)
|
||||||
|
|
||||||
/* SIDE BUNDLE NAMES */
|
/* SIDE BUNDLE NAMES */
|
||||||
|
|
||||||
uint32_t x = _longest_port_name + name_pad() * 3;
|
uint32_t x;
|
||||||
|
if (_location == LEFT) {
|
||||||
|
x = name_pad();
|
||||||
|
} else if (_location == RIGHT) {
|
||||||
|
x = _longest_port_name + name_pad() * 3;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t y = 0;
|
uint32_t y = 0;
|
||||||
for (std::vector<boost::shared_ptr<ARDOUR::Bundle> >::const_iterator i = _body->row_bundles().begin(); i != _body->row_bundles().end(); ++i) {
|
for (std::vector<boost::shared_ptr<ARDOUR::Bundle> >::const_iterator i = _body->row_bundles().begin(); i != _body->row_bundles().end(); ++i) {
|
||||||
|
|
||||||
Gdk::Color const colour = get_a_bundle_colour (i - _body->row_bundles().begin ());
|
Gdk::Color const colour = get_a_bundle_colour (i - _body->row_bundles().begin ());
|
||||||
set_source_rgb (cr, colour);
|
set_source_rgb (cr, colour);
|
||||||
cairo_rectangle (
|
cairo_rectangle (cr, 0, y, _width, row_height() * (*i)->nchannels());
|
||||||
cr,
|
|
||||||
0,
|
|
||||||
y,
|
|
||||||
_longest_port_name + name_pad() * 4 + _longest_bundle_name + name_pad() * 2,
|
|
||||||
row_height() * (*i)->nchannels()
|
|
||||||
);
|
|
||||||
cairo_fill_preserve (cr);
|
cairo_fill_preserve (cr);
|
||||||
set_source_rgb (cr, background_colour());
|
set_source_rgb (cr, background_colour());
|
||||||
cairo_set_line_width (cr, label_border_width ());
|
cairo_set_line_width (cr, label_border_width ());
|
||||||
|
|
@ -134,11 +131,18 @@ PortMatrixRowLabels::render (cairo_t* cr)
|
||||||
for (std::vector<boost::shared_ptr<ARDOUR::Bundle> >::const_iterator i = _body->row_bundles().begin(); i != _body->row_bundles().end(); ++i) {
|
for (std::vector<boost::shared_ptr<ARDOUR::Bundle> >::const_iterator i = _body->row_bundles().begin(); i != _body->row_bundles().end(); ++i) {
|
||||||
for (uint32_t j = 0; j < (*i)->nchannels(); ++j) {
|
for (uint32_t j = 0; j < (*i)->nchannels(); ++j) {
|
||||||
|
|
||||||
|
uint32_t x;
|
||||||
|
if (_location == LEFT) {
|
||||||
|
x = _longest_bundle_name + name_pad() * 2;
|
||||||
|
} else if (_location == RIGHT) {
|
||||||
|
x = 0;
|
||||||
|
}
|
||||||
|
|
||||||
Gdk::Color const colour = get_a_bundle_colour (i - _body->row_bundles().begin ());
|
Gdk::Color const colour = get_a_bundle_colour (i - _body->row_bundles().begin ());
|
||||||
set_source_rgb (cr, colour);
|
set_source_rgb (cr, colour);
|
||||||
cairo_rectangle (
|
cairo_rectangle (
|
||||||
cr,
|
cr,
|
||||||
0,
|
x,
|
||||||
y,
|
y,
|
||||||
_longest_port_name + (name_pad() * 2),
|
_longest_port_name + (name_pad() * 2),
|
||||||
row_height()
|
row_height()
|
||||||
|
|
@ -153,7 +157,7 @@ PortMatrixRowLabels::render (cairo_t* cr)
|
||||||
uint32_t const off = (row_height() - ext.height) / 2;
|
uint32_t const off = (row_height() - ext.height) / 2;
|
||||||
|
|
||||||
set_source_rgb (cr, text_colour());
|
set_source_rgb (cr, text_colour());
|
||||||
cairo_move_to (cr, name_pad(), y + name_pad() + off);
|
cairo_move_to (cr, x + name_pad(), y + name_pad() + off);
|
||||||
cairo_show_text (cr, (*i)->channel_name(j).c_str());
|
cairo_show_text (cr, (*i)->channel_name(j).c_str());
|
||||||
|
|
||||||
y += row_height();
|
y += row_height();
|
||||||
|
|
@ -164,7 +168,13 @@ PortMatrixRowLabels::render (cairo_t* cr)
|
||||||
void
|
void
|
||||||
PortMatrixRowLabels::button_press (double x, double y, int b, uint32_t t)
|
PortMatrixRowLabels::button_press (double x, double y, int b, uint32_t t)
|
||||||
{
|
{
|
||||||
if (b == 3 && x < (_longest_port_name + name_pad() * 2) ) {
|
if (b != 3) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( (_location == LEFT && x > (_longest_bundle_name + name_pad() * 2)) ||
|
||||||
|
(_location == RIGHT && x < (_longest_port_name + name_pad() * 2))
|
||||||
|
) {
|
||||||
|
|
||||||
delete _menu;
|
delete _menu;
|
||||||
|
|
||||||
|
|
@ -173,7 +183,6 @@ PortMatrixRowLabels::button_press (double x, double y, int b, uint32_t t)
|
||||||
|
|
||||||
Gtk::Menu_Helpers::MenuList& items = _menu->items ();
|
Gtk::Menu_Helpers::MenuList& items = _menu->items ();
|
||||||
|
|
||||||
|
|
||||||
uint32_t row = y / row_height ();
|
uint32_t row = y / row_height ();
|
||||||
|
|
||||||
boost::shared_ptr<ARDOUR::Bundle> bundle;
|
boost::shared_ptr<ARDOUR::Bundle> bundle;
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,12 @@ namespace Gtk {
|
||||||
class PortMatrixRowLabels : public PortMatrixComponent
|
class PortMatrixRowLabels : public PortMatrixComponent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PortMatrixRowLabels (PortMatrix *, PortMatrixBody *);
|
enum Location {
|
||||||
|
LEFT,
|
||||||
|
RIGHT
|
||||||
|
};
|
||||||
|
|
||||||
|
PortMatrixRowLabels (PortMatrix *, PortMatrixBody *, Location);
|
||||||
~PortMatrixRowLabels ();
|
~PortMatrixRowLabels ();
|
||||||
|
|
||||||
void button_press (double, double, int, uint32_t);
|
void button_press (double, double, int, uint32_t);
|
||||||
|
|
@ -52,6 +57,7 @@ private:
|
||||||
uint32_t _longest_port_name;
|
uint32_t _longest_port_name;
|
||||||
uint32_t _longest_bundle_name;
|
uint32_t _longest_bundle_name;
|
||||||
Gtk::Menu* _menu;
|
Gtk::Menu* _menu;
|
||||||
|
Location _location;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue