Ardour  9.0-pre0-582-g084a23a80d
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 #pragma once
20 
21 #include <cstdint>
22 #include <memory>
23 
24 #include <gtkmm/eventbox.h>
25 
26 class PortMatrix;
27 class PortMatrixBody;
28 class PortMatrixNode;
29 class PortGroup;
30 class PortGroupList;
31 
32 namespace ARDOUR {
33  class Bundle;
34  class BundleChannel;
35 }
36 
41 {
42 public:
45 
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, GdkEventButton *) {}
53  virtual void button_release (double, double, GdkEventButton *) {}
54  virtual void motion (double, double) {}
55 
56  void set_show_ports (bool);
57  void setup ();
59  std::pair<uint32_t, uint32_t> dimensions ();
60 
61  void require_render () {
62  _render_required = true;
63  }
64 
65  void require_rebuild () {
67  _render_required = true;
68  }
69 
72  }
73 
75  return _parent_rectangle;
76  }
77 
79  static uint32_t grid_spacing ();
80 
81 protected:
82 
84  static uint32_t label_border_width () {
85  return 1;
86  }
87 
89  static uint32_t name_pad () {
90  return 8;
91  }
92 
94  static double thin_grid_line_width () {
95  return 0.5;
96  }
97 
99  static double thick_grid_line_width () {
100  return 1;
101  }
102 
104  static uint32_t connection_indicator_pad () {
105  return 6;
106  }
107 
108  static uint32_t mouseover_line_width () {
109  return 4;
110  }
111 
113  static double angle () {
114  return M_PI / 4;
115  }
116 
119 
120  /* XXX I guess these colours should come from a theme, or something */
121 
124  return Gdk::Color ("#ffffff");
125  }
126 
129  return Gdk::Color ("#000000");
130  }
131 
134  return Gdk::Color ("#00ff00");
135  }
136 
139  return Gdk::Color ("#cccccc");
140  }
141 
144  return Gdk::Color ("#ff0000");
145  }
146 
149  return Gdk::Color ("#777777");
150  }
151 
152  /* XXX */
154  if ((x % 2) == 0) {
155  return Gdk::Color ("#555555");
156  } else {
157  return Gdk::Color ("#666666");
158  }
159  }
160 
161  /* XXX */
163  if ((x % 2) == 0) {
164  return Gdk::Color ("#222222");
165  } else {
166  return Gdk::Color ("#444444");
167  }
168  }
169 
170  void set_source_rgb (cairo_t *, Gdk::Color const &);
171  void set_source_rgba (cairo_t *, Gdk::Color const &, double);
172  uint32_t group_size (std::shared_ptr<const PortGroup>) const;
173  uint32_t channel_to_position (ARDOUR::BundleChannel, std::shared_ptr<const PortGroup>) const;
174  virtual ARDOUR::BundleChannel position_to_channel (double, double, std::shared_ptr<const PortGroup>) const;
175 
177  virtual void render (cairo_t *) = 0;
181  virtual void compute_dimensions () = 0;
182 
185  uint32_t _width;
186  uint32_t _height;
188 
189 private:
193 };
194 
A list of PortGroups.
Definition: port_group.h:102
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