27f295b89dad6e6a0964d0e3827a1b8f6a61cbce
[ardour.git] / gtk2_ardour / port_matrix.h
1 /*
2     Copyright (C) 2002-2007 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 __ardour_ui_port_matrix_h__
21 #define __ardour_ui_port_matrix_h__
22
23 #include <gtkmm/box.h>
24 #include <gtkmm/checkbutton.h>
25 #include <gtkmm/table.h>
26 #include <gtkmm/frame.h>
27 #include <gtkmm/eventbox.h>
28 #include <gtkmm/scrolledwindow.h>
29
30 #include "ardour_dialog.h"
31 #include "port_group.h"
32 #include "matrix.h"
33
34 namespace ARDOUR {
35         class Session;
36         class IO;
37         class PortInsert;
38 }
39
40 class PortMatrix : public Gtk::VBox {
41   public:
42         PortMatrix (ARDOUR::Session&, ARDOUR::DataType, bool, PortGroupList::Mask);
43         ~PortMatrix ();
44
45         void setup ();
46
47         enum Result {
48                 Cancelled,
49                 Accepted
50         };
51
52         sigc::signal<void, Result> Finished;
53
54         void set_type (ARDOUR::DataType);
55         void set_offer_inputs (bool);
56         bool offering_input() const { return _offer_inputs; }
57
58         /** @param r Our row index.
59          *  @param p Other port.
60          *  @param s New state.
61          *  @param k XXX
62          */
63         virtual void set_state (int r, std::string const & p, bool s, uint32_t k) = 0;
64
65         /** @param r Our row index.
66          *  @param p Other port.
67          *  @return true if r is connected to p, otherwise false.
68          */
69         virtual bool get_state (int r, std::string const &p) const = 0;
70         
71         virtual uint32_t n_rows () const = 0;
72         virtual uint32_t maximum_rows () const = 0;
73         virtual uint32_t minimum_rows () const = 0;
74         virtual std::string row_name (int) const = 0;
75         virtual void add_row () = 0;
76         virtual void remove_row (int) = 0;
77         virtual std::string row_descriptor () const = 0;
78
79         Gtk::Widget& scrolled_window() { return _scrolled_window; }
80
81   protected:
82
83         bool _offer_inputs;
84         void set_ports (const std::list<std::string>&);
85
86   private:
87         PortGroupList _port_group_list;
88         ARDOUR::DataType _type;
89         Matrix matrix;
90         std::vector<PortGroupUI*> _port_group_ui;
91         std::vector<Gtk::EventBox*> _row_labels;
92         Gtk::VBox* _row_labels_vbox;
93         Gtk::HBox _overall_hbox;
94         Gtk::VBox _side_vbox;
95         Gtk::HBox _port_group_hbox;
96         Gtk::ScrolledWindow _scrolled_window;
97         Gtk::Label* _side_vbox_pad;
98         Gtk::HBox _visibility_checkbutton_box;
99
100         void clear ();
101         bool row_label_button_pressed (GdkEventButton*, int);
102         void reset_visibility ();
103 };
104
105 #endif