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__
24 #include <gtkmm/eventbox.h>
25 #include <boost/shared_ptr.hpp>
37 /** One component of the PortMatrix. This is a cairo-rendered
40 class PortMatrixComponent
43 PortMatrixComponent (PortMatrix *, PortMatrixBody *);
44 virtual ~PortMatrixComponent ();
46 virtual double component_to_parent_x (double x) const = 0;
47 virtual double parent_to_component_x (double x) const = 0;
48 virtual double component_to_parent_y (double y) const = 0;
49 virtual double parent_to_component_y (double y) const = 0;
50 virtual void mouseover_changed (std::list<PortMatrixNode> const &) = 0;
51 virtual void draw_extra (cairo_t *) = 0;
52 virtual void button_press (double, double, int, uint32_t) {}
53 virtual void motion (double, double) {}
55 void set_show_ports (bool);
57 GdkPixmap* get_pixmap (GdkDrawable *);
58 std::pair<uint32_t, uint32_t> dimensions ();
60 void require_render () {
61 _render_required = true;
64 void require_rebuild () {
65 _dimension_computation_required = true;
66 _render_required = true;
69 void set_parent_rectangle (Gdk::Rectangle const & r) {
70 _parent_rectangle = r;
73 Gdk::Rectangle parent_rectangle () const {
74 return _parent_rectangle;
77 /** @return grid spacing */
78 static uint32_t grid_spacing () {
84 /** @return width of borders drawn around labels */
85 static uint32_t label_border_width () {
89 /** @return padding between a name and the nearest line */
90 static uint32_t name_pad () {
94 /** @return width of thin lines in the grid */
95 static double thin_grid_line_width () {
99 /** @return width of thick lines in the grid */
100 static double thick_grid_line_width () {
104 /** @return space around the connection indicator */
105 static uint32_t connection_indicator_pad () {
109 static uint32_t mouseover_line_width () {
113 /** @return angle of column labels, in radians */
114 static double angle () {
118 /** @return background colour */
119 Gdk::Color background_colour ();
121 /* XXX I guess these colours should come from a theme, or something */
123 /** @return text colour */
124 static Gdk::Color text_colour () {
125 return Gdk::Color ("#ffffff");
128 /** @return grid line colour */
129 static Gdk::Color grid_colour () {
130 return Gdk::Color ("#000000");
133 /** @return colour of association blobs */
134 static Gdk::Color association_colour () {
135 return Gdk::Color ("#00ff00");
138 /** @return colour to paint grid squares when they can't be associated */
139 static Gdk::Color unknown_colour () {
140 return Gdk::Color ("#cccccc");
143 /** @return colour to paint mouseover lines */
144 static Gdk::Color mouseover_line_colour () {
145 return Gdk::Color ("#ff0000");
148 /** @return colour to paint channel highlights */
149 static Gdk::Color highlighted_channel_colour () {
150 return Gdk::Color ("#777777");
154 static Gdk::Color get_a_bundle_colour (int x) {
156 return Gdk::Color ("#547027");
158 return Gdk::Color ("#3552a6");
163 static Gdk::Color get_a_group_colour (int x) {
165 return Gdk::Color ("#222222");
167 return Gdk::Color ("#444444");
171 void set_source_rgb (cairo_t *, Gdk::Color const &);
172 void set_source_rgba (cairo_t *, Gdk::Color const &, double);
173 uint32_t group_size (boost::shared_ptr<const PortGroup>) const;
174 uint32_t channel_to_position (ARDOUR::BundleChannel, PortGroupList const *) const;
175 virtual std::pair<boost::shared_ptr<PortGroup>, ARDOUR::BundleChannel> position_to_group_and_channel (double, double, PortGroupList const *) const;
177 /** Render the complete component to a cairo context. */
178 virtual void render (cairo_t *) = 0;
179 /** Compute any required dimensions. This must set up
180 * _width and _height.
182 virtual void compute_dimensions () = 0;
185 PortMatrixBody* _body; ///< the PortMatrixBody that we're in
186 uint32_t _width; ///< full width of the contents
187 uint32_t _height; ///< full height of the contents
188 Gdk::Rectangle _parent_rectangle;
191 GdkPixmap* _pixmap; ///< pixmap
192 bool _render_required; ///< true if the rendered pixmap is out of date
193 bool _dimension_computation_required; ///< true if the dimensions are out of date