8b49e5e2de33e9e187b4cd272fb3affc96be5272
[ardour.git] / gtk2_ardour / io_selector.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_io_selector_h__
21 #define __ardour_ui_io_selector_h__
22
23 #include "ardour_dialog.h"
24 #include "port_matrix.h"
25
26 namespace ARDOUR {
27         class PortInsert;
28 }
29
30 class IOSelector : public PortMatrix {
31   public:
32         IOSelector (ARDOUR::Session&, boost::shared_ptr<ARDOUR::IO>, bool);
33
34         void set_state (
35                 boost::shared_ptr<ARDOUR::Bundle>,
36                 uint32_t,
37                 boost::shared_ptr<ARDOUR::Bundle>,
38                 uint32_t,
39                 bool,
40                 uint32_t
41                 );
42         
43         State get_state (
44                 boost::shared_ptr<ARDOUR::Bundle>,
45                 uint32_t,
46                 boost::shared_ptr<ARDOUR::Bundle>,
47                 uint32_t
48                 ) const;
49
50         void add_channel (boost::shared_ptr<ARDOUR::Bundle>);
51         void remove_channel (boost::shared_ptr<ARDOUR::Bundle>, uint32_t);
52         bool can_rename_channels () const {
53                 return false;
54         }
55         
56         uint32_t n_rows () const;
57         uint32_t maximum_rows () const;
58         uint32_t minimum_rows () const;
59         boost::shared_ptr<ARDOUR::IO> const io () { return _io; }
60         void setup ();
61
62   private:
63         ARDOUR::Session& _session;
64         boost::shared_ptr<ARDOUR::IO> _io;
65         
66         void ports_changed ();
67 };
68
69 class IOSelectorWindow : public ArdourDialog
70 {
71   public:
72         IOSelectorWindow (ARDOUR::Session&, boost::shared_ptr<ARDOUR::IO>, bool for_input, bool can_cancel = false);
73
74         IOSelector& selector() { return _selector; }
75
76   protected:
77         void on_map ();
78         
79   private:
80         IOSelector _selector;
81
82         /* overall operation buttons */
83
84         Gtk::Button add_button;
85         Gtk::Button disconnect_button;
86         Gtk::Button ok_button;
87         Gtk::Button cancel_button;
88         Gtk::Button rescan_button;
89
90         void cancel ();
91         void accept ();
92
93         void ports_changed ();
94         void io_name_changed (void *src);
95 };
96
97
98 class PortInsertUI : public Gtk::VBox
99 {
100   public: 
101         PortInsertUI (ARDOUR::Session&, boost::shared_ptr<ARDOUR::PortInsert>);
102         
103         void redisplay ();
104         void finished (IOSelector::Result);
105
106   private:
107         IOSelector input_selector;
108         IOSelector output_selector;
109 };
110
111 class PortInsertWindow : public ArdourDialog
112 {
113   public: 
114         PortInsertWindow (ARDOUR::Session&, boost::shared_ptr<ARDOUR::PortInsert>, bool can_cancel = false);
115         
116   protected:
117         void on_map ();
118         
119   private:
120         PortInsertUI _portinsertui;
121         Gtk::VBox vbox;
122         
123         Gtk::Button ok_button;
124         Gtk::Button cancel_button;
125         Gtk::Button rescan_button;
126         Gtk::Frame button_frame;
127         
128         void cancel ();
129         void accept ();
130
131         void plugin_going_away ();
132         sigc::connection going_away_connection;
133 };
134
135
136 #endif