* first implementation of MIDI Clock Slave support
[ardour.git] / gtk2_ardour / option_editor.h
1 #ifndef __gtk_ardour_option_editor_h__
2 #define __gtk_ardour_option_editor_h__
3
4 /*
5     Copyright (C) 2001 Paul Davis
6
7     This program is free software; you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by
9     the Free Software Foundation; either version 2 of the License, or
10     (at your option) any later version.
11
12     This program is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.
16
17     You should have received a copy of the GNU General Public License
18     along with this program; if not, write to the Free Software
19     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 */
22
23 #include <vector>
24
25 #include <gtkmm/notebook.h>
26 #include <gtkmm/checkbutton.h>
27 #include <gtkmm/table.h>
28 #include <gtkmm/entry.h>
29 #include <gtkmm/box.h>
30 #include <gtkmm/label.h>
31 #include <gtkmm/adjustment.h>
32 #include <gtkmm/scale.h>
33 #include <gtkmm/spinbutton.h>
34 #include <gtkmm/radiobutton.h>
35 #include <gtkmm/comboboxtext.h>
36
37 #include <ardour/session.h>
38
39 #include "ardour_dialog.h"
40 #include "editing.h"
41 #include "audio_clock.h"
42
43 class ARDOUR_UI;
44 class PublicEditor;
45 class Mixer_UI;
46 class IOSelector;
47 class GainMeter;
48 class PannerUI;
49
50 class OptionEditor : public ArdourDialog
51 {
52   public:
53         OptionEditor (ARDOUR_UI&, PublicEditor&, Mixer_UI&);
54         ~OptionEditor ();
55
56         void set_session (ARDOUR::Session *);
57         void save ();
58
59   private:
60         ARDOUR::Session *session;
61         ARDOUR_UI& ui;
62         PublicEditor& editor;
63         Mixer_UI& mixer;
64
65         Gtk::Notebook notebook;
66
67         /* Generic */
68
69         gint wm_close (GdkEventAny *);
70         bool focus_out_event_handler (GdkEventFocus*, void (OptionEditor::*pmf)());
71         void parameter_changed (const char* name);
72
73         /* paths */
74
75         Gtk::Table      path_table;
76         Gtk::Entry      session_raid_entry;
77
78         void setup_path_options();
79         void add_session_paths ();
80         void remove_session_paths ();
81         void raid_path_changed ();
82
83         /* misc */
84
85         Gtk::VBox        misc_packer;
86
87         Gtk::Adjustment  short_xfade_adjustment;
88         Gtk::HScale      short_xfade_slider;
89         Gtk::Adjustment  destructo_xfade_adjustment;
90         Gtk::HScale      destructo_xfade_slider;
91
92         void setup_misc_options();
93
94         void short_xfade_adjustment_changed ();
95         void destructo_xfade_adjustment_changed ();
96
97         Gtk::Adjustment history_depth;
98         Gtk::Adjustment saved_history_depth;
99         Gtk::SpinButton     history_depth_spinner;
100         Gtk::SpinButton     saved_history_depth_spinner;
101         Gtk::CheckButton    limit_history_button;
102         Gtk::CheckButton    save_history_button;
103
104         void history_depth_changed();
105         void saved_history_depth_changed();
106         void save_history_toggled ();
107         void limit_history_toggled ();
108
109         /* Sync */
110
111         Gtk::VBox sync_packer;
112
113         Gtk::ComboBoxText slave_type_combo;
114         AudioClock smpte_offset_clock;
115         Gtk::CheckButton smpte_offset_negative_button;
116         Gtk::CheckButton synced_timecode_button;
117
118         void setup_sync_options ();
119
120         void smpte_offset_chosen ();
121         void smpte_offset_negative_clicked ();
122         void synced_timecode_toggled ();
123
124         /* MIDI */
125
126         Gtk::VBox  midi_packer;
127
128         Gtk::RadioButton::Group mtc_button_group;
129         Gtk::RadioButton::Group mmc_button_group;
130         Gtk::RadioButton::Group midi_button_group;
131         Gtk::RadioButton::Group midi_clock_button_group;
132
133         Gtk::Table      midi_port_table;
134         std::vector<Gtk::Widget*> midi_port_table_widgets;
135         Gtk::Adjustment mmc_receive_device_id_adjustment;
136         Gtk::SpinButton mmc_receive_device_id_spinner;
137         Gtk::Adjustment mmc_send_device_id_adjustment;
138         Gtk::SpinButton mmc_send_device_id_spinner;
139         Gtk::Button     add_midi_port_button;
140
141         void add_midi_port ();
142         void remove_midi_port (MIDI::Port*);
143         void redisplay_midi_ports ();
144
145         void port_online_toggled (MIDI::Port*,Gtk::ToggleButton*);
146         void port_trace_in_toggled (MIDI::Port*,Gtk::ToggleButton*);
147         void port_trace_out_toggled (MIDI::Port*,Gtk::ToggleButton*);
148
149         void mmc_port_chosen (MIDI::Port*,Gtk::RadioButton*, Gtk::Button*);
150         void mtc_port_chosen (MIDI::Port*,Gtk::RadioButton*, Gtk::Button*);
151         void midi_port_chosen (MIDI::Port*,Gtk::RadioButton*, Gtk::Button*);
152         void midi_clock_port_chosen (MIDI::Port*,Gtk::RadioButton*, Gtk::Button*);
153         bool port_removable (MIDI::Port*);
154
155         void mmc_receive_device_id_adjusted ();
156         void mmc_send_device_id_adjusted ();
157
158         void map_port_online (MIDI::Port*, Gtk::ToggleButton*);
159
160         void setup_midi_options();
161
162         enum PortIndex {
163                 MtcIndex = 0,
164                 MmcIndex = 1,
165                 MidiIndex = 2,
166                 MidiClockIndex = 3
167         };
168
169         std::map<MIDI::Port*,std::vector<Gtk::RadioButton*> > port_toggle_buttons;
170
171         /* Click */
172
173         IOSelector*   click_io_selector;
174         GainMeter* click_gpm;
175         PannerUI*     click_panner;
176         Gtk::VBox     click_packer;
177         Gtk::Table    click_table;
178         Gtk::Entry    click_path_entry;
179         Gtk::Entry    click_emphasis_path_entry;
180         Gtk::Button   click_browse_button;
181         Gtk::Button   click_emphasis_browse_button;
182
183         void setup_click_editor ();
184         void clear_click_editor ();
185
186         void click_chosen (const string & paths);
187         void click_emphasis_chosen (const string & paths);
188
189         void click_browse_clicked ();
190         void click_emphasis_browse_clicked ();
191
192         void click_sound_changed ();
193         void click_emphasis_sound_changed ();
194
195         /* Auditioner */
196
197         Gtk::VBox     audition_packer;
198         Gtk::HBox     audition_hpacker;
199         Gtk::Label    audition_label;
200         IOSelector*   auditioner_io_selector;
201         GainMeter* auditioner_gpm;
202         PannerUI* auditioner_panner;
203
204         void setup_auditioner_editor ();
205         void clear_auditioner_editor ();
206         void connect_audition_editor ();
207
208         /* keyboard/mouse */
209
210         Gtk::Table keyboard_mouse_table;
211         Gtk::ComboBoxText keyboard_layout_selector;
212         Gtk::ComboBoxText edit_modifier_combo;
213         Gtk::ComboBoxText delete_modifier_combo;
214         Gtk::ComboBoxText snap_modifier_combo;
215         Gtk::Adjustment delete_button_adjustment;
216         Gtk::SpinButton delete_button_spin;
217         Gtk::Adjustment edit_button_adjustment;
218         Gtk::SpinButton edit_button_spin;
219
220         std::map<std::string,std::string> bindings_files;
221
222         void setup_keyboard_options ();
223         void delete_modifier_chosen ();
224         void edit_modifier_chosen ();
225         void snap_modifier_chosen ();
226         void edit_button_changed ();
227         void delete_button_changed ();
228         void bindings_changed ();
229
230         void fixup_combo_size (Gtk::ComboBoxText&, std::vector<std::string>& strings);
231 };
232
233 #endif /* __gtk_ardour_option_editor_h__ */
234
235