New matrix-based editor for connections and bundles, based on thorwil's design.
[ardour.git] / gtk2_ardour / port_matrix_body.h
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_body_h__
21 #define __gtk_ardour_port_matrix_body_h__
22
23 #include "port_matrix_column_labels.h"
24 #include "port_matrix_row_labels.h"
25 #include "port_matrix_grid.h"
26
27 class PortMatrix;
28
29 /** The main body of the port matrix.  It is made up of three parts:
30  *  column labels, grid and row labels, each drawn using cairo.
31  *  This class handles the arrangement of these parts.
32  */
33 class PortMatrixBody : public Gtk::EventBox
34 {
35 public:
36         PortMatrixBody (PortMatrix *);
37
38         /** @return bundles to offer for columns */
39         std::vector<boost::shared_ptr<ARDOUR::Bundle> > const & column_bundles () {
40                 return _column_bundles;
41         }
42
43         /** @return bundles to offer for rows */
44         std::vector<boost::shared_ptr<ARDOUR::Bundle> > const & row_bundles () {
45                 return _row_bundles;
46         }
47         
48         void setup (
49                 std::vector<boost::shared_ptr<ARDOUR::Bundle> > const &,
50                 std::vector<boost::shared_ptr<ARDOUR::Bundle> > const &
51                 );
52
53         uint32_t full_scroll_width ();
54         uint32_t alloc_scroll_width ();
55         uint32_t full_scroll_height ();
56         uint32_t alloc_scroll_height ();
57
58         void set_xoffset (uint32_t);
59         void set_yoffset (uint32_t);
60
61         void repaint_grid ();
62
63 protected:
64         bool on_expose_event (GdkEventExpose *);
65         void on_size_request (Gtk::Requisition *);
66         void on_size_allocate (Gtk::Allocation &);
67         bool on_button_press_event (GdkEventButton *);
68
69 private:
70         void compute_divs ();
71         void repaint_column_labels ();
72         void repaint_row_labels ();
73         
74         PortMatrix* _port_matrix;
75         PortMatrixColumnLabels _column_labels;
76         PortMatrixRowLabels _row_labels;
77         PortMatrixGrid _grid;
78
79         uint32_t _alloc_width; ///< allocated width
80         uint32_t _alloc_height; ///< allocated height
81         uint32_t _alloc_xdiv; ///< position of the division between grid and row labels
82         uint32_t _alloc_ydiv; ///< position of the division between column labels and grid
83         uint32_t _xoffset;
84         uint32_t _yoffset;
85
86         /// bundles to offer for columns
87         std::vector<boost::shared_ptr<ARDOUR::Bundle> > _column_bundles;
88         /// bundles to offer for rows
89         std::vector<boost::shared_ptr<ARDOUR::Bundle> > _row_bundles;
90
91         std::list<sigc::connection> _bundle_connections;
92 };
93
94 #endif