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