fix logic error that prevent input monitoring during slave wait states
[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/button.h>
24 #include <gtkmm/comboboxtext.h>
25 #include <gtkmm/entry.h>
26 #include <gtkmm/liststore.h>
27 #include <gtkmm/notebook.h>
28 #include <gtkmm/scrolledwindow.h>
29 #include <gtkmm/treemodel.h>
30 #include <gtkmm/treeview.h>
31
32 #include "gtkmm2ext/dndtreeview.h"
33
34 #include "ardour/plugin.h"
35 #include "ardour/session_handle.h"
36
37 #include "widgets/ardour_button.h"
38
39 #include "plugin_interest.h"
40 #include "ardour_dialog.h"
41
42 namespace ARDOUR {
43         class Session;
44         class PluginManager;
45 }
46
47 class PluginSelector : public ArdourDialog
48 {
49 public:
50         PluginSelector (ARDOUR::PluginManager&);
51         ~PluginSelector ();
52
53         void set_interested_object (PluginInterestedObject&);
54
55         int run (); // XXX should we try not to overload the non-virtual Gtk::Dialog::run() ?
56
57         void on_show ();
58
59         Gtk::Menu* plugin_menu ();
60         void show_manager ();
61
62 private:
63         PluginInterestedObject* interested_object;
64
65         Gtk::ScrolledWindow scroller;   // Available plugins
66         Gtk::ScrolledWindow ascroller;  // Added plugins
67
68         Gtk::ComboBoxText filter_mode;
69         Gtk::Entry filter_entry;
70         Gtk::Button filter_button;
71
72         ArdourWidgets::ArdourButton fil_hidden_button;
73         ArdourWidgets::ArdourButton fil_instruments_button;
74         ArdourWidgets::ArdourButton fil_analysis_button;
75         ArdourWidgets::ArdourButton fil_utils_button;
76
77         void filter_button_clicked ();
78         void filter_entry_changed ();
79         void filter_mode_changed ();
80
81         struct PluginColumns : public Gtk::TreeModel::ColumnRecord {
82                 PluginColumns () {
83                         add (favorite);
84                         add (hidden);
85                         add (name);
86                         add (type_name);
87                         add (category);
88                         add (creator);
89                         add (audio_ins);
90                         add (audio_outs);
91                         add (midi_ins);
92                         add (midi_outs);
93                         add (plugin);
94                 }
95                 Gtk::TreeModelColumn<bool> favorite;
96                 Gtk::TreeModelColumn<bool> hidden;
97                 Gtk::TreeModelColumn<std::string> name;
98                 Gtk::TreeModelColumn<std::string> type_name;
99                 Gtk::TreeModelColumn<std::string> category;
100                 Gtk::TreeModelColumn<std::string> creator;
101                 Gtk::TreeModelColumn<std::string> audio_ins;
102                 Gtk::TreeModelColumn<std::string> audio_outs;
103                 Gtk::TreeModelColumn<std::string> midi_ins;
104                 Gtk::TreeModelColumn<std::string> midi_outs;
105                 Gtk::TreeModelColumn<ARDOUR::PluginInfoPtr> plugin;
106         };
107         PluginColumns plugin_columns;
108         Glib::RefPtr<Gtk::ListStore> plugin_model;
109         Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr> plugin_display;
110         Gtk::Button* btn_add;
111         Gtk::Button* btn_remove;
112
113         struct AddedColumns : public Gtk::TreeModel::ColumnRecord {
114                 AddedColumns () {
115                         add (text);
116                         add (plugin);
117                 }
118                 Gtk::TreeModelColumn<std::string> text;
119                 Gtk::TreeModelColumn<ARDOUR::PluginInfoPtr> plugin;
120         };
121         AddedColumns acols;
122         Glib::RefPtr<Gtk::ListStore> amodel;
123         Gtk::TreeView added_list;
124
125         void refill ();
126         void refiller (const ARDOUR::PluginInfoList& plugs, const::std::string& filterstr, const char* type);
127         void ladspa_refiller (const std::string&);
128         void lv2_refiller (const std::string&);
129         void vst_refiller (const std::string&);
130         void lxvst_refiller (const std::string&);
131         void mac_vst_refiller (const std::string&);
132         void au_refiller (const std::string&);
133         void lua_refiller (const std::string&);
134
135         Gtk::Menu* _plugin_menu;
136         ARDOUR::PluginManager& manager;
137
138         void row_activated(Gtk::TreeModel::Path path, Gtk::TreeViewColumn* col);
139         void btn_add_clicked();
140         void btn_remove_clicked();
141         void added_list_selection_changed();
142         void added_row_clicked(GdkEventButton* event);
143         void display_selection_changed();
144         void btn_apply_clicked();
145         ARDOUR::PluginPtr load_plugin (ARDOUR::PluginInfoPtr);
146         bool show_this_plugin (const ARDOUR::PluginInfoPtr&, const std::string&);
147         void setup_filter_string (std::string&);
148
149         bool fil_hidden_button_release (GdkEventButton*);
150         bool fil_instruments_button_release (GdkEventButton*);
151         bool fil_analysis_button_release (GdkEventButton*);
152         bool fil_utils_button_release (GdkEventButton*);
153
154         void favorite_changed (const std::string& path);
155         void hidden_changed (const std::string& path);
156         bool in_row_change;
157
158         void plugin_chosen_from_menu (const ARDOUR::PluginInfoPtr&);
159
160         Gtk::Menu* create_favs_menu (ARDOUR::PluginInfoList&);
161         Gtk::Menu* create_by_creator_menu (ARDOUR::PluginInfoList&);
162         Gtk::Menu* create_by_category_menu (ARDOUR::PluginInfoList&);
163         void build_plugin_menu ();
164         PBD::ScopedConnectionList plugin_list_changed_connection;
165
166         bool _show_hidden;
167         Gtkmm2ext::ActiveState _show_instruments;
168         Gtkmm2ext::ActiveState _show_analysers;
169         Gtkmm2ext::ActiveState _show_utils;
170 };
171
172 #endif // __ardour_plugin_selector_h__
173