2 Copyright (C) 2002-2009 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __gtk_ardour_port_matrix_component_h__
21 #define __gtk_ardour_port_matrix_component_h__
23 #include <gtkmm/eventbox.h>
27 /** One component of the PortMatrix. This is a cairo-rendered
30 class PortMatrixComponent
33 PortMatrixComponent (PortMatrixBody *);
34 virtual ~PortMatrixComponent ();
37 GdkPixmap* get_pixmap (GdkDrawable *);
38 std::pair<uint32_t, uint32_t> dimensions ();
40 void require_render () {
41 _render_required = true;
44 void require_rebuild () {
45 _dimension_computation_required = true;
46 _render_required = true;
49 /** @return width of columns in the grid */
50 static uint32_t column_width () {
54 /** @return height of rows in the grid */
55 static uint32_t row_height () {
61 /** @return width of borders drawn around labels */
62 static uint32_t label_border_width () {
66 /** @return padding between a name and the nearest line */
67 static uint32_t name_pad () {
71 /** @return width of thin lines in the grid */
72 static uint32_t thin_grid_line_width () {
76 /** @return width of thick lines in the grid */
77 static uint32_t thick_grid_line_width () {
81 /** @return space around the connection indicator */
82 static uint32_t connection_indicator_pad () {
86 /** @return angle of column labels, in radians */
87 static double angle () {
91 /* XXX I guess these colours should come from a theme, or something */
93 /** @return background colour */
94 static Gdk::Color background_colour () {
95 return Gdk::Color ("#000000");
98 /** @return text colour */
99 static Gdk::Color text_colour () {
100 return Gdk::Color ("#ffffff");
103 /** @return grid line colour */
104 static Gdk::Color grid_colour () {
105 return Gdk::Color ("#333333");
108 /** @return colour of association blobs */
109 static Gdk::Color association_colour () {
110 return Gdk::Color ("#00ff00");
113 /** @return colour to paint grid squares when they can't be associated */
114 static Gdk::Color unknown_colour () {
115 return Gdk::Color ("#cccccc");
119 static Gdk::Color get_a_bundle_colour (int x) {
121 return Gdk::Color ("#547027");
123 return Gdk::Color ("#3552a6");
128 static Gdk::Color get_a_group_colour (int x) {
130 return Gdk::Color ("#222222");
132 return Gdk::Color ("#444444");
136 void set_source_rgb (cairo_t *, Gdk::Color const &);
137 void set_source_rgba (cairo_t *, Gdk::Color const &, double);
138 std::pair<std::string, double> display_port_name (cairo_t*, std::string const &, double) const;
140 /** Render the complete component to a cairo context. */
141 virtual void render (cairo_t *) = 0;
142 /** Compute any required dimensions. This must set up
143 * _width and _height.
145 virtual void compute_dimensions () = 0;
147 PortMatrixBody* _body; ///< the PortMatrixBody that we're in
148 uint32_t _width; ///< full width of the contents
149 uint32_t _height; ///< full height of the contents
152 GdkPixmap* _pixmap; ///< pixmap
153 bool _render_required; ///< true if the rendered pixmap is out of date
154 bool _dimension_computation_required; ///< true if the dimensions are out of date