Port matrix tweaks: scroll wheel support; use the correct verb for disassociation...
[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         void add_channel (boost::shared_ptr<ARDOUR::Bundle>);
43         bool can_remove_channels (int d) const {
44                 return d == OURS;
45         }
46         void remove_channel (ARDOUR::BundleChannel);
47         bool can_rename_channels (int d) const {
48                 return d == OURS;
49         }
50         void rename_channel (ARDOUR::BundleChannel);
51         void setup_ports (int);
52         bool list_is_global (int) const;
53
54         std::string disassociation_verb () const {
55                 return _("Disassociate");
56         }
57
58   private:
59         enum {
60                 OTHER = 0,
61                 OURS = 1
62         };
63                 
64         boost::shared_ptr<PortGroup> _port_group;
65         boost::shared_ptr<ARDOUR::Bundle> _bundle;
66 };
67
68 class BundleEditor : public ArdourDialog
69 {
70   public:
71         BundleEditor (ARDOUR::Session &, boost::shared_ptr<ARDOUR::UserBundle>, bool);
72
73   protected:
74         void on_map ();
75
76   private:
77         void name_changed ();
78         void input_or_output_changed ();
79         void type_changed ();
80         
81         BundleEditorMatrix _matrix;
82         boost::shared_ptr<ARDOUR::UserBundle> _bundle;
83         Gtk::Entry _name;
84         Gtk::ComboBoxText _input_or_output;
85         Gtk::ComboBoxText _type;
86 };
87
88 class BundleManager : public ArdourDialog
89 {
90   public:
91         BundleManager (ARDOUR::Session &);
92
93   private:
94
95         void new_clicked ();
96         void edit_clicked ();
97         void delete_clicked ();
98         void add_bundle (boost::shared_ptr<ARDOUR::Bundle>);
99         void bundle_changed (ARDOUR::Bundle::Change, boost::shared_ptr<ARDOUR::UserBundle>);
100         void set_button_sensitivity ();
101
102         class ModelColumns : public Gtk::TreeModelColumnRecord
103         {
104         public:
105                 ModelColumns () {
106                         add (name);
107                         add (bundle);
108                 }
109                 
110                 Gtk::TreeModelColumn<Glib::ustring> name;
111                 Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::UserBundle> > bundle;
112         };
113         
114         Gtk::TreeView _tree_view;
115         Glib::RefPtr<Gtk::ListStore> _list_model;
116         ModelColumns _list_model_columns;
117         ARDOUR::Session& _session;
118         Gtk::Button edit_button;
119         Gtk::Button delete_button;
120 };
121
122 class NameChannelDialog : public ArdourDialog
123 {
124 public:
125         NameChannelDialog ();
126         NameChannelDialog (boost::shared_ptr<ARDOUR::Bundle>, uint32_t);
127
128         std::string get_name () const;
129
130 private:
131
132         void setup ();
133         
134         boost::shared_ptr<ARDOUR::Bundle> _bundle;
135         uint32_t _channel;
136         Gtk::Entry _name;
137         bool _adding;
138 };
139
140 #endif