Restore add channel option to port matrix context menu.
[ardour.git] / gtk2_ardour / bundle_manager.h
1 /*
2     Copyright (C) 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_bundle_manager_h__
21 #define __ardour_ui_bundle_manager_h__
22
23 #include <gtkmm/treeview.h>
24 #include <gtkmm/liststore.h>
25 #include <gtkmm/entry.h>
26 #include "ardour_dialog.h"
27 #include "port_matrix.h"
28 #include "i18n.h"
29
30 namespace ARDOUR {
31         class Session;
32         class Bundle;
33 }
34
35 class BundleEditorMatrix : public PortMatrix
36 {
37   public:
38         BundleEditorMatrix (ARDOUR::Session &, boost::shared_ptr<ARDOUR::Bundle>);
39
40         void set_state (ARDOUR::BundleChannel c[2], bool s);
41         PortMatrixNode::State get_state (ARDOUR::BundleChannel c[2]) const;
42         std::string add_channel_name () const;
43         void add_channel ();
44         bool can_remove_channels (int d) const {
45                 return d == OURS;
46         }
47         void remove_channel (ARDOUR::BundleChannel);
48         bool can_rename_channels (int d) const {
49                 return d == OURS;
50         }
51         void rename_channel (ARDOUR::BundleChannel);
52         void setup_ports (int);
53         bool list_is_global (int) const;
54
55         std::string disassociation_verb () const {
56                 return _("Disassociate");
57         }
58
59   private:
60         enum {
61                 OTHER = 0,
62                 OURS = 1
63         };
64                 
65         boost::shared_ptr<PortGroup> _port_group;
66         boost::shared_ptr<ARDOUR::Bundle> _bundle;
67 };
68
69 class BundleEditor : public ArdourDialog
70 {
71   public:
72         BundleEditor (ARDOUR::Session &, boost::shared_ptr<ARDOUR::UserBundle>, bool);
73
74   protected:
75         void on_map ();
76
77   private:
78         void name_changed ();
79         void input_or_output_changed ();
80         void type_changed ();
81         
82         BundleEditorMatrix _matrix;
83         boost::shared_ptr<ARDOUR::UserBundle> _bundle;
84         Gtk::Entry _name;
85         Gtk::ComboBoxText _input_or_output;
86         Gtk::ComboBoxText _type;
87 };
88
89 class BundleManager : public ArdourDialog
90 {
91   public:
92         BundleManager (ARDOUR::Session &);
93
94   private:
95
96         void new_clicked ();
97         void edit_clicked ();
98         void delete_clicked ();
99         void add_bundle (boost::shared_ptr<ARDOUR::Bundle>);
100         void bundle_changed (ARDOUR::Bundle::Change, boost::shared_ptr<ARDOUR::UserBundle>);
101         void set_button_sensitivity ();
102
103         class ModelColumns : public Gtk::TreeModelColumnRecord
104         {
105         public:
106                 ModelColumns () {
107                         add (name);
108                         add (bundle);
109                 }
110                 
111                 Gtk::TreeModelColumn<Glib::ustring> name;
112                 Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::UserBundle> > bundle;
113         };
114         
115         Gtk::TreeView _tree_view;
116         Glib::RefPtr<Gtk::ListStore> _list_model;
117         ModelColumns _list_model_columns;
118         ARDOUR::Session& _session;
119         Gtk::Button edit_button;
120         Gtk::Button delete_button;
121 };
122
123 class NameChannelDialog : public ArdourDialog
124 {
125 public:
126         NameChannelDialog ();
127         NameChannelDialog (boost::shared_ptr<ARDOUR::Bundle>, uint32_t);
128
129         std::string get_name () const;
130
131 private:
132
133         void setup ();
134         
135         boost::shared_ptr<ARDOUR::Bundle> _bundle;
136         uint32_t _channel;
137         Gtk::Entry _name;
138         bool _adding;
139 };
140
141 #endif