-
-static vector<string> positional_sync_strings;
-
-OptionEditor::OptionEditor (ARDOUR_UI& uip, PublicEditor& ed, Mixer_UI& mixui)
- : Dialog ("options editor"),
- ui (uip),
- editor (ed),
- mixer (mixui),
-
- /* Paths */
- path_table (11, 2),
-
- /* Fades */
-
- short_xfade_adjustment (0, 1.0, 500.0, 5.0, 100.0),
- short_xfade_slider (short_xfade_adjustment),
- destructo_xfade_adjustment (1.0, 1.0, 500.0, 1.0, 100.0),
- destructo_xfade_slider (destructo_xfade_adjustment),
-
- /* Sync */
-
- smpte_offset_clock (X_("smpteoffset"), false, X_("SMPTEOffsetClock"), true, true),
- smpte_offset_negative_button (_("SMPTE offset is negative")),
-
- /* MIDI */
-
- mmc_device_id_adjustment (0.0, 0.0, (double) 0x7f, 1.0, 16.0),
- mmc_device_id_spinner (mmc_device_id_adjustment),
-
- /* Click */
-
- click_table (2, 3),
- click_browse_button (_("Browse")),
- click_emphasis_browse_button (_("Browse")),
-
- /* kbd/mouse */
-
- keyboard_mouse_table (3, 4),
- delete_button_adjustment (3, 1, 5),
- delete_button_spin (delete_button_adjustment),
- edit_button_adjustment (3, 1, 5),
- edit_button_spin (edit_button_adjustment)
-
-{
- using namespace Notebook_Helpers;
-
- click_io_selector = 0;
- auditioner_io_selector = 0;
- session = 0;
-
- WindowTitle title(Glib::get_application_name());
- title += _("Options Editor");
- set_title(title.get_string());
-
- set_default_size (300, 300);
- set_wmclass (X_("ardour_option_editor"), "Ardour");
-
- set_name ("OptionsWindow");
- add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
-
- VBox *vbox = get_vbox();
- set_border_width (3);
-
- vbox->set_spacing (4);
- vbox->pack_start(notebook);
-
- signal_delete_event().connect (mem_fun(*this, &OptionEditor::wm_close));
-
- notebook.set_show_tabs (true);
- notebook.set_show_border (true);
- notebook.set_name ("OptionsNotebook");
-
- setup_sync_options();
- setup_path_options();
- setup_fade_options ();
- setup_keyboard_options ();
- setup_auditioner_editor ();
-
- notebook.pages().push_back (TabElem (sync_packer, _("Sync")));
- notebook.pages().push_back (TabElem (path_table, _("Paths/Files")));
- notebook.pages().push_back (TabElem (keyboard_mouse_table, _("Kbd/Mouse")));
- notebook.pages().push_back (TabElem (click_packer, _("Click")));
- notebook.pages().push_back (TabElem (audition_packer, _("Audition")));
- notebook.pages().push_back (TabElem (fade_packer, _("Layers & Fades")));
-
- if (!MIDI::Manager::instance()->get_midi_ports().empty()) {
- setup_midi_options ();
- notebook.pages().push_back (TabElem (midi_packer, _("MIDI")));
- }
-
- set_session (0);
- show_all_children();
-}
-
-void
-OptionEditor::set_session (Session *s)
-{
- clear_click_editor ();
- clear_auditioner_editor ();
-
- click_path_entry.set_text ("");
- click_emphasis_path_entry.set_text ("");
- session_raid_entry.set_text ("");
-
- click_path_entry.set_sensitive (false);
- click_emphasis_path_entry.set_sensitive (false);
- session_raid_entry.set_sensitive (false);
-
- short_xfade_slider.set_sensitive (false);
- smpte_offset_negative_button.set_sensitive (false);
-
- smpte_offset_clock.set_session (s);
-
- if ((session = s) == 0) {
- return;
- }
-
- click_path_entry.set_sensitive (true);
- click_emphasis_path_entry.set_sensitive (true);
- session_raid_entry.set_sensitive (true);
- short_xfade_slider.set_sensitive (true);
- smpte_offset_negative_button.set_sensitive (true);
-
- smpte_offset_clock.set_session (s);
- smpte_offset_clock.set (s->smpte_offset (), true);
-
- smpte_offset_negative_button.set_active (session->smpte_offset_negative());
-
- /* set up port assignments */
-
- std::map<MIDI::Port*,vector<RadioButton*> >::iterator res;
-
- if (session->mtc_port()) {
- if ((res = port_toggle_buttons.find (session->mtc_port())) != port_toggle_buttons.end()) {
- (*res).second[MtcIndex]->set_active (true);
- }
- }
-
- if (session->mmc_port ()) {
- if ((res = port_toggle_buttons.find (session->mmc_port())) != port_toggle_buttons.end()) {
- (*res).second[MmcIndex]->set_active (true);
- }
- }
-
- if (session->midi_port()) {
- if ((res = port_toggle_buttons.find (session->midi_port())) != port_toggle_buttons.end()) {
- (*res).second[MidiIndex]->set_active (true);
- }
- }
-
- setup_click_editor ();
- connect_audition_editor ();
-
- short_xfade_adjustment.set_value ((Crossfade::short_xfade_length() / (float) session->frame_rate()) * 1000.0);
-
- add_session_paths ();
-}
-
-OptionEditor::~OptionEditor ()
-{
-}
-
-void
-OptionEditor::setup_path_options()
-{
- Gtk::Label* label;
-
- path_table.set_homogeneous (false);
- path_table.set_border_width (12);
- path_table.set_row_spacings (5);
-
- session_raid_entry.set_name ("OptionsEntry");
-
- session_raid_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::raid_path_changed));
-
- label = manage(new Label(_("session RAID path")));
- label->set_name ("OptionsLabel");
- path_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
- path_table.attach (session_raid_entry, 1, 3, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
-
- path_table.show_all();
-}
-
-void
-OptionEditor::add_session_paths ()
-{
- click_path_entry.set_sensitive (true);
- click_emphasis_path_entry.set_sensitive (true);
- session_raid_entry.set_sensitive (true);
-
- if (Config->get_click_sound().empty()) {
- click_path_entry.set_text (_("internal"));
- } else {
- click_path_entry.set_text (Config->get_click_sound());
- }
-
- if (Config->get_click_emphasis_sound().empty()) {
- click_emphasis_path_entry.set_text (_("internal"));
- } else {
- click_emphasis_path_entry.set_text (Config->get_click_emphasis_sound());
- }
-
- session_raid_entry.set_text(session->raid_path());
-}
-
-void
-OptionEditor::setup_fade_options ()
-{
- Gtk::HBox* hbox;
-
- Label* label = manage (new Label (_("Short crossfade length (msecs)")));
- label->set_name ("OptionsLabel");
-
- hbox = manage (new HBox);
- hbox->set_border_width (5);
- hbox->set_spacing (10);
- hbox->pack_start (*label, false, false);
- hbox->pack_start (short_xfade_slider, true, true);
- fade_packer.pack_start (*hbox, false, false);
-
- short_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::short_xfade_adjustment_changed));
-
- label = manage (new Label (_("Destructive crossfade length (msecs)")));
- label->set_name ("OptionsLabel");
-
- hbox = manage (new HBox);
- hbox->set_border_width (5);
- hbox->set_spacing (10);
- hbox->pack_start (*label, false, false);
- hbox->pack_start (destructo_xfade_slider, true, true);
- fade_packer.pack_start (*hbox, false, false);
-
- destructo_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::destructo_xfade_adjustment_changed));
-
- short_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
- destructo_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
-
- destructo_xfade_adjustment.set_value (Config->get_destructive_xfade_msecs());
-
- fade_packer.show_all ();
-}
-
-void
-OptionEditor::short_xfade_adjustment_changed ()
-{
- if (session) {
- float val = short_xfade_adjustment.get_value();
-
- /* val is in msecs */
-
- Crossfade::set_short_xfade_length ((nframes_t) floor (session->frame_rate() * (val / 1000.0)));
- }
-}
-
-void
-OptionEditor::destructo_xfade_adjustment_changed ()
-{
- float val = destructo_xfade_adjustment.get_value();
-
- /* val is in msecs */
-
-
- Config->set_destructive_xfade_msecs ((uint32_t) floor (val));
-
- if (session) {
- SndFileSource::setup_standard_crossfades (session->frame_rate());
- }
-}
-
-void
-OptionEditor::setup_sync_options ()
-{
- HBox* hbox;
- vector<string> dumb;
-
- smpte_offset_clock.set_mode (AudioClock::SMPTE);
- smpte_offset_clock.ValueChanged.connect (mem_fun(*this, &OptionEditor::smpte_offset_chosen));
-
- smpte_offset_negative_button.set_name ("OptionEditorToggleButton");
-
- smpte_offset_negative_button.unset_flags (Gtk::CAN_FOCUS);
-
- Label *smpte_offset_label = manage (new Label (_("SMPTE Offset")));
- smpte_offset_label->set_name("OptionsLabel");
-
- hbox = manage (new HBox);
- hbox->set_border_width (5);
- hbox->set_spacing (10);
- hbox->pack_start (*smpte_offset_label, false, false);
- hbox->pack_start (smpte_offset_clock, false, false);
- hbox->pack_start (smpte_offset_negative_button, false, false);
-
- sync_packer.pack_start (*hbox, false, false);
-
- smpte_offset_negative_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::smpte_offset_negative_clicked));
-}
-
-void
-OptionEditor::smpte_offset_negative_clicked ()
-{
- if (session) {
- session->set_smpte_offset_negative (smpte_offset_negative_button.get_active());
- }
-}
-
-void
-OptionEditor::smpte_offset_chosen()
-{
- if (session) {
- nframes_t frames = smpte_offset_clock.current_duration();
- session->set_smpte_offset (frames);
- }
-}
-
-
-void
-OptionEditor::setup_midi_options ()
-{
- HBox* hbox;
- MIDI::Manager::PortMap::const_iterator i;
- const MIDI::Manager::PortMap& ports = MIDI::Manager::instance()->get_midi_ports();
- int n;
- ToggleButton* tb;
- RadioButton* rb;
-
- Gtk::Table* table = manage (new Table (ports.size() + 4, 10));
-
- table->set_row_spacings (6);
- table->set_col_spacings (10);
-
- table->attach (*(manage (new Label (_("Port")))), 0, 1, 0, 1);
- table->attach (*(manage (new Label (_("Offline")))), 1, 2, 0, 1);
- table->attach (*(manage (new Label (_("Trace\nInput")))), 2, 3, 0, 1);
- table->attach (*(manage (new Label (_("Trace\nOutput")))), 3, 4, 0, 1);
- table->attach (*(manage (new Label (_("MTC")))), 4, 5, 0, 1);
- table->attach (*(manage (new Label (_("MMC")))), 6, 7, 0, 1);
- table->attach (*(manage (new Label (_("MIDI Parameter\nControl")))), 8, 9, 0, 1);
-
- table->attach (*(manage (new HSeparator())), 0, 9, 1, 2);
- table->attach (*(manage (new VSeparator())), 5, 6, 0, 8);
- table->attach (*(manage (new VSeparator())), 7, 8, 0, 8);
-
- table->attach (*(manage (new Label (_("MMC Device ID")))), 9, 10, 0, 1);
- table->attach (mmc_device_id_spinner, 9, 10, 1, 2);
-
- mmc_device_id_adjustment.signal_value_changed().connect (mem_fun (*this, &OptionEditor::mmc_device_id_adjusted));
-
- for (n = 0, i = ports.begin(); i != ports.end(); ++n, ++i) {
-
- pair<MIDI::Port*,vector<RadioButton*> > newpair;
-
- newpair.first = i->second;
-
- table->attach (*(manage (new Label (i->first))), 0, 1, n+2, n+3,FILL|EXPAND, FILL );
- tb = manage (new ToggleButton (_("online")));
- tb->set_name ("OptionEditorToggleButton");
-
- /* remember, we have to handle the i18n case where the relative
- lengths of the strings in language N is different than in english.
- */
-
- if (strlen (_("offline")) > strlen (_("online"))) {
- set_size_request_to_display_given_text (*tb, _("offline"), 15, 12);
- } else {
- set_size_request_to_display_given_text (*tb, _("online"), 15, 12);
- }
-
- tb->set_active (!(*i).second->input()->offline());
- tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_online_toggled), (*i).second, tb));
- (*i).second->input()->OfflineStatusChanged.connect (bind (mem_fun(*this, &OptionEditor::map_port_online), (*i).second, tb));
- table->attach (*tb, 1, 2, n+2, n+3, FILL|EXPAND, FILL);
-
- tb = manage (new ToggleButton ());
- tb->set_name ("OptionEditorToggleButton");
- tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_trace_in_toggled), (*i).second, tb));
- tb->set_size_request (10, 10);
- table->attach (*tb, 2, 3, n+2, n+3, FILL|EXPAND, FILL);
-
- tb = manage (new ToggleButton ());
- tb->set_name ("OptionEditorToggleButton");
- tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_trace_out_toggled), (*i).second, tb));
- tb->set_size_request (10, 10);
- table->attach (*tb, 3, 4, n+2, n+3, FILL|EXPAND, FILL);
-
- rb = manage (new RadioButton ());
- newpair.second.push_back (rb);
- rb->set_name ("OptionEditorToggleButton");
- if (n == 0) {
- mtc_button_group = rb->get_group();
- } else {
- rb->set_group (mtc_button_group);
-
- }
- table->attach (*rb, 4, 5, n+2, n+3, FILL|EXPAND, FILL);
- rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mtc_port_chosen), (*i).second, rb));
-
- if (Config->get_mtc_port_name() == i->first) {
- rb->set_active (true);
- }
-
- rb = manage (new RadioButton ());
- newpair.second.push_back (rb);
- rb->set_name ("OptionEditorToggleButton");
- if (n == 0) {
- mmc_button_group = rb->get_group();
- } else {
- rb->set_group (mmc_button_group);
- }
- table->attach (*rb, 6, 7, n+2, n+3, FILL|EXPAND, FILL);
- rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mmc_port_chosen), (*i).second, rb));
-
- if (Config->get_mmc_port_name() == i->first) {
- rb->set_active (true);
- }
-
- rb = manage (new RadioButton ());
- newpair.second.push_back (rb);
- rb->set_name ("OptionEditorToggleButton");
- if (n == 0) {
- midi_button_group = rb->get_group();
- } else {
- rb->set_group (midi_button_group);
- }
- table->attach (*rb, 8, 9, n+2, n+3, FILL|EXPAND, FILL);
- rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::midi_port_chosen), (*i).second, rb));
-
- if (Config->get_midi_port_name() == i->first) {
- rb->set_active (true);
- }
-
- port_toggle_buttons.insert (newpair);
- }
-
- table->show_all ();
-
- hbox = manage (new HBox);
- hbox->set_border_width (6);
- hbox->pack_start (*table, true, false);
- midi_packer.pack_start (*hbox, false, false);
-}