ardour
port_matrix_component.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2009 Paul Davis
3 
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.
8 
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.
13 
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.
17 
18 */
19 
20 #ifndef __gtk_ardour_port_matrix_component_h__
21 #define __gtk_ardour_port_matrix_component_h__
22 
23 #include <stdint.h>
24 #include <gtkmm/eventbox.h>
25 #include <boost/shared_ptr.hpp>
26 
27 class PortMatrix;
28 class PortMatrixBody;
29 class PortMatrixNode;
30 class PortGroup;
31 class PortGroupList;
32 
33 namespace ARDOUR {
34  class Bundle;
35  class BundleChannel;
36 }
37 
42 {
43 public:
45  virtual ~PortMatrixComponent ();
46 
47  virtual double component_to_parent_x (double x) const = 0;
48  virtual double parent_to_component_x (double x) const = 0;
49  virtual double component_to_parent_y (double y) const = 0;
50  virtual double parent_to_component_y (double y) const = 0;
51  virtual void mouseover_changed (std::list<PortMatrixNode> const &) = 0;
52  virtual void draw_extra (cairo_t *) = 0;
53  virtual void button_press (double, double, GdkEventButton *) {}
54  virtual void button_release (double, double, GdkEventButton *) {}
55  virtual void motion (double, double) {}
56 
57  void set_show_ports (bool);
58  void setup ();
59  GdkPixmap* get_pixmap (GdkDrawable *);
60  std::pair<uint32_t, uint32_t> dimensions ();
61 
62  void require_render () {
63  _render_required = true;
64  }
65 
66  void require_rebuild () {
68  _render_required = true;
69  }
70 
71  void set_parent_rectangle (Gdk::Rectangle const & r) {
73  }
74 
75  Gdk::Rectangle parent_rectangle () const {
76  return _parent_rectangle;
77  }
78 
80  static uint32_t grid_spacing () {
81  return 24;
82  }
83 
84 protected:
85 
87  static uint32_t label_border_width () {
88  return 1;
89  }
90 
92  static uint32_t name_pad () {
93  return 8;
94  }
95 
97  static double thin_grid_line_width () {
98  return 0.5;
99  }
100 
102  static double thick_grid_line_width () {
103  return 1;
104  }
105 
107  static uint32_t connection_indicator_pad () {
108  return 6;
109  }
110 
111  static uint32_t mouseover_line_width () {
112  return 4;
113  }
114 
116  static double angle () {
117  return M_PI / 4;
118  }
119 
121  Gdk::Color background_colour ();
122 
123  /* XXX I guess these colours should come from a theme, or something */
124 
126  static Gdk::Color text_colour () {
127  return Gdk::Color ("#ffffff");
128  }
129 
131  static Gdk::Color grid_colour () {
132  return Gdk::Color ("#000000");
133  }
134 
136  static Gdk::Color association_colour () {
137  return Gdk::Color ("#00ff00");
138  }
139 
141  static Gdk::Color non_connectable_colour () {
142  return Gdk::Color ("#cccccc");
143  }
144 
146  static Gdk::Color mouseover_line_colour () {
147  return Gdk::Color ("#ff0000");
148  }
149 
151  static Gdk::Color highlighted_channel_colour () {
152  return Gdk::Color ("#777777");
153  }
154 
155  /* XXX */
156  static Gdk::Color get_a_bundle_colour (int x) {
157  if ((x % 2) == 0) {
158  return Gdk::Color ("#555555");
159  } else {
160  return Gdk::Color ("#666666");
161  }
162  }
163 
164  /* XXX */
165  static Gdk::Color get_a_group_colour (int x) {
166  if ((x % 2) == 0) {
167  return Gdk::Color ("#222222");
168  } else {
169  return Gdk::Color ("#444444");
170  }
171  }
172 
173  void set_source_rgb (cairo_t *, Gdk::Color const &);
174  void set_source_rgba (cairo_t *, Gdk::Color const &, double);
178 
180  virtual void render (cairo_t *) = 0;
184  virtual void compute_dimensions () = 0;
185 
188  uint32_t _width;
189  uint32_t _height;
190  Gdk::Rectangle _parent_rectangle;
191 
192 private:
193  GdkPixmap* _pixmap;
196 };
197 
198 #endif
static Gdk::Color text_colour()
void set_source_rgb(cairo_t *, Gdk::Color const &)
virtual void button_press(double, double, GdkEventButton *)
static uint32_t name_pad()
virtual double parent_to_component_y(double y) const =0
virtual void compute_dimensions()=0
virtual void render(cairo_t *)=0
bool _render_required
true if the rendered pixmap is out of date
static Gdk::Color association_colour()
static uint32_t grid_spacing()
GdkPixmap * _pixmap
pixmap
static Gdk::Color get_a_bundle_colour(int x)
static Gdk::Color grid_colour()
bool _dimension_computation_required
true if the dimensions are out of date
virtual void mouseover_changed(std::list< PortMatrixNode > const &)=0
static Gdk::Color highlighted_channel_colour()
uint32_t _height
full height of the contents
A list of PortGroups.
Definition: port_group.h:100
static uint32_t connection_indicator_pad()
Gdk::Rectangle parent_rectangle() const
virtual void motion(double, double)
uint32_t group_size(boost::shared_ptr< const PortGroup >) const
virtual void draw_extra(cairo_t *)=0
GdkPixmap * get_pixmap(GdkDrawable *)
Definition: amp.h:29
virtual ARDOUR::BundleChannel position_to_channel(double, double, boost::shared_ptr< const PortGroup >) const
uint32_t channel_to_position(ARDOUR::BundleChannel, boost::shared_ptr< const PortGroup >) const
Gdk::Rectangle _parent_rectangle
std::pair< uint32_t, uint32_t > dimensions()
virtual double component_to_parent_x(double x) const =0
static uint32_t label_border_width()
static Gdk::Color non_connectable_colour()
PortMatrixBody * _body
the PortMatrixBody that we're in
void set_show_ports(bool)
void set_source_rgba(cairo_t *, Gdk::Color const &, double)
static Gdk::Color mouseover_line_colour()
static uint32_t mouseover_line_width()
void set_parent_rectangle(Gdk::Rectangle const &r)
uint32_t _width
full width of the contents
virtual void button_release(double, double, GdkEventButton *)
static Gdk::Color get_a_group_colour(int x)
static double thick_grid_line_width()
virtual double parent_to_component_x(double x) const =0
PortMatrixComponent(PortMatrix *, PortMatrixBody *)
virtual double component_to_parent_y(double y) const =0
static double thin_grid_line_width()