Trim session.h include dependency tree.
[ardour.git] / gtk2_ardour / sfdb_ui.h
1 /*
2     Copyright (C) 2005-2006 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_sfdb_ui_h__
21 #define __ardour_sfdb_ui_h__
22
23 #include <string>
24 #include <vector>
25 #include <map>
26 #include <glibmm/ustring.h>
27
28 #include <sigc++/signal.h>
29
30 #include <gtkmm/box.h>
31 #include <gtkmm/button.h>
32 #include <gtkmm/checkbutton.h>
33 #include <gtkmm/comboboxtext.h>
34 #include <gtkmm/dialog.h>
35 #include <gtkmm/entry.h>
36 #include <gtkmm/filechooserwidget.h>
37 #include <gtkmm/frame.h>
38 #include <gtkmm/label.h>
39 #include <gtkmm/textview.h>
40
41 #include "ardour/audiofilesource.h"
42
43 #include "ardour_dialog.h"
44 #include "editing.h"
45 #include "audio_clock.h"
46
47 namespace ARDOUR {
48         class Session;
49 };
50
51 class GainMeter;
52
53 class SoundFileBox : public Gtk::VBox
54 {
55   public:
56         SoundFileBox (bool persistent);
57         virtual ~SoundFileBox () {};
58
59         void set_session (ARDOUR::Session* s);
60         bool setup_labels (const Glib::ustring& filename);
61
62         void audition();
63         bool audition_oneshot();
64         bool autoplay () const;
65
66   protected:
67         ARDOUR::Session* _session;
68         Glib::ustring path;
69
70         ARDOUR::SoundFileInfo sf_info;
71
72         Gtk::Table table;
73
74         Gtk::Label length;
75         Gtk::Label format;
76         Gtk::Label channels;
77         Gtk::Label samplerate;
78         Gtk::Label timecode;
79
80         Gtk::Label channels_value;
81         Gtk::Label samplerate_value;
82
83         Gtk::Label format_text;
84         AudioClock length_clock;
85         AudioClock timecode_clock;
86
87         Gtk::Frame border_frame;
88         Gtk::Label preview_label;
89
90         Gtk::TextView tags_entry;
91
92         Gtk::VBox main_box;
93         Gtk::VBox path_box;
94         Gtk::HBox bottom_box;
95
96         Gtk::Button play_btn;
97         Gtk::Button stop_btn;
98         Gtk::CheckButton autoplay_btn;
99         Gtk::Button apply_btn;
100
101         bool tags_entry_left (GdkEventFocus* event);
102         void tags_changed ();
103         void save_tags (const std::vector<std::string>&);
104         void stop_audition ();
105 };
106
107 class SoundFileBrowser : public ArdourDialog
108 {
109   private:
110         class FoundTagColumns : public Gtk::TreeModel::ColumnRecord
111         {
112           public:
113                 Gtk::TreeModelColumn<Glib::ustring> pathname;
114
115                 FoundTagColumns() { add(pathname); }
116         };
117
118         FoundTagColumns found_list_columns;
119         Glib::RefPtr<Gtk::ListStore> found_list;
120
121         FoundTagColumns freesound_list_columns;
122         Glib::RefPtr<Gtk::ListStore> freesound_list;
123
124   public:
125         SoundFileBrowser (Gtk::Window& parent, std::string title, ARDOUR::Session* _s, bool persistent);
126         virtual ~SoundFileBrowser ();
127
128         virtual void set_session (ARDOUR::Session*);
129         std::vector<Glib::ustring> get_paths ();
130
131         void clear_selection ();
132
133         Gtk::FileChooserWidget chooser;
134
135         SoundFileBox preview;
136
137         Gtk::Entry found_entry;
138         Gtk::Button found_search_btn;
139         Gtk::TreeView found_list_view;
140
141         Gtk::Entry freesound_name_entry;
142         Gtk::Entry freesound_pass_entry;
143         Gtk::Entry freesound_entry;
144         Gtk::Button freesound_search_btn;
145         Gtk::TreeView freesound_list_view;
146
147         void freesound_search_thread();
148
149   protected:
150         bool resetting_ourselves;
151
152         Gtk::FileFilter audio_filter;
153         Gtk::FileFilter midi_filter;
154         Gtk::FileFilter custom_filter;
155         Gtk::FileFilter matchall_filter;
156         Gtk::HBox hpacker;
157
158         static Glib::ustring persistent_folder;
159
160         Gtk::Notebook notebook;
161
162         GainMeter* gm;
163         Gtk::VBox meter_packer;
164         void add_gain_meter ();
165         void remove_gain_meter ();
166         void meter ();
167         void start_metering ();
168         void stop_metering ();
169         sigc::connection metering_connection;
170
171         void update_preview ();
172
173         void found_list_view_selected ();
174         void found_list_view_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn*);
175         void found_search_clicked ();
176
177         void freesound_list_view_selected ();
178         void freesound_list_view_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn*);
179         void freesound_search_clicked ();
180
181         void chooser_file_activated ();
182
183         bool on_audio_filter (const Gtk::FileFilter::Info& filter_info);
184         bool on_midi_filter (const Gtk::FileFilter::Info& filter_info);
185
186         virtual bool reset_options() { return true; }
187
188   protected:
189         void on_show();
190
191 };
192
193 class SoundFileChooser : public SoundFileBrowser
194 {
195   public:
196         SoundFileChooser (Gtk::Window& parent, std::string title, ARDOUR::Session* _s = 0);
197         virtual ~SoundFileChooser () {};
198
199         Glib::ustring get_filename ();
200
201   protected:
202         void on_hide();
203 };
204
205 class SoundFileOmega : public SoundFileBrowser
206 {
207
208   public:
209         SoundFileOmega (Gtk::Window& parent, std::string title, ARDOUR::Session* _s, int selected_tracks, bool persistent,
210                         Editing::ImportMode mode_hint = Editing::ImportAsTrack);
211
212         void reset (int selected_tracks);
213
214         Gtk::ComboBoxText action_combo;
215         Gtk::ComboBoxText where_combo;
216         Gtk::ComboBoxText channel_combo;
217         Gtk::ComboBoxText src_combo;
218
219         Gtk::CheckButton copy_files_btn;
220
221         void set_mode (Editing::ImportMode);
222         Editing::ImportMode get_mode() const;
223         Editing::ImportPosition get_position() const;
224         Editing::ImportDisposition get_channel_disposition() const;
225         ARDOUR::SrcQuality get_src_quality() const;
226
227   protected:
228         void on_hide();
229
230   private:
231         uint32_t selected_track_cnt;
232
233         typedef std::map<Glib::ustring,Editing::ImportDisposition> DispositionMap;
234         DispositionMap disposition_map;
235
236         Gtk::HBox options;
237         Gtk::VBox block_two;
238         Gtk::VBox block_three;
239         Gtk::VBox block_four;
240
241         bool check_info (const std::vector<Glib::ustring>& paths,
242                          bool& same_size, bool& src_needed, bool& multichannel);
243
244         static bool check_link_status (const ARDOUR::Session&, const std::vector<Glib::ustring>& paths);
245
246         void file_selection_changed ();
247         bool reset_options ();
248         void reset_options_noret ();
249         bool bad_file_message ();
250 };
251
252 #endif // __ardour_sfdb_ui_h__