VKeybd: Pass on primary (Ctrl/Cmd) shortcuts
[ardour.git] / gtk2_ardour / plugin_selector.h
1 /*
2  * Copyright (C) 2005-2006 Doug McLain <doug@nostar.net>
3  * Copyright (C) 2005-2006 Taybin Rutkin <taybin@taybin.com>
4  * Copyright (C) 2005-2011 Paul Davis <paul@linuxaudiosystems.com>
5  * Copyright (C) 2006-2012 David Robillard <d@drobilla.net>
6  * Copyright (C) 2006 Nick Mainsbridge <mainsbridge@gmail.com>
7  * Copyright (C) 2009 Carl Hetherington <carl@carlh.net>
8  * Copyright (C) 2014-2019 Robin Gareus <robin@gareus.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License along
21  * with this program; if not, write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24
25 #ifndef __ardour_plugin_selector_h__
26 #define __ardour_plugin_selector_h__
27
28 #include <gtkmm/button.h>
29 #include <gtkmm/checkbutton.h>
30 #include <gtkmm/comboboxtext.h>
31 #include <gtkmm/entry.h>
32 #include <gtkmm/liststore.h>
33 #include <gtkmm/notebook.h>
34 #include <gtkmm/scrolledwindow.h>
35 #include <gtkmm/treemodel.h>
36 #include <gtkmm/treeview.h>
37
38 #include "widgets/ardour_button.h"
39 #include "widgets/ardour_dropdown.h"
40
41 #include "gtkmm2ext/dndtreeview.h"
42
43 #include "ardour/plugin.h"
44 #include "ardour/plugin_manager.h"
45 #include "ardour/session_handle.h"
46
47 #include "widgets/ardour_button.h"
48
49 #include "plugin_interest.h"
50 #include "ardour_dialog.h"
51
52 namespace ARDOUR {
53         class Session;
54         class PluginManager;
55 }
56
57 class PluginSelector : public ArdourDialog
58 {
59 public:
60         PluginSelector (ARDOUR::PluginManager&);
61         ~PluginSelector ();
62
63         void set_interested_object (PluginInterestedObject&);
64
65         int run (); // XXX should we try not to overload the non-virtual Gtk::Dialog::run() ?
66
67         void on_show ();
68
69         Gtk::Menu* plugin_menu ();
70         void show_manager ();
71
72 private:
73
74         //search
75         ArdourWidgets::ArdourButton* _search_name_checkbox;
76         ArdourWidgets::ArdourButton* _search_tags_checkbox;
77         ArdourWidgets::ArdourButton* _search_ignore_checkbox;
78
79         //radio-button filters
80         Gtk::RadioButton *_fil_effects_radio;
81         Gtk::RadioButton *_fil_instruments_radio;
82         Gtk::RadioButton *_fil_utils_radio;
83         Gtk::RadioButton *_fil_favorites_radio;
84         Gtk::RadioButton *_fil_hidden_radio;
85         Gtk::RadioButton *_fil_all_radio;
86
87         /* combobox filters */
88         ArdourWidgets::ArdourDropdown _fil_type_combo;
89         ArdourWidgets::ArdourDropdown _fil_creator_combo;
90
91         PluginInterestedObject* interested_object;
92
93         Gtk::ScrolledWindow scroller;   // Available plugins
94         Gtk::ScrolledWindow ascroller;  // Added plugins
95
96         Gtk::Entry search_entry;
97         Gtk::Button search_clear_button;
98
99         Gtk::Entry *tag_entry;
100         Gtk::Button* tag_reset_button;
101         void tag_reset_button_clicked ();
102
103         void set_sensitive_widgets();
104
105         void search_clear_button_clicked ();
106         void search_entry_changed ();
107
108         void tag_entry_changed ();
109         sigc::connection tag_entry_connection;
110
111         void tags_changed ( ARDOUR::PluginType t, std::string unique_id, std::string tag);
112
113         struct PluginColumns : public Gtk::TreeModel::ColumnRecord {
114                 PluginColumns () {
115                         add (favorite);
116                         add (hidden);
117                         add (name);
118                         add (tags);
119                         add (creator);
120                         add (type_name);
121                         add (audio_io);
122                         add (midi_io);
123                         add (plugin);
124                 }
125                 Gtk::TreeModelColumn<bool> favorite;
126                 Gtk::TreeModelColumn<bool> hidden;
127                 Gtk::TreeModelColumn<std::string> name;
128                 Gtk::TreeModelColumn<std::string> type_name;
129                 Gtk::TreeModelColumn<std::string> creator;
130                 Gtk::TreeModelColumn<std::string> tags;
131                 Gtk::TreeModelColumn<std::string> audio_io;
132                 Gtk::TreeModelColumn<std::string> midi_io;
133                 Gtk::TreeModelColumn<ARDOUR::PluginInfoPtr> plugin;
134         };
135         PluginColumns plugin_columns;
136         Glib::RefPtr<Gtk::ListStore> plugin_model;
137         Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr> plugin_display;
138         Gtk::Button* btn_add;
139         Gtk::Button* btn_remove;
140
141         struct AddedColumns : public Gtk::TreeModel::ColumnRecord {
142                 AddedColumns () {
143                         add (text);
144                         add (plugin);
145                 }
146                 Gtk::TreeModelColumn<std::string> text;
147                 Gtk::TreeModelColumn<ARDOUR::PluginInfoPtr> plugin;
148         };
149         AddedColumns acols;
150         Glib::RefPtr<Gtk::ListStore> amodel;
151         Gtk::TreeView added_list;
152
153         void refill ();
154         void refiller (const ARDOUR::PluginInfoList& plugs, const::std::string& filterstr, const char* type);
155         void ladspa_refiller (const std::string&);
156         void lv2_refiller (const std::string&);
157         void vst_refiller (const std::string&);
158         void lxvst_refiller (const std::string&);
159         void mac_vst_refiller (const std::string&);
160         void au_refiller (const std::string&);
161         void lua_refiller (const std::string&);
162
163         Gtk::Menu* _plugin_menu;
164         ARDOUR::PluginManager& manager;
165
166         void row_activated(Gtk::TreeModel::Path path, Gtk::TreeViewColumn* col);
167         void btn_add_clicked();
168         void btn_remove_clicked();
169         void added_list_selection_changed();
170         void added_row_clicked(GdkEventButton* event);
171         void display_selection_changed();
172         void btn_apply_clicked();
173         ARDOUR::PluginPtr load_plugin (ARDOUR::PluginInfoPtr);
174         bool show_this_plugin (const ARDOUR::PluginInfoPtr&, const std::string&);
175
176         void favorite_changed (const std::string& path);
177         void hidden_changed (const std::string& path);
178         bool in_row_change;
179
180         void plugin_chosen_from_menu (const ARDOUR::PluginInfoPtr&);
181
182         void plugin_status_changed ( ARDOUR::PluginType t, std::string unique_id, ARDOUR::PluginManager::PluginStatusType s );
183
184         Gtk::Menu* create_favs_menu (ARDOUR::PluginInfoList&);
185         Gtk::Menu* create_by_creator_menu (ARDOUR::PluginInfoList&);
186         Gtk::Menu* create_by_tags_menu (ARDOUR::PluginInfoList&);
187         void build_plugin_menu ();
188         PBD::ScopedConnectionList plugin_list_changed_connection;
189
190         bool _need_tag_save;
191         bool _need_status_save;
192         bool _need_menu_rebuild;
193         bool _inhibit_refill;
194 };
195
196 #endif // __ardour_plugin_selector_h__
197