X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Foption_editor.cc;h=dcae19ef77b6c1fcbfcf1693119182159908e98f;hb=7f1784252882cd216a9912f57f66533cc06af8a5;hp=491579b286f38841e33dd6054ad06f6280752a71;hpb=6817b59169b2c334245f8018d7e3f2235e195aa0;p=ardour.git diff --git a/gtk2_ardour/option_editor.cc b/gtk2_ardour/option_editor.cc index 491579b286..dcae19ef77 100644 --- a/gtk2_ardour/option_editor.cc +++ b/gtk2_ardour/option_editor.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2001 Paul Davis + Copyright (C) 2001-2009 Paul Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,1189 +15,341 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ -#include +#include +#include +#include "gtkmm2ext/utils.h" -#include -#include -#include -#include -#include -#include -#include -#include +#include "ardour/configuration.h" +#include "ardour/rc_configuration.h" +#include "ardour/utils.h" +#include "ardour/dB.h" -#include "public_editor.h" -#include "mixer_ui.h" -#include "ardour_ui.h" -#include "io_selector.h" -#include "gain_meter.h" -#include "sfdb_ui.h" -#include "utils.h" -#include "editing.h" #include "option_editor.h" - +#include "gui_thread.h" +#include "utils.h" #include "i18n.h" -using namespace ARDOUR; +using namespace std; using namespace Gtk; -using namespace Editing; using namespace Gtkmm2ext; -using namespace std; - -static const gchar *lmode_strings[] = { - N_("Later regions are higher"), - N_("Most recently added/moved/trimmed regions are higher"), - N_("Most recently added regions are higher"), - 0 -}; - -static const gchar *xfl_strings[] = { - N_("Span entire region overlap"), - N_("Short fades at the start of the overlap"), - 0 -}; - -static vector positional_sync_strings; -static vector layer_mode_strings; -static vector xfade_model_strings; - -OptionEditor::OptionEditor (ARDOUR_UI& uip, PublicEditor& ed, Mixer_UI& mixui) - : Dialog ("option editor"), - ui (uip), - editor (ed), - mixer (mixui), - - /* Paths */ - path_table (11, 2), - sfdb_path_columns(), - sfdb_paths(ListStore::create(sfdb_path_columns)), - sfdb_path_view(sfdb_paths), - - /* Fades */ - - auto_xfade_button (_("Automatically create crossfades")), - xfade_active_button (_("New full-overlap crossfades are unmuted")), - layer_mode_label (_("Region layering mode")), - xfade_model_label (_("Crossfade model")), - short_xfade_adjustment (0, 1.0, 500.0, 5.0, 100.0), - short_xfade_slider (short_xfade_adjustment), - - /* Sync */ - - smpte_offset_clock (X_("SMPTEOffsetClock"), true, true), - smpte_offset_negative_button (_("SMPTE offset is negative")), - - /* MIDI */ - - /* 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; - - set_default_size (300, 300); - set_title (_("ardour: options editor")); - set_wmclass (_("ardour_option_editor"), "Ardour"); - - set_name ("OptionsWindow"); - add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK); - - layer_mode_label.set_name ("OptionsLabel"); - xfade_model_label.set_name ("OptionsLabel"); - - 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(); -} +using namespace ARDOUR; 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); - - smpte_fps_combo.set_sensitive (false); - layer_mode_combo.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); - smpte_fps_combo.set_sensitive (true); - layer_mode_combo.set_sensitive (true); - short_xfade_slider.set_sensitive (true); - smpte_offset_negative_button.set_sensitive (true); - - if (!s->smpte_drop_frames) { - // non-drop frames - if (s->smpte_frames_per_second == 24.0) - smpte_fps_combo.set_active_text (_("24 FPS")); - else if (s->smpte_frames_per_second == 25.0) - smpte_fps_combo.set_active_text (_("25 FPS")); - else if (s->smpte_frames_per_second == 30.0) - smpte_fps_combo.set_active_text (_("30 FPS")); - else - smpte_fps_combo.set_active_text (_("???")); - } else { - // drop frames - if (floor(s->smpte_frames_per_second) == 29.0) - smpte_fps_combo.set_active_text (_("30 FPS drop")); - else - smpte_fps_combo.set_active_text (_("???")); - } - - 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 >::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 (); - - layer_mode_combo.set_active_text (layer_mode_strings[session->get_layer_model()]); - xfade_model_combo.set_active_text (xfade_model_strings[session->get_xfade_model()]); - - short_xfade_adjustment.set_value ((Crossfade::short_xfade_length() / (float) session->frame_rate()) * 1000.0); - - add_session_paths (); -} - -OptionEditor::~OptionEditor () +OptionEditorComponent::add_widget_to_page (OptionEditorPage* p, Gtk::Widget* w) { + int const n = p->table.property_n_rows(); + p->table.resize (n + 1, 3); + p->table.attach (*w, 1, 3, n, n + 1, FILL | EXPAND); } -static const gchar *native_format_strings[] = { - N_("Broadcast WAVE/floating point"), - N_("WAVE/floating point"), - 0 -}; - void -OptionEditor::setup_path_options() +OptionEditorComponent::add_widgets_to_page (OptionEditorPage* p, Gtk::Widget* wa, Gtk::Widget* wb) { - 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); - - label = manage(new Label(_("Native Format"))); - label->set_name ("OptionsLabel"); - path_table.attach (*label, 0, 1, 1, 2, FILL|EXPAND, FILL); - path_table.attach (native_format_combo, 1, 3, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL); - - label = manage(new Label(_("Soundfile Search Paths"))); - label->set_name("OptionsLabel"); - path_table.attach(*label, 0, 1, 2, 3, FILL|EXPAND, FILL); - path_table.attach(sfdb_path_view, 1, 3, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL); - - sfdb_path_view.append_column(_("Paths"), sfdb_path_columns.paths); - sfdb_path_view.set_size_request(-1, 100); - - vector nfstrings = internationalize (native_format_strings); - - set_popdown_strings (native_format_combo, nfstrings); - native_format_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::native_format_chosen)); - - fixup_combo_size (native_format_combo, nfstrings); - - if (Config->get_native_format_is_bwf()) { - native_format_combo.set_active_text (native_format_strings[0]); - } else { - native_format_combo.set_active_text (native_format_strings[1]); - } - - path_table.show_all(); + int const n = p->table.property_n_rows(); + p->table.resize (n + 1, 3); + p->table.attach (*wa, 1, 2, n, n + 1, FILL); + p->table.attach (*wb, 2, 3, n, n + 1, FILL | EXPAND); } -void -OptionEditor::add_session_paths () +OptionEditorHeading::OptionEditorHeading (string const & h) { - click_path_entry.set_sensitive (true); - click_emphasis_path_entry.set_sensitive (true); - session_raid_entry.set_sensitive (true); - - if (session->click_sound.length() == 0) { - click_path_entry.set_text (_("internal")); - } else { - click_path_entry.set_text (session->click_sound); - } - - if (session->click_emphasis_sound.length() == 0) { - click_emphasis_path_entry.set_text (_("internal")); - } else { - click_emphasis_path_entry.set_text (session->click_emphasis_sound); - } - - session_raid_entry.set_text(session->raid_path()); + std::stringstream s; + s << "" << h << ""; + _label = manage (new Label (s.str())); + _label->set_alignment (0, 0.5); + _label->set_use_markup (true); } void -OptionEditor::setup_fade_options () +OptionEditorHeading::add_to_page (OptionEditorPage* p) { - Gtk::HBox* hbox; - vector dumb; - - auto_xfade_button.set_name ("OptionEditorToggleButton"); - xfade_active_button.set_name ("OptionEditorToggleButton"); - - hbox = manage (new HBox); - hbox->set_border_width (12); - hbox->pack_start (auto_xfade_button, false, false); - fade_packer.pack_start (*hbox, false, false); - - hbox = manage (new HBox); - hbox->set_border_width (12); - hbox->pack_start (xfade_active_button, false, false); - fade_packer.pack_start (*hbox, false, false); + int const n = p->table.property_n_rows(); + p->table.resize (n + 2, 3); - layer_mode_strings = internationalize (lmode_strings); - - dumb.push_back (lmode_strings[Session::LaterHigher]); - dumb.push_back (lmode_strings[Session::MoveAddHigher]); - dumb.push_back (lmode_strings[Session::AddHigher]); - set_popdown_strings (layer_mode_combo, dumb); - - layer_mode_combo.signal_changed ().connect (mem_fun(*this, &OptionEditor::layer_mode_chosen)); - - fixup_combo_size (layer_mode_combo, layer_mode_strings); - - hbox = manage (new HBox); - hbox->set_border_width (5); - hbox->set_spacing (10); - hbox->pack_start (layer_mode_label, false, false); - hbox->pack_start (layer_mode_combo, false, false); - fade_packer.pack_start (*hbox, false, false); - - xfade_model_strings = internationalize (xfl_strings); - - dumb.clear (); - dumb.push_back (xfade_model_strings[FullCrossfade]); - dumb.push_back (xfade_model_strings[ShortCrossfade]); - set_popdown_strings (xfade_model_combo, dumb); - - xfade_model_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::xfade_model_chosen)); - - fixup_combo_size (xfade_model_combo, xfade_model_strings); - - hbox = manage (new HBox); - hbox->set_border_width (5); - hbox->set_spacing (10); - hbox->pack_start (xfade_model_label, false, false); - hbox->pack_start (xfade_model_combo, false, false); - fade_packer.pack_start (*hbox, false, false); - - auto_xfade_button.set_active (Config->get_auto_xfade()); - /* xfade and layer mode active requires session */ - - auto_xfade_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::auto_xfade_clicked)); - xfade_active_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::xfade_active_clicked)); - - Label* short_xfade_label = manage (new Label (_("Short crossfade length (msecs)"))); - short_xfade_label->set_name ("OptionsLabel"); - - hbox = manage (new HBox); - hbox->set_border_width (5); - hbox->set_spacing (10); - hbox->pack_start (*short_xfade_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)); - - fade_packer.show_all (); + p->table.attach (*manage (new Label ("")), 0, 3, n, n + 1, FILL | EXPAND); + p->table.attach (*_label, 0, 3, n + 1, n + 2, FILL | EXPAND); } void -OptionEditor::short_xfade_adjustment_changed () +OptionEditorBox::add_to_page (OptionEditorPage* p) { - if (session) { - float val = short_xfade_adjustment.get_value(); - - /* val is in msecs */ - - Crossfade::set_short_xfade_length ((jack_nframes_t) floor (session->frame_rate() * (val / 1000.0))); - } + add_widget_to_page (p, _box); } -void -OptionEditor::layer_mode_chosen () +BoolOption::BoolOption (string const & i, string const & n, sigc::slot g, sigc::slot s) + : Option (i, n), + _get (g), + _set (s) { - if (!session) { - return; - } - - string which = layer_mode_combo.get_active_text (); - - if (which == layer_mode_strings[Session::LaterHigher]) { - session->set_layer_model (Session::LaterHigher); - } else if (which == layer_mode_strings[Session::MoveAddHigher]) { - session->set_layer_model (Session::MoveAddHigher); - } else if (which == layer_mode_strings[Session::AddHigher]) { - session->set_layer_model (Session::AddHigher); - } + _button = manage (new CheckButton (n)); + _button->set_active (_get ()); + _button->signal_toggled().connect (sigc::mem_fun (*this, &BoolOption::toggled)); } void -OptionEditor::xfade_model_chosen () +BoolOption::add_to_page (OptionEditorPage* p) { - if (!session) { - return; - } - - string which = xfade_model_combo.get_active_text (); - - if (which == xfade_model_strings[FullCrossfade]) { - session->set_xfade_model (FullCrossfade); - } else if (which == xfade_model_strings[ShortCrossfade]) { - session->set_xfade_model (ShortCrossfade); - } + add_widget_to_page (p, _button); } void -OptionEditor::auto_xfade_clicked () +BoolOption::set_state_from_config () { - Config->set_auto_xfade (auto_xfade_button.get_active()); + _button->set_active (_get ()); } void -OptionEditor::xfade_active_clicked () +BoolOption::toggled () { - if (session) { - session->set_crossfades_active (xfade_active_button.get_active()); - } + _set (_button->get_active ()); } -void -OptionEditor::setup_sync_options () +EntryOption::EntryOption (string const & i, string const & n, sigc::slot g, sigc::slot s) + : Option (i, n), + _get (g), + _set (s) { - HBox* hbox; - vector dumb; - - dumb.clear (); - dumb.push_back (X_("24 FPS")); - dumb.push_back (X_("25 FPS")); - dumb.push_back (X_("30 FPS drop")); - dumb.push_back (X_("30 FPS non-drop")); - - set_popdown_strings (smpte_fps_combo, dumb); - smpte_fps_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::smpte_fps_chosen)); - - 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_fps_label = manage (new Label (_("SMPTE Frames/second"))); - Label *smpte_offset_label = manage (new Label (_("SMPTE Offset"))); - smpte_fps_label->set_name("OptionsLabel"); - smpte_offset_label->set_name("OptionsLabel"); - - hbox = manage (new HBox); - hbox->set_border_width (5); - hbox->set_spacing (10); - hbox->pack_start (*smpte_fps_label, false, false); - hbox->pack_start (smpte_fps_combo, false, false); - - sync_packer.pack_start (*hbox, false, false); - - 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)); + _label = manage (new Label (n + ":")); + _label->set_alignment (0, 0.5); + _entry = manage (new Entry); + _entry->signal_activate().connect (sigc::mem_fun (*this, &EntryOption::activated)); } void -OptionEditor::smpte_offset_negative_clicked () +EntryOption::add_to_page (OptionEditorPage* p) { - if (session) { - session->set_smpte_offset_negative (smpte_offset_negative_button.get_active()); - } + add_widgets_to_page (p, _label, _entry); } void -OptionEditor::smpte_fps_chosen () +EntryOption::set_state_from_config () { - if (session) { - string str = smpte_fps_combo.get_active_text(); - - if (str == X_("24 FPS")) { - session->set_smpte_type (24.0, false); - } else if (str == X_("25 FPS")) { - session->set_smpte_type (25.0, false); - } else if (str == X_("30 FPS drop")) { - session->set_smpte_type (29.97, true); - } else if (str == X_("30 FPS non-drop")) { - session->set_smpte_type (30.0, false); - } - } + _entry->set_text (_get ()); } void -OptionEditor::smpte_offset_chosen() +EntryOption::activated () { - if (session) { - jack_nframes_t frames = smpte_offset_clock.current_duration(); - session->set_smpte_offset (frames); - } + _set (_entry->get_text ()); } - -void -OptionEditor::setup_midi_options () +FaderOption::FaderOption (string const & i, string const & n, sigc::slot g, sigc::slot s) + : Option (i, n) + , _db_adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0, 1, 0.01, 0.1) + , _get (g) + , _set (s) { - 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, 9)); - - table->set_row_spacings (6); - table->set_col_spacings (10); - - table->attach (*(manage (new Label (X_("Port")))), 0, 1, 0, 1); - table->attach (*(manage (new Label (X_("Offline")))), 1, 2, 0, 1); - table->attach (*(manage (new Label (X_("Trace\nInput")))), 2, 3, 0, 1); - table->attach (*(manage (new Label (X_("Trace\nOutput")))), 3, 4, 0, 1); - table->attach (*(manage (new Label (X_("MTC")))), 4, 5, 0, 1); - table->attach (*(manage (new Label (X_("MMC")))), 6, 7, 0, 1); - table->attach (*(manage (new Label (X_("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); - - for (n = 0, i = ports.begin(); i != ports.end(); ++n, ++i) { - - pair > 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_button_press_event().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_button_press_event().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_button_press_event().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_button_press_event().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_button_press_event().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_button_press_event().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); + _pix = ::get_icon (X_("fader_belt_h")); + if (_pix == 0) { + throw failed_constructor (); } - table->show_all (); + _db_slider = manage (new HSliderController (_pix, + &_db_adjustment, + 115, + false)); - hbox = manage (new HBox); - hbox->set_border_width (6); - hbox->pack_start (*table, true, false); - midi_packer.pack_start (*hbox, false, false); -} + _label.set_text (n + ":"); + _label.set_name (X_("OptionsLabel")); -bool -OptionEditor::mtc_port_chosen (GdkEventButton* ev, MIDI::Port *port, Gtk::RadioButton* rb) -{ - if (session) { - if (!rb->get_active()) { - if (port) { - session->set_mtc_port (port->name()); - Config->set_mtc_port_name (port->name()); - } else { - session->set_mtc_port (""); - } - rb->set_active (true); - } - } - - return false; -} + _box.set_spacing (4); + _box.pack_start (*_db_slider, false, false); + _box.pack_start (_db_display, false, false); + _box.show_all (); -bool -OptionEditor::mmc_port_chosen (GdkEventButton* ev, MIDI::Port* port, Gtk::RadioButton* rb) -{ - if (session) { - if (!rb->get_active()) { - if (port) { - session->set_mmc_port (port->name()); - Config->set_mtc_port_name (port->name()); - } else { - session->set_mmc_port (""); - } - rb->set_active (true); - } - } - return false; -} + set_size_request_to_display_given_text (_db_display, "-99.0", 12, 12); -bool -OptionEditor::midi_port_chosen (GdkEventButton* ev, MIDI::Port* port, Gtk::RadioButton* rb) -{ - if (session) { - if (!rb->get_active()) { - if (port) { - session->set_midi_port (port->name()); - Config->set_midi_port_name (port->name()); - } else { - session->set_midi_port (""); - } - rb->set_active (true); - } - } - return false; + _db_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &FaderOption::db_changed)); } -gint -OptionEditor::port_online_toggled (GdkEventButton* ev, MIDI::Port* port, ToggleButton* tb) +void +FaderOption::set_state_from_config () { - bool wanted = tb->get_active(); /* it hasn't changed at this point */ + gain_t const val = _get (); + _db_adjustment.set_value (gain_to_slider_position_with_max (val, Config->get_max_gain ())); - if (wanted != port->input()->offline()) { - port->input()->set_offline (wanted); - } - return stop_signal (*tb, "button_press_event"); -} + char buf[16]; -void -OptionEditor::map_port_online (MIDI::Port* port, ToggleButton* tb) -{ - if (port->input()->offline()) { - static_cast(tb->get_child())->set_text (_("offline")); - tb->set_active (false); + if (val == 0.0) { + snprintf (buf, sizeof (buf), "-inf"); } else { - static_cast(tb->get_child())->set_text (_("online")); - tb->set_active (true); + snprintf (buf, sizeof (buf), "%.2f", accurate_coefficient_to_dB (val)); } -} - -gint -OptionEditor::port_trace_in_toggled (GdkEventButton* ev, MIDI::Port* port, ToggleButton* tb) -{ - /* XXX not very good MVC style here */ - - port->input()->trace (!tb->get_active(), &cerr, string (port->name()) + string (" input: ")); - tb->set_active (!tb->get_active()); - return stop_signal (*tb, "button_press_event"); -} - -gint -OptionEditor::port_trace_out_toggled (GdkEventButton* ev,MIDI::Port* port, ToggleButton* tb) -{ - /* XXX not very good MVC style here */ - port->output()->trace (!tb->get_active(), &cerr, string (port->name()) + string (" output: ")); - tb->set_active (!tb->get_active()); - return stop_signal (*tb, "button_press_event"); + _db_display.set_text (buf); } void -OptionEditor::save () -{ - /* XXX a bit odd that we save the entire session state here */ - - ui.save_state (""); -} - -gint -OptionEditor::wm_close (GdkEventAny *ev) +FaderOption::db_changed () { - save (); - hide (); - return TRUE; + _set (slider_position_to_gain_with_max (_db_adjustment.get_value (), Config->get_max_gain())); } void -OptionEditor::raid_path_changed () +FaderOption::add_to_page (OptionEditorPage* p) { - if (session) { - session->set_raid_path (session_raid_entry.get_text()); - } + add_widgets_to_page (p, &_label, &_box); } -void -OptionEditor::click_browse_clicked () +ClockOption::ClockOption (string const & i, string const & n, sigc::slot g, sigc::slot s) + : Option (i, n) + , _clock (X_("timecode-offset"), false, X_(""), true, false, true, false) + , _get (g) + , _set (s) { - SoundFileChooser sfdb (_("Choose Click")); - - int result = sfdb.run (); - - if (result == Gtk::RESPONSE_OK) { - click_chosen(sfdb.get_filename()); - } + _label.set_text (n + ":"); + _label.set_alignment (0, 0.5); + _label.set_name (X_("OptionsLabel")); } void -OptionEditor::click_chosen (const string & path) +ClockOption::set_state_from_config () { - click_path_entry.set_text (path); - click_sound_changed (); + _clock.set (_get ()); } void -OptionEditor::click_emphasis_browse_clicked () +ClockOption::add_to_page (OptionEditorPage* p) { - SoundFileChooser sfdb (_("Choose Click Emphasis")); - - int result = sfdb.run (); - - if (result == Gtk::RESPONSE_OK) { - click_emphasis_chosen (sfdb.get_filename()); - } -} - -void -OptionEditor::click_emphasis_chosen (const string & path) -{ - click_emphasis_path_entry.set_text (path); - click_emphasis_sound_changed (); + add_widgets_to_page (p, &_label, &_clock); } void -OptionEditor::click_sound_changed () +ClockOption::set_session (Session* s) { - if (session) { - string path = click_path_entry.get_text(); - - if (path == session->click_sound) { - return; - } - - if (path.length() == 0) { - - session->set_click_sound (""); - - } else { - - strip_whitespace_edges (path); - - if (path == _("internal")) { - session->set_click_sound (""); - } else { - session->set_click_sound (path); - } - } - } + _clock.set_session (s); } -void -OptionEditor::click_emphasis_sound_changed () +OptionEditorPage::OptionEditorPage (Gtk::Notebook& n, std::string const & t) + : table (1, 3) { - if (session) { - string path = click_emphasis_path_entry.get_text(); - - if (path == session->click_emphasis_sound) { - return; - } - - if (path.length() == 0) { - - session->set_click_emphasis_sound (""); - - } else { - - strip_whitespace_edges (path); - - if (path == _("internal")) { - session->set_click_emphasis_sound (""); - } else { - session->set_click_emphasis_sound (path); - } - } - } + table.set_spacings (4); + table.set_col_spacing (0, 32); + box.pack_start (table, false, false); + box.set_border_width (4); + n.append_page (box, t); } -void -OptionEditor::native_format_chosen () +/** Construct an OptionEditor. + * @param o Configuration to edit. + * @param t Title for the dialog. + */ +OptionEditor::OptionEditor (Configuration* c, std::string const & t) + : ArdourWindow (t), _config (c) { - string which; - - if (session == 0) { - return; - } - - bool use_bwf = (native_format_combo.get_active_text() == native_format_strings[0]); - - if (use_bwf != Config->get_native_format_is_bwf()) { - Config->set_native_format_is_bwf (use_bwf); - session->reset_native_file_format (); - } -} - -void -OptionEditor::clear_click_editor () -{ - if (click_io_selector) { - click_packer.remove (*click_io_selector); - click_packer.remove (*click_gpm); - delete click_io_selector; - delete click_gpm; - click_io_selector = 0; - click_gpm = 0; - } -} - -void -OptionEditor::setup_click_editor () -{ - Label* label; - HBox* hpacker = manage (new HBox); - - click_path_entry.set_sensitive (true); - click_emphasis_path_entry.set_sensitive (true); - - click_path_entry.set_name ("OptionsEntry"); - click_emphasis_path_entry.set_name ("OptionsEntry"); - - click_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_sound_changed)); - click_emphasis_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_emphasis_sound_changed)); - - click_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_sound_changed)); - click_emphasis_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_emphasis_sound_changed)); + using namespace Notebook_Helpers; - click_browse_button.set_name ("EditorGTKButton"); - click_emphasis_browse_button.set_name ("EditorGTKButton"); - click_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_browse_clicked)); - click_emphasis_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_emphasis_browse_clicked)); + set_default_size (300, 300); + set_wmclass (X_("ardour_preferences"), PROGRAM_NAME); - click_packer.set_border_width (12); - click_packer.set_spacing (5); + set_name ("Preferences"); + add_events (Gdk::KEY_PRESS_MASK | Gdk::KEY_RELEASE_MASK); - click_io_selector = new IOSelector (*session, session->click_io(), false); - click_gpm = new GainMeter (session->click_io(), *session); + set_border_width (4); - click_table.set_col_spacings (10); - - label = manage(new Label(_("Click audio file"))); - label->set_name ("OptionsLabel"); - click_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL); - click_table.attach (click_path_entry, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL); - click_table.attach (click_browse_button, 2, 3, 0, 1, FILL|EXPAND, FILL); - - label = manage(new Label(_("Click emphasis audiofile"))); - label->set_name ("OptionsLabel"); - click_table.attach (*label, 0, 1, 1, 2, FILL|EXPAND, FILL); - click_table.attach (click_emphasis_path_entry, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL); - click_table.attach (click_emphasis_browse_button, 2, 3, 1, 2, FILL|EXPAND, FILL); + add (_notebook); - hpacker->set_spacing (10); - hpacker->pack_start (*click_io_selector, false, false); - hpacker->pack_start (*click_gpm, false, false); + _notebook.set_show_tabs (true); + _notebook.set_show_border (true); + _notebook.set_name ("OptionsNotebook"); - click_packer.pack_start (click_table, false, false); - click_packer.pack_start (*hpacker, false, false); + show_all_children(); - click_packer.show_all (); + /* Watch out for changes to parameters */ + _config->ParameterChanged.connect (config_connection, invalidator (*this), ui_bind (&OptionEditor::parameter_changed, this, _1), gui_context()); } -void -OptionEditor::clear_auditioner_editor () +OptionEditor::~OptionEditor () { - if (auditioner_io_selector) { - audition_hpacker.remove (*auditioner_io_selector); - audition_hpacker.remove (*auditioner_gpm); - delete auditioner_io_selector; - delete auditioner_gpm; - auditioner_io_selector = 0; - auditioner_gpm = 0; + for (std::map::iterator i = _pages.begin(); i != _pages.end(); ++i) { + for (std::list::iterator j = i->second->components.begin(); j != i->second->components.end(); ++j) { + delete *j; + } + delete i->second; } } +/** Called when a configuration parameter has been changed. + * @param p Parameter name. + */ void -OptionEditor::setup_auditioner_editor () +OptionEditor::parameter_changed (std::string const & p) { - audition_packer.set_border_width (12); - audition_packer.set_spacing (5); - audition_hpacker.set_spacing (10); + ENSURE_GUI_THREAD (*this, &OptionEditor::parameter_changed, p) - audition_label.set_name ("OptionEditorAuditionerLabel"); - audition_label.set_text (_("The auditioner is a dedicated mixer strip used\n" - "for listening to specific regions outside the context\n" - "of the overall mix. It can be connected just like any\n" - "other mixer strip.")); - - audition_packer.pack_start (audition_label, false, false, 10); - audition_packer.pack_start (audition_hpacker, false, false); + for (std::map::iterator i = _pages.begin(); i != _pages.end(); ++i) { + for (std::list::iterator j = i->second->components.begin(); j != i->second->components.end(); ++j) { + (*j)->parameter_changed (p); + } + } } +/** Add a component to a given page. + * @param pn Page name (will be created if it doesn't already exist) + * @param o Component. + */ void -OptionEditor::connect_audition_editor () +OptionEditor::add_option (std::string const & pn, OptionEditorComponent* o) { - auditioner_io_selector = new IOSelector (*session, session->the_auditioner(), false); - auditioner_gpm = new GainMeter (session->the_auditioner(), *session); + if (_pages.find (pn) == _pages.end()) { + _pages[pn] = new OptionEditorPage (_notebook, pn); + } - audition_hpacker.pack_start (*auditioner_io_selector, false, false); - audition_hpacker.pack_start (*auditioner_gpm, false, false); + OptionEditorPage* p = _pages[pn]; + p->components.push_back (o); - auditioner_io_selector->show_all (); - auditioner_gpm->show_all (); + o->add_to_page (p); + o->set_state_from_config (); } -bool -OptionEditor::focus_out_event_handler (GdkEventFocus* ev, void (OptionEditor::*pmf)()) -{ - (this->*pmf)(); - return false; -} - -static const struct { - const char *name; - guint modifier; -} modifiers[] = { - { "Shift", GDK_SHIFT_MASK }, - { "Control", GDK_CONTROL_MASK }, - { "Alt (Mod1)", GDK_MOD1_MASK }, - { "Control-Shift", GDK_CONTROL_MASK|GDK_SHIFT_MASK }, - { "Control-Alt", GDK_CONTROL_MASK|GDK_MOD1_MASK }, - { "Shift-Alt", GDK_SHIFT_MASK|GDK_MOD1_MASK }, - { "Control-Shift-Alt", GDK_CONTROL_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK }, - { "Mod2", GDK_MOD2_MASK }, - { "Mod3", GDK_MOD3_MASK }, - { "Mod4", GDK_MOD4_MASK }, - { "Mod5", GDK_MOD5_MASK }, - { 0, 0 } -}; - void -OptionEditor::setup_keyboard_options () +OptionEditor::set_current_page (string const & p) { - vector dumb; - Label* label; - - keyboard_mouse_table.set_border_width (12); - keyboard_mouse_table.set_row_spacings (5); - keyboard_mouse_table.set_col_spacings (5); - - /* internationalize and prepare for use with combos */ - - for (int i = 0; modifiers[i].name; ++i) { - dumb.push_back (_(modifiers[i].name)); - } - - set_popdown_strings (edit_modifier_combo, dumb); - edit_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::edit_modifier_chosen)); - - for (int x = 0; modifiers[x].name; ++x) { - if (modifiers[x].modifier == Keyboard::edit_modifier ()) { - edit_modifier_combo.set_active_text (_(modifiers[x].name)); - break; - } - } - - label = manage (new Label (_("Edit using"))); - label->set_name ("OptionsLabel"); - label->set_alignment (1.0, 0.5); - - keyboard_mouse_table.attach (*label, 0, 1, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL); - keyboard_mouse_table.attach (edit_modifier_combo, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL); - - label = manage (new Label (_("+ button"))); - label->set_name ("OptionsLabel"); - - keyboard_mouse_table.attach (*label, 3, 4, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL); - keyboard_mouse_table.attach (edit_button_spin, 4, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL); - - edit_button_spin.set_name ("OptionsEntry"); - edit_button_adjustment.set_value (Keyboard::edit_button()); - edit_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::edit_button_changed)); - - set_popdown_strings (delete_modifier_combo, dumb); - delete_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::delete_modifier_chosen)); - - for (int x = 0; modifiers[x].name; ++x) { - if (modifiers[x].modifier == Keyboard::delete_modifier ()) { - delete_modifier_combo.set_active_text (_(modifiers[x].name)); - break; + int i = 0; + while (i < _notebook.get_n_pages ()) { + if (_notebook.get_tab_label_text (*_notebook.get_nth_page (i)) == p) { + _notebook.set_current_page (i); + return; } - } - - label = manage (new Label (_("Delete using"))); - label->set_name ("OptionsLabel"); - label->set_alignment (1.0, 0.5); - - keyboard_mouse_table.attach (*label, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL); - keyboard_mouse_table.attach (delete_modifier_combo, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL); - label = manage (new Label (_("+ button"))); - label->set_name ("OptionsLabel"); - - keyboard_mouse_table.attach (*label, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL); - keyboard_mouse_table.attach (delete_button_spin, 4, 5, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL); - - delete_button_spin.set_name ("OptionsEntry"); - delete_button_adjustment.set_value (Keyboard::delete_button()); - delete_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::delete_button_changed)); - - set_popdown_strings (snap_modifier_combo, dumb); - snap_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::snap_modifier_chosen)); - - for (int x = 0; modifiers[x].name; ++x) { - if (modifiers[x].modifier == (guint) Keyboard::snap_modifier ()) { - snap_modifier_combo.set_active_text (_(modifiers[x].name)); - break; - } + ++i; } - - label = manage (new Label (_("Ignore snap using"))); - label->set_name ("OptionsLabel"); - label->set_alignment (1.0, 0.5); - - keyboard_mouse_table.attach (*label, 0, 1, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL); - keyboard_mouse_table.attach (snap_modifier_combo, 1, 2, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL); } -void -OptionEditor::edit_modifier_chosen () -{ - string txt; - - txt = edit_modifier_combo.get_active_text(); - for (int i = 0; modifiers[i].name; ++i) { - if (txt == _(modifiers[i].name)) { - Keyboard::set_edit_modifier (modifiers[i].modifier); - break; - } - } -} - -void -OptionEditor::delete_modifier_chosen () +DirectoryOption::DirectoryOption (string const & i, string const & n, sigc::slot g, sigc::slot s) + : Option (i, n) + , _get (g) + , _set (s) { - string txt; - - txt = delete_modifier_combo.get_active_text(); - - for (int i = 0; modifiers[i].name; ++i) { - if (txt == _(modifiers[i].name)) { - Keyboard::set_delete_modifier (modifiers[i].modifier); - break; - } - } + _file_chooser.set_action (Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER); + _file_chooser.signal_file_set().connect (sigc::mem_fun (*this, &DirectoryOption::file_set)); + _file_chooser.signal_current_folder_changed().connect (sigc::mem_fun (*this, &DirectoryOption::current_folder_set)); } + void -OptionEditor::snap_modifier_chosen () +DirectoryOption::set_state_from_config () { - string txt; - - txt = snap_modifier_combo.get_active_text(); - - for (int i = 0; modifiers[i].name; ++i) { - if (txt == _(modifiers[i].name)) { - Keyboard::set_snap_modifier (modifiers[i].modifier); - break; - } - } + _file_chooser.set_current_folder (_get ()); } void -OptionEditor::delete_button_changed () +DirectoryOption::add_to_page (OptionEditorPage* p) { - Keyboard::set_delete_button ((guint) delete_button_adjustment.get_value()); + add_widgets_to_page (p, manage (new Label (_name)), &_file_chooser); } void -OptionEditor::edit_button_changed () +DirectoryOption::file_set () { - Keyboard::set_edit_button ((guint) edit_button_adjustment.get_value()); + _set (_file_chooser.get_filename ()); } void -OptionEditor::fixup_combo_size (Gtk::ComboBoxText& combo, vector& strings) +DirectoryOption::current_folder_set () { - /* find the widest string */ - - string::size_type maxlen = 0; - string maxstring; - - for (vector::iterator i = strings.begin(); i != strings.end(); ++i) { - string::size_type l; - - if ((l = (*i).length()) > maxlen) { - maxlen = l; - maxstring = *i; - } - } - - /* try to include ascenders and descenders */ - - if (maxstring.length() > 2) { - maxstring[0] = 'g'; - maxstring[1] = 'l'; - } - - const guint32 FUDGE = 10; // Combo's are stupid - they steal space from the entry for the button - - set_size_request_to_display_given_text (combo, maxstring.c_str(), 10 + FUDGE, 10); + _set (_file_chooser.get_current_folder ()); } -