fix math bug with numthreads computation
[ardour2.git] / gtk2_ardour / sfdb_ui.h
blob15affab5706db414ec8cbc9340f803116615c4c3
1 /*
2 Copyright (C) 2005-2006 Paul Davis
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.
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.
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.
20 #ifndef __ardour_sfdb_ui_h__
21 #define __ardour_sfdb_ui_h__
23 #include <string>
24 #include <vector>
25 #include <map>
26 #include <glibmm/ustring.h>
28 #include <sigc++/signal.h>
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>
41 #include "ardour/audiofilesource.h"
42 #include "ardour/session_handle.h"
44 #include "ardour_dialog.h"
45 #include "editing.h"
46 #include "audio_clock.h"
48 namespace ARDOUR {
49 class Session;
52 class GainMeter;
54 class SoundFileBox : public Gtk::VBox, public ARDOUR::SessionHandlePtr
56 public:
57 SoundFileBox (bool persistent);
58 virtual ~SoundFileBox () {};
60 void set_session (ARDOUR::Session* s);
61 bool setup_labels (const Glib::ustring& filename);
63 void audition();
64 bool audition_oneshot();
65 bool autoplay () const;
67 protected:
68 Glib::ustring path;
70 ARDOUR::SoundFileInfo sf_info;
72 Gtk::Table table;
74 Gtk::Label length;
75 Gtk::Label format;
76 Gtk::Label channels;
77 Gtk::Label samplerate;
78 Gtk::Label timecode;
80 Gtk::Label channels_value;
81 Gtk::Label samplerate_value;
83 Gtk::Label format_text;
84 AudioClock length_clock;
85 AudioClock timecode_clock;
87 Gtk::Frame border_frame;
88 Gtk::Label preview_label;
90 Gtk::TextView tags_entry;
92 Gtk::VBox main_box;
93 Gtk::VBox path_box;
94 Gtk::HBox bottom_box;
96 Gtk::Button play_btn;
97 Gtk::Button stop_btn;
98 Gtk::CheckButton autoplay_btn;
99 Gtk::Button apply_btn;
101 bool tags_entry_left (GdkEventFocus* event);
102 void tags_changed ();
103 void save_tags (const std::vector<std::string>&);
104 void stop_audition ();
107 class SoundFileBrowser : public ArdourDialog
109 private:
110 class FoundTagColumns : public Gtk::TreeModel::ColumnRecord
112 public:
113 Gtk::TreeModelColumn<Glib::ustring> pathname;
115 FoundTagColumns() { add(pathname); }
118 FoundTagColumns found_list_columns;
119 Glib::RefPtr<Gtk::ListStore> found_list;
121 FoundTagColumns freesound_list_columns;
122 Glib::RefPtr<Gtk::ListStore> freesound_list;
124 public:
125 SoundFileBrowser (Gtk::Window& parent, std::string title, ARDOUR::Session* _s, bool persistent);
126 virtual ~SoundFileBrowser ();
128 virtual void set_session (ARDOUR::Session*);
129 std::vector<Glib::ustring> get_paths ();
131 void clear_selection ();
133 Gtk::FileChooserWidget chooser;
135 SoundFileBox preview;
137 Gtk::Entry found_entry;
138 Gtk::Button found_search_btn;
139 Gtk::TreeView found_list_view;
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;
147 void freesound_search_thread();
149 protected:
150 bool resetting_ourselves;
152 Gtk::FileFilter audio_filter;
153 Gtk::FileFilter midi_filter;
154 Gtk::FileFilter custom_filter;
155 Gtk::FileFilter matchall_filter;
156 Gtk::HBox hpacker;
158 static Glib::ustring persistent_folder;
160 Gtk::Notebook notebook;
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;
171 void update_preview ();
173 void found_list_view_selected ();
174 void found_list_view_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn*);
175 void found_search_clicked ();
177 void freesound_list_view_selected ();
178 void freesound_list_view_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn*);
179 void freesound_search_clicked ();
181 void chooser_file_activated ();
183 bool on_audio_filter (const Gtk::FileFilter::Info& filter_info);
184 bool on_midi_filter (const Gtk::FileFilter::Info& filter_info);
186 virtual bool reset_options() { return true; }
188 protected:
189 void on_show();
193 class SoundFileChooser : public SoundFileBrowser
195 public:
196 SoundFileChooser (Gtk::Window& parent, std::string title, ARDOUR::Session* _s = 0);
197 virtual ~SoundFileChooser () {};
199 Glib::ustring get_filename ();
201 protected:
202 void on_hide();
205 class SoundFileOmega : public SoundFileBrowser
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);
212 void reset (int selected_tracks);
214 Gtk::ComboBoxText action_combo;
215 Gtk::ComboBoxText where_combo;
216 Gtk::ComboBoxText channel_combo;
217 Gtk::ComboBoxText src_combo;
219 Gtk::CheckButton copy_files_btn;
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;
227 protected:
228 void on_hide();
230 private:
231 uint32_t selected_track_cnt;
233 typedef std::map<Glib::ustring,Editing::ImportDisposition> DispositionMap;
234 DispositionMap disposition_map;
236 Gtk::HBox options;
237 Gtk::VBox block_two;
238 Gtk::VBox block_three;
239 Gtk::VBox block_four;
241 bool check_info (const std::vector<Glib::ustring>& paths,
242 bool& same_size, bool& src_needed, bool& multichannel);
244 static bool check_link_status (const ARDOUR::Session*, const std::vector<Glib::ustring>& paths);
246 void file_selection_changed ();
247 bool reset_options ();
248 void reset_options_noret ();
249 bool bad_file_message ();
252 #endif // __ardour_sfdb_ui_h__