Plugin selector keyboard focus should now stay in the plugin list. More
[ardour.git] / gtk2_ardour / plugin_selector.h
1 /*
2     Copyright (C) 2000 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_plugin_selector_h__
21 #define __ardour_plugin_selector_h__
22
23 #include <gtkmm/dialog.h>
24 #include <gtkmm/notebook.h>
25 #include <gtkmm/treeview.h>
26 #include <gtkmm2ext/selector.h>
27
28 #include <ardour/plugin.h>
29
30 namespace ARDOUR {
31         class Session;
32         class PluginManager;
33 }
34
35 class PluginSelector : public ArdourDialog
36 {
37   public:
38         PluginSelector (ARDOUR::PluginManager *);
39         sigc::signal<void,boost::shared_ptr<ARDOUR::Plugin> > PluginCreated;
40
41         int run (); // XXX should we try not to overload the non-virtual Gtk::Dialog::run() ?
42
43         void set_session (ARDOUR::Session*);
44
45   private:
46         ARDOUR::Session* session;
47         Gtk::Notebook notebook;
48         Gtk::ScrolledWindow lscroller;  // ladspa
49         Gtk::ScrolledWindow vscroller;  // vst
50         Gtk::ScrolledWindow auscroller; // AudioUnit
51         Gtk::ScrolledWindow ascroller;  // Added plugins
52         
53         ARDOUR::PluginType current_selection;
54
55         // page 1
56         struct LadspaColumns : public Gtk::TreeModel::ColumnRecord {
57                 LadspaColumns () {
58                         add (name);
59                     add (type);
60                         add (ins);
61                         add (outs);
62                         add (plugin);
63                 }
64             Gtk::TreeModelColumn<std::string> name;
65                 Gtk::TreeModelColumn<std::string> type;
66                 Gtk::TreeModelColumn<std::string> ins;
67                 Gtk::TreeModelColumn<std::string> outs;
68             Gtk::TreeModelColumn<ARDOUR::PluginInfoPtr> plugin;
69         };
70         LadspaColumns lcols;
71         Glib::RefPtr<Gtk::ListStore> lmodel;
72         Glib::RefPtr<Gtk::TreeSelection> lselection;
73         Gtk::TreeView ladspa_display;
74         Gtk::Button* btn_add;
75         Gtk::Button* btn_remove;
76
77         struct AddedColumns : public Gtk::TreeModel::ColumnRecord {
78                 AddedColumns () {
79                         add (text);
80                         add (plugin);
81                 }
82                 Gtk::TreeModelColumn<std::string> text;
83                 Gtk::TreeModelColumn<ARDOUR::PluginInfoPtr> plugin;
84         };
85         AddedColumns acols;
86         Glib::RefPtr<Gtk::ListStore> amodel;
87         Glib::RefPtr<Gtk::TreeSelection> aselection;
88         Gtk::TreeView added_list;
89
90 #ifdef VST_SUPPORT
91         // page 2
92         struct VstColumns : public Gtk::TreeModel::ColumnRecord {
93                 VstColumns () {
94                         add (name);
95                         add (ins);
96                         add (outs);
97                         add (plugin);
98                 }
99             Gtk::TreeModelColumn<std::string> name;
100                 Gtk::TreeModelColumn<std::string> ins;
101                 Gtk::TreeModelColumn<std::string> outs;
102             Gtk::TreeModelColumn<ARDOUR::PluginInfoPtr> plugin;
103         };
104         VstColumns vcols;
105         Glib::RefPtr<Gtk::ListStore> vmodel;
106         Glib::RefPtr<Gtk::TreeSelection> vselection;
107         Gtk::TreeView vst_display;
108         static void _vst_refiller (void *);
109         void vst_refiller ();
110         void vst_display_selection_changed();
111 #endif // VST_SUPPORT
112
113 #ifdef HAVE_COREAUDIO
114         // page 3
115         struct AUColumns : public Gtk::TreeModel::ColumnRecord {
116                 AUColumns () {
117                         add (name);
118                         add (ins);
119                         add (outs);
120                         add (plugin);
121                 }
122                 Gtk::TreeModelColumn<std::string> name;
123                 Gtk::TreeModelColumn<std::string> ins;
124                 Gtk::TreeModelColumn<std::string> outs;
125                 Gtk::TreeModelColumn<ARDOUR::PluginInfoPtr> plugin;
126         };
127         AUColumns aucols;
128         Glib::RefPtr<Gtk::ListStore> aumodel;
129         Glib::RefPtr<Gtk::TreeSelection> auselection;
130         Gtk::TreeView au_display;
131         static void _au_refiller (void *);
132         void au_refiller ();
133         void au_display_selection_changed();
134 #endif //HAVE_COREAUDIO
135
136         ARDOUR::PluginManager *manager;
137
138         static void _input_refiller (void *);
139         
140         void input_refiller ();
141         void row_clicked(GdkEventButton *);
142         void btn_add_clicked();
143         void btn_remove_clicked();
144         void btn_update_clicked();
145         void added_list_selection_changed();
146         void ladspa_display_selection_changed();
147         void btn_apply_clicked();
148         void use_plugin (ARDOUR::PluginInfoPtr);
149         void cleanup ();
150
151         void set_correct_focus();
152 };
153
154 #endif // __ardour_plugin_selector_h__
155