Ardour  8.12
port_matrix_component.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009-2011 Carl Hetherington <carl@carlh.net>
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 along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef __gtk_ardour_port_matrix_component_h__
20 #define __gtk_ardour_port_matrix_component_h__
21 
22 #include <cstdint>
23 #include <memory>
24 
25 #include <gtkmm/eventbox.h>
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:
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 ();
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 
73  }
74 
76  return _parent_rectangle;
77  }
78 
80  static uint32_t grid_spacing ();
81 
82 protected:
83 
85  static uint32_t label_border_width () {
86  return 1;
87  }
88 
90  static uint32_t name_pad () {
91  return 8;
92  }
93 
95  static double thin_grid_line_width () {
96  return 0.5;
97  }
98 
100  static double thick_grid_line_width () {
101  return 1;
102  }
103 
105  static uint32_t connection_indicator_pad () {
106  return 6;
107  }
108 
109  static uint32_t mouseover_line_width () {
110  return 4;
111  }
112 
114  static double angle () {
115  return M_PI / 4;
116  }
117 
120 
121  /* XXX I guess these colours should come from a theme, or something */
122 
125  return Gdk::Color ("#ffffff");
126  }
127 
130  return Gdk::Color ("#000000");
131  }
132 
135  return Gdk::Color ("#00ff00");
136  }
137 
140  return Gdk::Color ("#cccccc");
141  }
142 
145  return Gdk::Color ("#ff0000");
146  }
147 
150  return Gdk::Color ("#777777");
151  }
152 
153  /* XXX */
155  if ((x % 2) == 0) {
156  return Gdk::Color ("#555555");
157  } else {
158  return Gdk::Color ("#666666");
159  }
160  }
161 
162  /* XXX */
164  if ((x % 2) == 0) {
165  return Gdk::Color ("#222222");
166  } else {
167  return Gdk::Color ("#444444");
168  }
169  }
170 
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 (std::shared_ptr<const PortGroup>) const;
174  uint32_t channel_to_position (ARDOUR::BundleChannel, std::shared_ptr<const PortGroup>) const;
175  virtual ARDOUR::BundleChannel position_to_channel (double, double, std::shared_ptr<const PortGroup>) const;
176 
178  virtual void render (cairo_t *) = 0;
182  virtual void compute_dimensions () = 0;
183 
186  uint32_t _width;
187  uint32_t _height;
189 
190 private:
194 };
195 
196 #endif
A list of PortGroups.
Definition: port_group.h:103
static Gdk::Color association_colour()
void set_show_ports(bool)
GdkPixmap * get_pixmap(GdkDrawable *)
GdkPixmap * _pixmap
pixmap
bool _render_required
true if the rendered pixmap is out of date
virtual double parent_to_component_x(double x) const =0
Gdk::Color background_colour()
void set_parent_rectangle(Gdk::Rectangle const &r)
void set_source_rgb(cairo_t *, Gdk::Color const &)
virtual ARDOUR::BundleChannel position_to_channel(double, double, std::shared_ptr< const PortGroup >) const
void set_source_rgba(cairo_t *, Gdk::Color const &, double)
static Gdk::Color get_a_bundle_colour(int x)
static Gdk::Color mouseover_line_colour()
static Gdk::Color text_colour()
virtual ~PortMatrixComponent()
std::pair< uint32_t, uint32_t > dimensions()
virtual void render(cairo_t *)=0
PortMatrixBody * _body
the PortMatrixBody that we're in
static uint32_t connection_indicator_pad()
static double thin_grid_line_width()
static Gdk::Color non_connectable_colour()
static uint32_t mouseover_line_width()
virtual double parent_to_component_y(double y) const =0
static Gdk::Color highlighted_channel_colour()
static Gdk::Color grid_colour()
virtual void draw_extra(cairo_t *)=0
static uint32_t name_pad()
static Gdk::Color get_a_group_colour(int x)
static uint32_t label_border_width()
virtual double component_to_parent_x(double x) const =0
static uint32_t grid_spacing()
uint32_t _width
full width of the contents
uint32_t channel_to_position(ARDOUR::BundleChannel, std::shared_ptr< const PortGroup >) const
virtual void mouseover_changed(std::list< PortMatrixNode > const &)=0
static double thick_grid_line_width()
virtual void button_press(double, double, GdkEventButton *)
uint32_t _height
full height of the contents
Gdk::Rectangle parent_rectangle() const
Gdk::Rectangle _parent_rectangle
bool _dimension_computation_required
true if the dimensions are out of date
virtual void compute_dimensions()=0
virtual void motion(double, double)
virtual void button_release(double, double, GdkEventButton *)
uint32_t group_size(std::shared_ptr< const PortGroup >) const
PortMatrixComponent(PortMatrix *, PortMatrixBody *)
virtual double component_to_parent_y(double y) const =0
uint32_t Color
Definition: colors.h:33