More port matrix re-working. Global matrix now has separate visibility buttons
[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 #include "port_group.h"
27 #include "port_matrix_types.h"
28
29 class PortMatrix;
30
31 /** The main body of the port matrix.  It is made up of three parts:
32  *  column labels, grid and row labels, each drawn using cairo.
33  */
34 class PortMatrixBody : public Gtk::EventBox
35 {
36 public:
37         PortMatrixBody (PortMatrix *);
38
39         void setup ();
40
41         uint32_t full_scroll_width ();
42         uint32_t alloc_scroll_width ();
43         uint32_t full_scroll_height ();
44         uint32_t alloc_scroll_height ();
45
46         uint32_t xoffset () const {
47                 return _xoffset;
48         }
49         void set_xoffset (uint32_t);
50         uint32_t yoffset () const {
51                 return _yoffset;
52         }
53         void set_yoffset (uint32_t);
54
55         void rebuild_and_draw_grid ();
56         
57         void set_mouseover (PortMatrixNode const &);
58         PortMatrixNode mouseover () const {
59                 return _mouseover;
60         }
61
62 protected:
63         bool on_expose_event (GdkEventExpose *);
64         void on_size_request (Gtk::Requisition *);
65         void on_size_allocate (Gtk::Allocation &);
66         bool on_button_press_event (GdkEventButton *);
67         bool on_enter_notify_event (GdkEventCrossing *);
68         bool on_motion_notify_event (GdkEventMotion *);
69         
70 private:
71         void compute_rectangles ();
72         void rebuild_and_draw_column_labels ();
73         void rebuild_and_draw_row_labels ();
74         void update_bundles ();
75         
76         PortMatrix* _matrix;
77         PortMatrixColumnLabels _column_labels;
78         PortMatrixRowLabels _row_labels;
79         PortMatrixGrid _grid;
80
81         uint32_t _alloc_width; ///< allocated width
82         uint32_t _alloc_height; ///< allocated height
83         Gdk::Rectangle _column_labels_rect;
84         Gdk::Rectangle _row_labels_rect;
85         Gdk::Rectangle _grid_rect;
86         uint32_t _xoffset;
87         uint32_t _yoffset;
88         bool _pointer_inside;
89
90         PortMatrixNode _mouseover;
91
92         std::list<sigc::connection> _bundle_connections;
93 };
94
95 #endif