425e3915c4e0e9cc8974f011d8bf5b65942b1130
[ardour.git] / gtk2_ardour / port_matrix.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_h__
21 #define __gtk_ardour_port_matrix_h__
22
23 #include <list>
24 #include <gtkmm/box.h>
25 #include <gtkmm/scrollbar.h>
26 #include <boost/shared_ptr.hpp>
27 #include "port_matrix_body.h"
28 #include "port_group.h"
29
30 /** The `port matrix' UI.  This is a widget which lets the user alter
31  *  associations between one set of ports and another.  e.g. to connect
32  *  things together.
33  *
34  *  The columns are labelled with various ports from around Ardour and the
35  *  system.
36  *
37  *  It is made up of a body, PortMatrixBody, which is rendered using cairo,
38  *  and some scrollbars.  All of this is arranged inside the VBox that we
39  *  inherit from.
40  */
41
42 namespace ARDOUR {
43         class Bundle;
44 }
45
46 class PortMatrix : public Gtk::VBox
47 {
48 public:
49         PortMatrix (ARDOUR::Session&, ARDOUR::DataType, bool);
50         ~PortMatrix ();
51
52         virtual void setup ();
53         void set_offer_inputs (bool);
54         void set_type (ARDOUR::DataType);
55
56         ARDOUR::DataType type () const {
57                 return _type;
58         }
59         
60         bool offering_input () const {
61                 return _offer_inputs;
62         }
63         
64         void disassociate_all ();
65
66         enum Result {
67                 Cancelled,
68                 Accepted
69         };
70
71         sigc::signal<void, Result> Finished;
72
73         /** @param ab Our bundle.
74          *  @param ac Channel on our bundle.
75          *  @param bb Other bundle.
76          *  @arapm bc Channel on other bundle.
77          *  @param s New state.
78          *  @param k XXX
79          */
80         virtual void set_state (
81                 boost::shared_ptr<ARDOUR::Bundle> ab,
82                 uint32_t ac,
83                 boost::shared_ptr<ARDOUR::Bundle> bb,
84                 uint32_t bc,
85                 bool s,
86                 uint32_t k
87                 ) = 0;
88
89         enum State {
90                 ASSOCIATED,
91                 NOT_ASSOCIATED,
92                 UNKNOWN
93         };
94
95         /** @param ab Our bundle.
96          *  @param ac Channel on our bundle.
97          *  @param bb Other bundle.
98          *  @arapm bc Channel on other bundle.
99          *  @return state
100          */
101         virtual State get_state (
102                 boost::shared_ptr<ARDOUR::Bundle> ab,
103                 uint32_t ac,
104                 boost::shared_ptr<ARDOUR::Bundle> bb,
105                 uint32_t bc
106                 ) const = 0;
107
108         virtual void add_channel (boost::shared_ptr<ARDOUR::Bundle>) = 0;
109         virtual void remove_channel (boost::shared_ptr<ARDOUR::Bundle>, uint32_t) = 0;
110         virtual bool can_rename_channels () const = 0;
111         virtual void rename_channel (boost::shared_ptr<ARDOUR::Bundle>, uint32_t) {}
112         
113         void setup_scrollbars ();
114
115 protected:
116
117         PortGroupList _row_ports;
118         PortGroupList _column_ports;
119         
120 private:
121
122         void hscroll_changed ();
123         void vscroll_changed ();
124         void routes_changed ();
125
126         ARDOUR::Session& _session;
127         /// true to offer inputs, otherwise false
128         bool _offer_inputs;
129         /// port type that we are working with
130         ARDOUR::DataType _type;
131
132         PortMatrixBody _body;
133         Gtk::HScrollbar _hscroll;
134         Gtk::VScrollbar _vscroll;
135         std::list<PortGroupUI*> _port_group_uis;
136         std::vector<sigc::connection> _route_connections;
137 };
138
139 #endif