2009-01-20 09:46:00 -05:00
|
|
|
/*
|
2009-10-14 12:10:01 -04:00
|
|
|
Copyright (C) 2002-2009 Paul Davis
|
2009-01-20 09:46:00 -05:00
|
|
|
|
|
|
|
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 __gtk_ardour_port_matrix_component_h__
|
|
|
|
#define __gtk_ardour_port_matrix_component_h__
|
|
|
|
|
2009-05-17 20:21:17 -04:00
|
|
|
#include <stdint.h>
|
2009-01-20 09:46:00 -05:00
|
|
|
#include <gtkmm/eventbox.h>
|
2009-07-17 18:54:45 -04:00
|
|
|
#include <boost/shared_ptr.hpp>
|
2009-01-20 09:46:00 -05:00
|
|
|
|
2009-01-30 10:08:09 -05:00
|
|
|
class PortMatrix;
|
2009-01-20 09:46:00 -05:00
|
|
|
class PortMatrixBody;
|
2009-01-26 23:21:13 -05:00
|
|
|
class PortMatrixNode;
|
2009-07-17 18:54:45 -04:00
|
|
|
class PortGroup;
|
2009-07-17 22:10:15 -04:00
|
|
|
class PortGroupList;
|
2009-07-17 18:54:45 -04:00
|
|
|
|
|
|
|
namespace ARDOUR {
|
2011-08-13 16:19:39 -04:00
|
|
|
class Bundle;
|
2009-07-17 18:54:45 -04:00
|
|
|
class BundleChannel;
|
|
|
|
}
|
2009-01-20 09:46:00 -05:00
|
|
|
|
|
|
|
/** One component of the PortMatrix. This is a cairo-rendered
|
|
|
|
* Pixmap.
|
|
|
|
*/
|
|
|
|
class PortMatrixComponent
|
|
|
|
{
|
|
|
|
public:
|
2009-01-30 10:08:09 -05:00
|
|
|
PortMatrixComponent (PortMatrix *, PortMatrixBody *);
|
2009-01-20 09:46:00 -05:00
|
|
|
virtual ~PortMatrixComponent ();
|
|
|
|
|
2009-01-26 23:21:13 -05:00
|
|
|
virtual double component_to_parent_x (double x) const = 0;
|
|
|
|
virtual double parent_to_component_x (double x) const = 0;
|
|
|
|
virtual double component_to_parent_y (double y) const = 0;
|
|
|
|
virtual double parent_to_component_y (double y) const = 0;
|
2009-11-16 19:30:42 -05:00
|
|
|
virtual void mouseover_changed (std::list<PortMatrixNode> const &) = 0;
|
2009-01-26 23:21:13 -05:00
|
|
|
virtual void draw_extra (cairo_t *) = 0;
|
2011-12-06 20:44:47 -05:00
|
|
|
virtual void button_press (double, double, GdkEventButton *) {}
|
|
|
|
virtual void button_release (double, double, GdkEventButton *) {}
|
2009-11-16 19:30:42 -05:00
|
|
|
virtual void motion (double, double) {}
|
2009-01-26 23:21:13 -05:00
|
|
|
|
2009-05-03 10:31:42 -04:00
|
|
|
void set_show_ports (bool);
|
2009-01-20 09:46:00 -05:00
|
|
|
void setup ();
|
|
|
|
GdkPixmap* get_pixmap (GdkDrawable *);
|
|
|
|
std::pair<uint32_t, uint32_t> dimensions ();
|
2009-01-21 22:38:40 -05:00
|
|
|
|
2009-01-20 09:46:00 -05:00
|
|
|
void require_render () {
|
|
|
|
_render_required = true;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-01-21 22:38:40 -05:00
|
|
|
void require_rebuild () {
|
|
|
|
_dimension_computation_required = true;
|
|
|
|
_render_required = true;
|
|
|
|
}
|
2009-01-20 09:46:00 -05:00
|
|
|
|
2009-01-26 23:21:13 -05:00
|
|
|
void set_parent_rectangle (Gdk::Rectangle const & r) {
|
|
|
|
_parent_rectangle = r;
|
|
|
|
}
|
|
|
|
|
|
|
|
Gdk::Rectangle parent_rectangle () const {
|
|
|
|
return _parent_rectangle;
|
|
|
|
}
|
|
|
|
|
2009-07-17 22:10:15 -04:00
|
|
|
/** @return grid spacing */
|
|
|
|
static uint32_t grid_spacing () {
|
2009-11-11 20:58:20 -05:00
|
|
|
return 24;
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
/** @return width of borders drawn around labels */
|
|
|
|
static uint32_t label_border_width () {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @return padding between a name and the nearest line */
|
|
|
|
static uint32_t name_pad () {
|
|
|
|
return 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @return width of thin lines in the grid */
|
2009-07-17 09:57:10 -04:00
|
|
|
static double thin_grid_line_width () {
|
|
|
|
return 0.5;
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/** @return width of thick lines in the grid */
|
2009-07-17 09:57:10 -04:00
|
|
|
static double thick_grid_line_width () {
|
|
|
|
return 1;
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/** @return space around the connection indicator */
|
|
|
|
static uint32_t connection_indicator_pad () {
|
2009-11-11 20:58:20 -05:00
|
|
|
return 6;
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
|
|
|
|
2009-01-26 23:21:13 -05:00
|
|
|
static uint32_t mouseover_line_width () {
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
|
2009-01-20 09:46:00 -05:00
|
|
|
/** @return angle of column labels, in radians */
|
|
|
|
static double angle () {
|
|
|
|
return M_PI / 4;
|
|
|
|
}
|
|
|
|
|
2009-01-23 16:24:11 -05:00
|
|
|
/** @return background colour */
|
2009-07-17 09:57:10 -04:00
|
|
|
Gdk::Color background_colour ();
|
|
|
|
|
|
|
|
/* XXX I guess these colours should come from a theme, or something */
|
2009-01-20 09:46:00 -05:00
|
|
|
|
2009-01-23 16:24:11 -05:00
|
|
|
/** @return text colour */
|
2009-01-20 09:46:00 -05:00
|
|
|
static Gdk::Color text_colour () {
|
|
|
|
return Gdk::Color ("#ffffff");
|
|
|
|
}
|
|
|
|
|
2009-01-23 16:24:11 -05:00
|
|
|
/** @return grid line colour */
|
2009-01-20 09:46:00 -05:00
|
|
|
static Gdk::Color grid_colour () {
|
2009-07-17 09:57:10 -04:00
|
|
|
return Gdk::Color ("#000000");
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
|
|
|
|
2009-01-23 16:24:11 -05:00
|
|
|
/** @return colour of association blobs */
|
2009-01-20 09:46:00 -05:00
|
|
|
static Gdk::Color association_colour () {
|
|
|
|
return Gdk::Color ("#00ff00");
|
|
|
|
}
|
|
|
|
|
2009-01-23 16:24:11 -05:00
|
|
|
/** @return colour to paint grid squares when they can't be associated */
|
2010-07-21 19:20:56 -04:00
|
|
|
static Gdk::Color non_connectable_colour () {
|
2009-01-23 16:24:11 -05:00
|
|
|
return Gdk::Color ("#cccccc");
|
|
|
|
}
|
|
|
|
|
2009-01-26 23:21:13 -05:00
|
|
|
/** @return colour to paint mouseover lines */
|
|
|
|
static Gdk::Color mouseover_line_colour () {
|
|
|
|
return Gdk::Color ("#ff0000");
|
|
|
|
}
|
|
|
|
|
2009-02-02 20:55:25 -05:00
|
|
|
/** @return colour to paint channel highlights */
|
|
|
|
static Gdk::Color highlighted_channel_colour () {
|
2009-01-26 23:21:13 -05:00
|
|
|
return Gdk::Color ("#777777");
|
|
|
|
}
|
|
|
|
|
2009-01-20 09:46:00 -05:00
|
|
|
/* XXX */
|
|
|
|
static Gdk::Color get_a_bundle_colour (int x) {
|
|
|
|
if ((x % 2) == 0) {
|
|
|
|
return Gdk::Color ("#547027");
|
|
|
|
} else {
|
|
|
|
return Gdk::Color ("#3552a6");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-25 01:47:11 -05:00
|
|
|
/* XXX */
|
|
|
|
static Gdk::Color get_a_group_colour (int x) {
|
|
|
|
if ((x % 2) == 0) {
|
|
|
|
return Gdk::Color ("#222222");
|
|
|
|
} else {
|
|
|
|
return Gdk::Color ("#444444");
|
|
|
|
}
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-01-20 09:46:00 -05:00
|
|
|
void set_source_rgb (cairo_t *, Gdk::Color const &);
|
|
|
|
void set_source_rgba (cairo_t *, Gdk::Color const &, double);
|
2009-07-17 22:10:15 -04:00
|
|
|
uint32_t group_size (boost::shared_ptr<const PortGroup>) const;
|
2009-11-18 08:35:31 -05:00
|
|
|
uint32_t channel_to_position (ARDOUR::BundleChannel, boost::shared_ptr<const PortGroup>) const;
|
|
|
|
virtual ARDOUR::BundleChannel position_to_channel (double, double, boost::shared_ptr<const PortGroup>) const;
|
2009-01-20 09:46:00 -05:00
|
|
|
|
|
|
|
/** Render the complete component to a cairo context. */
|
|
|
|
virtual void render (cairo_t *) = 0;
|
|
|
|
/** Compute any required dimensions. This must set up
|
|
|
|
* _width and _height.
|
|
|
|
*/
|
|
|
|
virtual void compute_dimensions () = 0;
|
|
|
|
|
2009-01-30 10:08:09 -05:00
|
|
|
PortMatrix* _matrix;
|
2009-01-20 09:46:00 -05:00
|
|
|
PortMatrixBody* _body; ///< the PortMatrixBody that we're in
|
|
|
|
uint32_t _width; ///< full width of the contents
|
|
|
|
uint32_t _height; ///< full height of the contents
|
2009-01-26 23:21:13 -05:00
|
|
|
Gdk::Rectangle _parent_rectangle;
|
2009-01-20 09:46:00 -05:00
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
private:
|
2009-01-20 09:46:00 -05:00
|
|
|
GdkPixmap* _pixmap; ///< pixmap
|
|
|
|
bool _render_required; ///< true if the rendered pixmap is out of date
|
|
|
|
bool _dimension_computation_required; ///< true if the dimensions are out of date
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|