/*
- 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
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+ 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id$
*/
+#include <algorithm>
-#include <ardour/session.h>
-#include <ardour/audioengine.h>
-#include <ardour/configuration.h>
-#include <ardour/auditioner.h>
-#include <ardour/crossfade.h>
-#include <midi++/manager.h>
-#include <gtkmm2ext/stop_signal.h>
-#include <gtkmm2ext/utils.h>
+#include <gtkmm/box.h>
+#include <gtkmm/alignment.h>
+#include "gtkmm2ext/utils.h"
+#include "ardour/dB.h"
+#include "ardour/rc_configuration.h"
+#include "ardour/session.h"
+#include "ardour/types.h"
+#include "ardour/utils.h"
+
+#include "pbd/configuration.h"
+#include "pbd/replace_all.h"
+#include "pbd/strsplit.h"
+
+#include "gui_thread.h"
+#include "option_editor.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 "i18n.h"
+#include "pbd/i18n.h"
-using namespace ARDOUR;
+using namespace std;
using namespace Gtk;
-using namespace Editing;
using namespace Gtkmm2ext;
-using namespace std;
-
-static const gchar *psync_strings[] = {
- N_("Internal"),
- N_("Slave to MTC"),
- N_("Sync with JACK"),
- N_("never used but stops crashes"),
- 0
-};
-
-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<string> positional_sync_strings;
-static vector<string> layer_mode_strings;
-static vector<string> xfade_model_strings;
-
-OptionEditor::OptionEditor (ARDOUR_UI& uip, PublicEditor& ed, Mixer_UI& mixui)
- : ArdourDialog ("option editor"),
- ui (uip),
- editor (ed),
- mixer (mixui),
-
- path_table (9, 2),
-
- /* 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),
-
- /* solo */
- solo_latched_button (_("Latched solo")),
- solo_via_bus_button (_("Solo via bus")),
-
- /* display */
-
- show_waveforms_button (_("Show waveforms")),
- show_waveforms_recording_button (_("Show waveforms while recording")),
- mixer_strip_width_button (_("Narrow mixer strips")),
- show_measures_button (_("Show measure lines")),
- follow_playhead_button (_("Follow playhead")),
-
- /* Sync */
-
- send_mtc_button (_("Send MTC")),
- send_mmc_button (_("Send MMC")),
- jack_time_master_button (_("JACK time master")),
- smpte_offset_clock (X_("SMPTEOffsetClock"), true, true),
- smpte_offset_negative_button (_("SMPTE offset is negative")),
-
- /* MIDI */
-
- midi_feedback_button (_("Send MIDI parameter feedback")),
- midi_control_button (_("MIDI parameter control")),
- mmc_control_button (_("MMC control")),
-
- /* 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),
-
- /* Misc */
-
- auto_connect_inputs_button (_("Auto-connect new track inputs to hardware")),
- auto_connect_output_physical_button (_("Auto-connect new track outputs to hardware")),
- auto_connect_output_master_button (_("Auto-connect new track outputs to master bus")),
- auto_connect_output_manual_button (_("Manually connect new track outputs")),
- hw_monitor_button(_("Use Hardware Monitoring")),
- sw_monitor_button(_("Use Software Monitoring")),
- plugins_stop_button (_("Stop plugins with transport")),
- plugins_on_rec_button (_("Run plugins while recording")),
- verify_remove_last_capture_button (_("Verify remove last capture")),
- stop_rec_on_xrun_button (_("Stop recording on xrun")),
- stop_at_end_button (_("Stop transport at end of session")),
- debug_keyboard_button (_("Debug keyboard events")),
- speed_quieten_button (_("-12dB gain reduction for ffwd/rew"))
-
-{
- 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 = manage(new VBox);
- add (*vbox);
- set_border_width (3);
-
- vbox->set_spacing (4);
- vbox->pack_start(notebook);
-
- 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_solo_options ();
- setup_display_options ();
- setup_misc_options ();
- setup_keyboard_options ();
- setup_auditioner_editor ();
-
- notebook.pages().push_back (TabElem (misc_packer, _("Misc")));
- notebook.pages().push_back (TabElem (sync_packer, _("Sync")));
- notebook.pages().push_back (TabElem (path_table, _("Paths/Files")));
- notebook.pages().push_back (TabElem (display_packer, _("Display")));
- 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")));
- notebook.pages().push_back (TabElem (solo_packer, _("Solo")));
-
- if (!MIDI::Manager::instance()->get_midi_ports().empty()) {
- setup_midi_options ();
- notebook.pages().push_back (TabElem (midi_packer, _("MIDI")));
- }
-
- set_session (0);
-}
+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 ("");
-
- send_mtc_button.set_sensitive (false);
- send_mmc_button.set_sensitive (false);
- midi_feedback_button.set_sensitive (false);
- midi_control_button.set_sensitive (false);
- mmc_control_button.set_sensitive (false);
- click_path_entry.set_sensitive (false);
- click_emphasis_path_entry.set_sensitive (false);
- session_raid_entry.set_sensitive (false);
- plugins_on_rec_button.set_sensitive (false);
- verify_remove_last_capture_button.set_sensitive (false);
- slave_type_combo.set_sensitive (false);
- solo_latched_button.set_sensitive (false);
- solo_via_bus_button.set_sensitive (false);
- smpte_fps_combo.set_sensitive (false);
- meter_hold_combo.set_sensitive (false);
- meter_falloff_combo.set_sensitive (false);
- auto_connect_inputs_button.set_sensitive (false);
- auto_connect_output_physical_button.set_sensitive (false);
- auto_connect_output_master_button.set_sensitive (false);
- auto_connect_output_manual_button.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;
- }
-
- send_mtc_button.set_sensitive (true);
- send_mmc_button.set_sensitive (true);
- midi_feedback_button.set_sensitive (true);
- midi_control_button.set_sensitive (true);
- mmc_control_button.set_sensitive (true);
- click_path_entry.set_sensitive (true);
- click_emphasis_path_entry.set_sensitive (true);
- session_raid_entry.set_sensitive (true);
- plugins_on_rec_button.set_sensitive (true);
- verify_remove_last_capture_button.set_sensitive (true);
- slave_type_combo.set_sensitive (true);
- solo_latched_button.set_sensitive (true);
- solo_via_bus_button.set_sensitive (true);
- smpte_fps_combo.set_sensitive (true);
- meter_hold_combo.set_sensitive (true);
- meter_falloff_combo.set_sensitive (true);
- auto_connect_inputs_button.set_sensitive (true);
- auto_connect_output_physical_button.set_sensitive (true);
- auto_connect_output_master_button.set_sensitive (true);
- auto_connect_output_manual_button.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.get_entry ()->set_text (_("24 FPS"));
- else if (s->smpte_frames_per_second == 25.0)
- smpte_fps_combo.get_entry ()->set_text (_("25 FPS"));
- else if (s->smpte_frames_per_second == 30.0)
- smpte_fps_combo.get_entry ()->set_text (_("30 FPS"));
- else
- smpte_fps_combo.get_entry ()->set_text (_("???"));
- } else {
- // drop frames
- if (floor(s->smpte_frames_per_second) == 29.0)
- smpte_fps_combo.get_entry ()->set_text (_("30 FPS drop"));
- else
- smpte_fps_combo.get_entry ()->set_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());
- send_mtc_button.set_active (session->get_send_mtc());
-
- /* MIDI I/O */
-
- send_mmc_button.set_active (session->get_send_mmc());
- midi_control_button.set_active (session->get_midi_control());
- midi_feedback_button.set_active (session->get_midi_feedback());
- mmc_control_button.set_active (session->get_mmc_control());
-
- /* set up port assignments */
-
- 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);
- }
- }
-
- auto_connect_inputs_button.set_active (session->get_input_auto_connect());
-
- Session::AutoConnectOption oac = session->get_output_auto_connect();
- if (oac & Session::AutoConnectPhysical) {
- auto_connect_output_physical_button.set_active (true);
- } else if (oac & Session::AutoConnectMaster) {
- auto_connect_output_master_button.set_active (true);
- } else {
- auto_connect_output_manual_button.set_active (true);
- }
-
- setup_click_editor ();
- connect_audition_editor ();
-
- plugins_on_rec_button.set_active (session->get_recording_plugins ());
- verify_remove_last_capture_button.set_active (Config->get_verify_remove_last_capture());
-
- layer_mode_combo.get_entry()->set_text (layer_mode_strings[session->get_layer_model()]);
- xfade_model_combo.get_entry()->set_text (xfade_model_strings[session->get_xfade_model()]);
-
- short_xfade_adjustment.set_value ((Crossfade::short_xfade_length() / (float) session->frame_rate()) * 1000.0);
-
- xfade_active_button.set_active (session->get_crossfades_active());
- solo_latched_button.set_active (session->solo_latched());
- solo_via_bus_button.set_active (session->solo_model() == Session::SoloBus);
-
- add_session_paths ();
-
- vector<string> dumb;
- dumb.push_back (positional_sync_strings[Session::None]);
- dumb.push_back (positional_sync_strings[Session::JACK]);
- if (session->mtc_port()) {
- dumb.push_back (positional_sync_strings[Session::MTC]);
- }
- set_popdown_strings (slave_type_combo, dumb);
-
- // meter stuff
- if (session->meter_falloff() == 0.0f) {
- meter_falloff_combo.get_entry ()->set_text (_("Off"));
- } else if (session->meter_falloff() <= 0.3f) {
- meter_falloff_combo.get_entry ()->set_text (_("Slowest"));
- } else if (session->meter_falloff() <= 0.4f) {
- meter_falloff_combo.get_entry ()->set_text (_("Slow"));
- } else if (session->meter_falloff() <= 0.8f) {
- meter_falloff_combo.get_entry ()->set_text (_("Medium"));
- } else if (session->meter_falloff() <= 1.4f) {
- meter_falloff_combo.get_entry ()->set_text (_("Fast"));
- } else if (session->meter_falloff() <= 2.0f) {
- meter_falloff_combo.get_entry ()->set_text (_("Faster"));
- } else {
- meter_falloff_combo.get_entry ()->set_text (_("Fastest"));
+OptionEditorComponent::add_widget_to_page (OptionEditorPage* p, Gtk::Widget* w)
+{
+ int const n = p->table.property_n_rows();
+ int m = n + 1;
+ if (!_note.empty ()) {
+ ++m;
}
- switch ((int) floor (session->meter_hold())) {
- case 0:
- meter_hold_combo.get_entry ()->set_text (_("Off"));
- break;
- case 40:
- meter_hold_combo.get_entry ()->set_text (_("Short"));
- break;
- case 100:
- meter_hold_combo.get_entry ()->set_text (_("Medium"));
- break;
- case 200:
- meter_hold_combo.get_entry ()->set_text (_("Long"));
- break;
- }
-
- session_control_changed (Session::SlaveType);
- session_control_changed (Session::AlignChoice);
- session->ControlChanged.connect (mem_fun(*this, &OptionEditor::queue_session_control_changed));
-}
+ p->table.resize (m, 3);
+ p->table.attach (*w, 1, 3, n, n + 1, FILL | EXPAND);
-OptionEditor::~OptionEditor ()
-{
+ maybe_add_note (p, n + 1);
}
-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, bool expand)
{
- Gtk::Label* label;
-
- path_table.set_homogeneous (true);
- path_table.set_border_width (12);
- path_table.set_row_spacings (5);
-
- session_raid_entry.set_name ("OptionsEntry");
-
- session_raid_entry.activate.connect (mem_fun(*this, &OptionEditor::raid_path_changed));
-
- session_raid_entry.signal_focus_in_event()().connect (mem_fun (Keyboard::the_keyboard(), &Keyboard::focus_in_handler));
- session_raid_entry.signal_focus_out_event()().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::raid_path_changed));
-
- label = manage(new Label(_("session RAID path")));
- label->set_name ("OptionsLabel");
- path_table.attach (*label, 0, 1, 0, 1, 0, 0);
- path_table.attach (session_raid_entry, 1, 3, 0, 1, Gtk::FILL|Gtk::EXPAND, 0);
-
- label = manage(new Label(_("Native Format")));
- label->set_name ("OptionsLabel");
- path_table.attach (*label, 0, 1, 1, 2, 0, 0);
- path_table.attach (native_format_combo, 1, 3, 1, 2, Gtk::FILL|Gtk::EXPAND, 0);
-
- vector<string> nfstrings = internationalize (native_format_strings);
-
- set_popdown_strings (native_format_combo, nfstrings);
- native_format_combo.get_popwin()->signal_unmap_event().connect (mem_fun(*this, &OptionEditor::native_format_chosen));
-
- fixup_combo_size (native_format_combo, nfstrings);
+ int const n = p->table.property_n_rows();
+ int m = n + 1;
+ if (!_note.empty ()) {
+ ++m;
+ }
- if (Config->get_native_format_is_bwf()) {
- native_format_combo.get_entry()->set_text (native_format_strings[0]);
+ p->table.resize (m, 3);
+ p->table.attach (*wa, 1, 2, n, n + 1, FILL);
+ if (expand) {
+ p->table.attach (*wb, 2, 3, n, n + 1, FILL | EXPAND);
} else {
- native_format_combo.get_entry()->set_text (native_format_strings[1]);
+ Alignment* a = manage (new Alignment (0, 0.5, 0, 1.0));
+ a->add (*wb);
+ p->table.attach (*a, 2, 3, n, n + 1, FILL | EXPAND);
}
-
- path_table.show_all();
+ maybe_add_note (p, n + 1);
}
void
-OptionEditor::add_session_paths ()
+OptionEditorComponent::maybe_add_note (OptionEditorPage* p, int n)
{
- 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);
+ if (!_note.empty ()) {
+ Gtk::Label* l = manage (left_aligned_label (string_compose (X_("<i>%1</i>"), _note)));
+ l->set_use_markup (true);
+ l->set_line_wrap (true);
+ p->table.attach (*l, 1, 3, n, n + 1, FILL | EXPAND);
}
-
- session_raid_entry.set_text(session->raid_path());
}
void
-OptionEditor::setup_fade_options ()
+OptionEditorComponent::set_note (string const & n)
{
- Gtk::HBox* hbox;
- vector<string> 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);
-
- 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.get_popwin()->signal_unmap_event().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.get_popwin()->signal_unmap_event().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.value_changed.connect (mem_fun(*this, &OptionEditor::short_xfade_adjustment_changed));
-
- fade_packer.show_all ();
+ _note = n;
}
-void
-OptionEditor::short_xfade_adjustment_changed ()
-{
- 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)));
- }
-}
+/*--------------------------*/
-gint
-OptionEditor::layer_mode_chosen (GdkEventAny* ev)
+OptionEditorHeading::OptionEditorHeading (string const & h)
{
- if (!session) {
- return FALSE;
- }
-
- string which = layer_mode_combo.get_entry()->get_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);
- }
- return FALSE;
+ std::stringstream s;
+ s << "<b>" << h << "</b>";
+ _label = manage (left_aligned_label (s.str()));
+ _label->set_use_markup (true);
}
-gint
-OptionEditor::xfade_model_chosen (GdkEventAny* ev)
+/*--------------------------*/
+
+void
+OptionEditorHeading::add_to_page (OptionEditorPage* p)
{
- if (!session) {
- return FALSE;
+ int const n = p->table.property_n_rows();
+ if (!_note.empty ()) {
+ p->table.resize (n + 3, 3);
+ } else {
+ p->table.resize (n + 2, 3);
}
- string which = xfade_model_combo.get_entry()->get_text ();
-
- if (which == xfade_model_strings[FullCrossfade]) {
- session->set_xfade_model (FullCrossfade);
- } else if (which == xfade_model_strings[ShortCrossfade]) {
- session->set_xfade_model (ShortCrossfade);
- }
- return FALSE;
+ 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);
+ maybe_add_note (p, n + 2);
}
-void
-OptionEditor::auto_xfade_clicked ()
-{
- Config->set_auto_xfade (auto_xfade_button.get_active());
-}
+/*--------------------------*/
void
-OptionEditor::xfade_active_clicked ()
+OptionEditorBlank::add_to_page (OptionEditorPage* p)
{
- if (session) {
- session->set_crossfades_active (xfade_active_button.get_active());
- }
+ int const n = p->table.property_n_rows();
+ p->table.resize (n + 1, 3);
+ p->table.attach (_dummy, 2, 3, n, n + 1, FILL | EXPAND, SHRINK, 0, 0);
+ _dummy.set_size_request (-1, 1);
+ _dummy.show ();
}
-void
-OptionEditor::setup_solo_options ()
-{
- Gtk::HBox* hbox;
-
- solo_via_bus_button.set_name ("OptionEditorToggleButton");
- solo_latched_button.set_name ("OptionEditorToggleButton");
+/*--------------------------*/
- hbox = manage (new HBox);
- hbox->set_border_width (12);
- hbox->pack_start (solo_via_bus_button, false, false);
- solo_packer.pack_start (*hbox, false, false);
-
- hbox = manage (new HBox);
- hbox->set_border_width (12);
- hbox->pack_start (solo_latched_button, false, false);
- solo_packer.pack_start (*hbox, false, false);
-
- solo_via_bus_button.signal_clicked().connect
- (mem_fun(*this, &OptionEditor::solo_via_bus_clicked));
- solo_latched_button.signal_clicked().connect
- (mem_fun(*this, &OptionEditor::solo_latched_clicked));
-
- solo_packer.show_all ();
+RcConfigDisplay::RcConfigDisplay (string const & i, string const & n, sigc::slot<string> g, char s)
+ : _get (g)
+ , _id (i)
+ , _sep (s)
+{
+ _label = manage (right_aligned_label (n));
+ _info = manage (new Label);
+ _info-> set_line_wrap (true);
+ set_state_from_config ();
}
void
-OptionEditor::solo_via_bus_clicked ()
+RcConfigDisplay::set_state_from_config ()
{
- if (!session) {
- return;
- }
-
- if (solo_via_bus_button.get_active()) {
- session->set_solo_model (Session::SoloBus);
- } else {
- session->set_solo_model (Session::InverseMute);
+ string p = _get();
+ if (_sep) {
+ std::replace (p.begin(), p.end(), _sep, '\n');
}
+ _info->set_text (p);
}
void
-OptionEditor::solo_latched_clicked ()
+RcConfigDisplay::parameter_changed (std::string const & p)
{
- if (!session) {
- return;
- }
-
- bool x = solo_latched_button.get_active();
-
- if (x != session->solo_latched()) {
- session->set_solo_latched (x);
+ if (p == _id) {
+ set_state_from_config ();
}
}
void
-OptionEditor::setup_display_options ()
-{
- HBox* hbox;
- vector<string> dumb;
-
- display_packer.set_border_width (12);
- display_packer.set_spacing (5);
-
- show_waveforms_button.set_name ("OptionEditorToggleButton");
- show_waveforms_recording_button.set_name ("OptionEditorToggleButton");
- show_measures_button.set_name ("OptionEditorToggleButton");
- follow_playhead_button.set_name ("OptionEditorToggleButton");
- mixer_strip_width_button.set_name ("OptionEditorToggleButton");
-
- mixer_strip_width_button.set_active (mixer.get_strip_width() == Narrow);
-
- hbox = manage (new HBox);
- hbox->set_border_width (8);
- hbox->pack_start (show_waveforms_button, false, false);
- display_packer.pack_start (*hbox, false, false);
-
- hbox = manage (new HBox);
- hbox->set_border_width (8);
- hbox->pack_start (show_waveforms_recording_button, false, false);
- display_packer.pack_start (*hbox, false, false);
-
- hbox = manage (new HBox);
- hbox->set_border_width (8);
- hbox->pack_start (show_measures_button, false, false);
- display_packer.pack_start (*hbox, false, false);
-
- hbox = manage (new HBox);
- hbox->set_border_width (8);
- hbox->pack_start (mixer_strip_width_button, false, false);
- display_packer.pack_start (*hbox, false, false);
-
- hbox = manage (new HBox);
- hbox->set_border_width (8);
- hbox->pack_start (follow_playhead_button, false, false);
- display_packer.pack_start (*hbox, false, false);
-
- Label *meter_hold_label = manage (new Label (_("Meter Peak Hold")));
- meter_hold_label->set_name ("OptionsLabel");
- dumb.clear ();
- dumb.push_back (_("Off"));
- dumb.push_back (_("Short"));
- dumb.push_back (_("Medium"));
- dumb.push_back (_("Long"));
- set_popdown_strings (meter_hold_combo, dumb);
- meter_hold_combo.get_popwin()->signal_unmap_event().connect (mem_fun(*this, &OptionEditor::meter_hold_chosen));
- hbox = manage (new HBox);
- hbox->set_border_width (8);
- hbox->set_spacing (8);
- hbox->pack_start (*meter_hold_label, false, false);
- hbox->pack_start (meter_hold_combo, false, false);
- display_packer.pack_start (*hbox, false, false);
-
- Label *meter_falloff_label = manage (new Label (_("Meter Falloff")));
- meter_falloff_label->set_name ("OptionsLabel");
- dumb.clear ();
- dumb.push_back (_("Off"));
- dumb.push_back (_("Slowest"));
- dumb.push_back (_("Slow"));
- dumb.push_back (_("Medium"));
- dumb.push_back (_("Fast"));
- dumb.push_back (_("Faster"));
- dumb.push_back (_("Fastest"));
- set_popdown_strings (meter_falloff_combo, dumb);
- meter_falloff_combo.get_popwin()->signal_unmap_event().connect (mem_fun(*this, &OptionEditor::meter_falloff_chosen));
- hbox = manage (new HBox);
- hbox->set_border_width (8);
- hbox->set_spacing (8);
- hbox->pack_start (*meter_falloff_label, false, false);
- hbox->pack_start (meter_falloff_combo, false, false);
- display_packer.pack_start (*hbox, false, false);
-
-
- show_waveforms_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::show_waveforms_clicked));
- show_waveforms_recording_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::show_waveforms_recording_clicked));
- show_measures_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::show_measures_clicked));
- mixer_strip_width_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::strip_width_clicked));
- follow_playhead_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::follow_playhead_clicked));
-
- editor.DisplayControlChanged.connect (mem_fun(*this, &OptionEditor::display_control_changed));
-
- show_measures_button.set_active (editor.show_measures());
- show_waveforms_button.set_active (editor.show_waveforms());
- show_waveforms_recording_button.set_active (editor.show_waveforms_recording());
- follow_playhead_button.set_active (editor.follow_playhead());
-}
-
-gint
-OptionEditor::meter_hold_chosen (GdkEventAny* ev)
-{
- if (session) {
- string str = meter_hold_combo.get_entry()->get_text();
-
- if (str == _("Off")) {
- session->set_meter_hold (0);
- } else if (str == _("Short")) {
- session->set_meter_hold (40);
- } else if (str == _("Medium")) {
- session->set_meter_hold (100);
- } else if (str == _("Long")) {
- session->set_meter_hold (200);
- }
- }
-
- return TRUE;
-}
-
-gint
-OptionEditor::meter_falloff_chosen (GdkEventAny* ev)
-{
- if (session) {
- string str = meter_falloff_combo.get_entry()->get_text();
-
- if (str == _("Off")) {
- session->set_meter_falloff (0.0f);
- } else if (str == _("Slowest")) {
- session->set_meter_falloff (0.266f); // 6.6 dB/sec falloff at update rate of 40 ms
- } else if (str == _("Slow")) {
- session->set_meter_falloff (0.342f); // 8.6 dB/sec falloff at update rate of 40 ms
- } else if (str == _("Medium")) {
- session->set_meter_falloff (0.7f);
- } else if (str == _("Fast")) {
- session->set_meter_falloff (1.1f);
- } else if (str == _("Faster")) {
- session->set_meter_falloff (1.5f);
- } else if (str == _("Fastest")) {
- session->set_meter_falloff (2.5f);
- }
- }
-
- return TRUE;
+RcConfigDisplay::add_to_page (OptionEditorPage *p)
+{
+ int const n = p->table.property_n_rows();
+ int m = n + 1;
+ p->table.resize (m, 3);
+ p->table.attach (*_label, 1, 2, n, n + 1, FILL | EXPAND);
+ p->table.attach (*_info, 2, 3, n, n + 1, FILL | EXPAND);
}
-void
-OptionEditor::display_control_changed (Editing::DisplayControl dc)
-{
- ToggleButton* button = 0;
- bool val = true;
-
- switch (dc) {
- case ShowMeasures:
- val = editor.show_measures ();
- button = &show_measures_button;
- break;
- case ShowWaveforms:
- val = editor.show_waveforms ();
- button = &show_waveforms_button;
- break;
- case ShowWaveformsRecording:
- val = editor.show_waveforms_recording ();
- button = &show_waveforms_recording_button;
- break;
- case FollowPlayhead:
- val = editor.follow_playhead ();
- button = &follow_playhead_button;
- break;
- }
+/*--------------------------*/
- if (button->get_active() != val) {
- button->set_active (val);
+RcActionButton::RcActionButton (std::string const & t, const Glib::SignalProxy0< void >::SlotType & slot, std::string const & l)
+ : _label (NULL)
+{
+ _button = manage (new Button (t));
+ _button->signal_clicked().connect (slot);
+ if (!l.empty ()) {
+ _label = manage (right_aligned_label (l));
}
}
void
-OptionEditor::setup_sync_options ()
-{
- Label *slave_type_label = manage (new Label (_("Positional Sync")));
- HBox* hbox;
- vector<string> dumb;
-
- slave_type_label->set_name("OptionsLabel");
- positional_sync_strings = internationalize (psync_strings);
-
- slave_type_combo.set_use_arrows_always (true);
- slave_type_combo.set_value_in_list (true, false);
- slave_type_combo.get_entry()->set_editable (false);
- slave_type_combo.get_entry()->set_name ("OptionsEntry");
- slave_type_combo.get_popwin()->signal_unmap_event().connect (mem_fun(*this, &OptionEditor::slave_type_chosen));
-
- 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.get_popwin()->signal_unmap_event().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));
-
- send_mtc_button.set_name ("OptionEditorToggleButton");
- jack_time_master_button.set_name ("OptionEditorToggleButton");
- smpte_offset_negative_button.set_name ("OptionEditorToggleButton");
-
- send_mtc_button.unset_flags (Gtk::CAN_FOCUS);
- jack_time_master_button.unset_flags (Gtk::CAN_FOCUS);
- smpte_offset_negative_button.unset_flags (Gtk::CAN_FOCUS);
-
- hbox = manage (new HBox);
- hbox->set_border_width (5);
- hbox->set_spacing (10);
- hbox->pack_start (*slave_type_label, false, false);
- hbox->pack_start (slave_type_combo, false, false);
-
- sync_packer.pack_start (*hbox, false, false);
-
- hbox = manage (new HBox);
- hbox->set_border_width (5);
- hbox->pack_start (send_mtc_button, false, false);
- sync_packer.pack_start (*hbox, false, false);
-
- hbox = manage (new HBox);
- hbox->set_border_width (5);
- hbox->pack_start (jack_time_master_button, false, false);
- sync_packer.pack_start (*hbox, false, false);
-
- 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);
-
- jack_time_master_button.set_active (Config->get_jack_time_master());
-
- send_mtc_button.signal_button_press_event().connect (bind (mem_fun(*this, &OptionEditor::send_mtc_toggled), &send_mtc_button));
- jack_time_master_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::jack_time_master_clicked));
- smpte_offset_negative_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::smpte_offset_negative_clicked));
-}
-
-void
-OptionEditor::smpte_offset_negative_clicked ()
+RcActionButton::add_to_page (OptionEditorPage *p)
{
- if (session) {
- session->set_smpte_offset_negative (smpte_offset_negative_button.get_active());
+ int const n = p->table.property_n_rows();
+ int m = n + 1;
+ p->table.resize (m, 3);
+ if (_label) {
+ p->table.attach (*_label, 1, 2, n, n + 1, FILL | EXPAND);
+ p->table.attach (*_button, 2, 3, n, n + 1, FILL | EXPAND);
+ } else {
+ p->table.attach (*_button, 1, 3, n, n + 1, FILL | EXPAND);
}
}
-gint
-OptionEditor::smpte_fps_chosen (GdkEventAny* ev)
-{
- if (session) {
- string str = smpte_fps_combo.get_entry()->get_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);
- }
- }
-
- return TRUE;
-}
+/*--------------------------*/
-void
-OptionEditor::smpte_offset_chosen()
+BoolOption::BoolOption (string const & i, string const & n, sigc::slot<bool> g, sigc::slot<bool, bool> s)
+ : Option (i, n),
+ _get (g),
+ _set (s)
{
- if (session) {
- jack_nframes_t frames = smpte_offset_clock.current_duration();
- session->set_smpte_offset (frames);
- }
+ _button = manage (new CheckButton);
+ _label = manage (new Label);
+ _label->set_markup (n);
+ _button->add (*_label);
+ _button->set_active (_get ());
+ _button->signal_toggled().connect (sigc::mem_fun (*this, &BoolOption::toggled));
}
-
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;
- RadioButton* first_mtc_button = 0;
- RadioButton* first_mmc_button = 0;
- RadioButton* first_midi_button = 0;
-
- 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<MIDI::Port*,vector<RadioButton*> > newpair;
-
- newpair.first = i->second;
-
- table->attach (*(manage (new Label (i->first))), 0, 1, n+2, n+3, 0, 0);
- 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, 0, 0);
-
- 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, 0, 0);
-
- 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, 0, 0);
-
- rb = manage (new RadioButton ());
- newpair.second.push_back (rb);
- rb->set_name ("OptionEditorToggleButton");
- if (n == 0) {
- first_mtc_button = rb;
- } else {
- rb->set_group (first_mtc_button->group());
- }
- table->attach (*rb, 4, 5, n+2, n+3, 0, 0);
- 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) {
- first_mmc_button = rb;
- } else {
- rb->set_group (first_mmc_button->group());
- }
- table->attach (*rb, 6, 7, n+2, n+3, 0, 0);
- 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) {
- first_midi_button = rb;
- } else {
- rb->set_group (first_midi_button->group());
- }
- table->attach (*rb, 8, 9, n+2, n+3, 0, 0);
- 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);
- }
-
- 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);
-
- VBox* mmcbuttonbox = manage (new VBox);
-
- mmc_control_button.set_name ("OptionEditorToggleButton");
-
- hbox = manage (new HBox);
- hbox->set_border_width (6);
- hbox->pack_start (mmc_control_button, false, false, 36);
- mmcbuttonbox->pack_start (*hbox, false, false);
-
- midi_control_button.set_name ("OptionEditorToggleButton");
-
- hbox = manage (new HBox);
- hbox->set_border_width (6);
- hbox->pack_start (midi_control_button, false, false, 36);
- mmcbuttonbox->pack_start (*hbox, false, false);
-
- send_mmc_button.set_name ("OptionEditorToggleButton");
-
- hbox = manage (new HBox);
- hbox->set_border_width (6);
- hbox->pack_start (send_mmc_button, false, false, 36);
- mmcbuttonbox->pack_start (*hbox, false, false);
-
- midi_feedback_button.set_name ("OptionEditorToggleButton");
-
- hbox = manage (new HBox);
- hbox->set_border_width (6);
- hbox->pack_start (midi_feedback_button, false, false, 36);
- mmcbuttonbox->pack_start (*hbox, false, false);
-
- midi_packer.pack_start (*mmcbuttonbox, false, false);
-
- mmc_control_button.signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mmc_control_toggled), &mmc_control_button));
- midi_control_button.signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::midi_control_toggled), &midi_control_button));
- send_mmc_button.signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::send_mmc_toggled), &send_mmc_button));
- midi_feedback_button.signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::midi_feedback_toggled), &midi_feedback_button));
-}
-
-gint
-OptionEditor::mtc_port_chosen (GdkEventButton* ev, MIDI::Port *port, Gtk::RadioButton* rb)
+BoolOption::add_to_page (OptionEditorPage* p)
{
- 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 ("");
- }
-
- /* update sync options to reflect MTC port availability */
-
- vector<string> dumb;
- dumb.push_back (positional_sync_strings[Session::None]);
- dumb.push_back (positional_sync_strings[Session::JACK]);
-
- if (session->mtc_port()) {
- dumb.push_back (positional_sync_strings[Session::MTC]);
- }
- set_popdown_strings (slave_type_combo, dumb);
-
- rb->set_active (true);
- }
- }
-
- return stop_signal (*rb, "button_press_event");
+ add_widget_to_page (p, _button);
}
-gint
-OptionEditor::mmc_port_chosen (GdkEventButton* ev, MIDI::Port* port, Gtk::RadioButton* rb)
+void
+BoolOption::set_state_from_config ()
{
- 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 stop_signal (*rb, "button_press_event");
+ _button->set_active (_get ());
}
-gint
-OptionEditor::midi_port_chosen (GdkEventButton* ev, MIDI::Port* port, Gtk::RadioButton* rb)
+void
+BoolOption::toggled ()
{
- 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);
- }
+ if (!_set (_button->get_active ())) {
+ _button->set_active (_get ());
}
- return stop_signal (*rb, "button_press_event");
}
-gint
-OptionEditor::port_online_toggled (GdkEventButton* ev, MIDI::Port* port, ToggleButton* tb)
-{
- bool wanted = tb->get_active(); /* it hasn't changed at this point */
+/*--------------------------*/
- if (wanted != port->input()->offline()) {
- port->input()->set_offline (wanted);
- }
- return stop_signal (*tb, "button_press_event");
+RouteDisplayBoolOption::RouteDisplayBoolOption (string const & i, string const & n, sigc::slot<bool> g, sigc::slot<bool, bool> s)
+ : BoolOption (i, n, g, s)
+{
}
void
-OptionEditor::map_port_online (MIDI::Port* port, ToggleButton* tb)
+RouteDisplayBoolOption::toggled ()
{
- if (port->input()->offline()) {
- static_cast<Label*>(tb->get_child())->set_text (_("offline"));
- tb->set_active (false);
- } else {
- static_cast<Label*>(tb->get_child())->set_text (_("online"));
- tb->set_active (true);
- }
+ DisplaySuspender ds;
+ BoolOption::toggled ();
}
-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)
+EntryOption::EntryOption (string const & i, string const & n, sigc::slot<string> g, sigc::slot<bool, string> s)
+ : Option (i, n),
+ _get (g),
+ _set (s)
{
- /* 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");
-}
-
-gint
-OptionEditor::send_mtc_toggled (GdkEventButton *ev, CheckButton *button)
-{
- if (session) {
- session->set_send_mtc (!button->get_active());
- }
- return stop_signal (*button, "button_press_event");
+ _label = manage (left_aligned_label (n + ":"));
+ _entry = manage (new Entry);
+ _entry->signal_activate().connect (sigc::mem_fun (*this, &EntryOption::activated));
+ _entry->signal_focus_out_event().connect (sigc::mem_fun (*this, &EntryOption::focus_out));
+ _entry->signal_insert_text().connect (sigc::mem_fun (*this, &EntryOption::filter_text));
}
void
-OptionEditor::send_mmc_toggled (CheckButton *button)
+EntryOption::add_to_page (OptionEditorPage* p)
{
- if (session) {
- session->set_send_mmc (button->get_active());
- }
+ add_widgets_to_page (p, _label, _entry);
}
void
-OptionEditor::mmc_control_toggled (CheckButton *button)
+EntryOption::set_state_from_config ()
{
- if (session) {
- session->set_mmc_control (button->get_active());
- }
+ _entry->set_text (_get ());
}
void
-OptionEditor::midi_control_toggled (CheckButton *button)
+EntryOption::set_sensitive (bool s)
{
- if (session) {
- session->set_midi_control (button->get_active());
- }
+ _entry->set_sensitive (s);
}
void
-OptionEditor::midi_feedback_toggled (CheckButton *button)
+EntryOption::filter_text (const Glib::ustring&, int*)
{
- if (session) {
- session->set_midi_feedback (button->get_active());
+ std::string text = _entry->get_text ();
+ for (size_t i = 0; i < _invalid.length(); ++i) {
+ text.erase (std::remove(text.begin(), text.end(), _invalid.at(i)), text.end());
+ }
+ if (text != _entry->get_text ()) {
+ _entry->set_text (text);
}
}
void
-OptionEditor::save ()
+EntryOption::activated ()
{
- /* XXX a bit odd that we save the entire session state here */
-
- ui.save_state ("");
+ _set (_entry->get_text ());
}
-gint
-OptionEditor::wm_close (GdkEventAny *ev)
+bool
+EntryOption::focus_out (GdkEventFocus*)
{
- save ();
- just_close_win();
- return TRUE;
+ _set (_entry->get_text ());
+ return true;
}
-void
-OptionEditor::jack_time_master_clicked ()
+/*--------------------------*/
+HSliderOption::HSliderOption (
+ std::string const& i,
+ std::string const& n,
+ sigc::slot<float> g,
+ sigc::slot<bool, float> s,
+ double lower, double upper,
+ double step_increment,
+ double page_increment,
+ double mult,
+ bool logarithmic
+ )
+ : Option (i, n)
+ , _get (g)
+ , _set (s)
+ , _adj (lower, lower, upper, step_increment, page_increment, 0)
+ , _hscale (_adj)
+ , _label (n + ":")
+ , _mult (mult)
+ , _log (logarithmic)
{
- bool yn = jack_time_master_button.get_active();
-
- Config->set_jack_time_master (yn);
-
- if (session) {
- session->engine().reset_timebase ();
- }
+ _label.set_alignment (0, 0.5);
+ _label.set_name ("OptionsLabel");
+ _adj.set_value (_get());
+ _adj.signal_value_changed().connect (sigc::mem_fun (*this, &HSliderOption::changed));
+ _hscale.set_update_policy (Gtk::UPDATE_DISCONTINUOUS);
}
void
-OptionEditor::raid_path_changed ()
+HSliderOption::set_state_from_config ()
{
- if (session) {
- session->set_raid_path (session_raid_entry.get_text());
+ if (_log) {
+ _adj.set_value (log10(_get()) / _mult);
+ } else {
+ _adj.set_value (_get() / _mult);
}
}
void
-OptionEditor::click_browse_clicked ()
+HSliderOption::changed ()
{
- SoundFileChooser sfdb (_("Choose Click"));
-
- int result = sfdb.run ();
-
- if (result == Gtk::RESPONSE_OK) {
- click_chosen(sfdb.get_filename());
+ if (_log) {
+ _set (pow (10, _adj.get_value () * _mult));
+ } else {
+ _set (_adj.get_value () * _mult);
}
}
void
-OptionEditor::click_chosen (string path)
+HSliderOption::add_to_page (OptionEditorPage* p)
{
- click_path_entry.set_text (path);
- click_sound_changed ();
+ add_widgets_to_page (p, &_label, &_hscale);
}
void
-OptionEditor::click_emphasis_browse_clicked ()
+HSliderOption::set_sensitive (bool yn)
{
- SoundFileChooser sfdb (_("Choose Click Emphasis"));
+ _hscale.set_sensitive (yn);
+}
- int result = sfdb.run ();
+/*--------------------------*/
- if (result == Gtk::RESPONSE_OK) {
- click_emphasis_chosen (sfdb.get_filename());
- }
+ComboStringOption::ComboStringOption (
+ std::string const & i,
+ std::string const & n,
+ sigc::slot<std::string> g,
+ sigc::slot<bool, std::string> s
+ )
+ : Option (i, n)
+ , _get (g)
+ , _set (s)
+{
+ _label = Gtk::manage (new Gtk::Label (n + ":"));
+ _label->set_alignment (0, 0.5);
+ _combo = Gtk::manage (new Gtk::ComboBoxText);
+ _combo->signal_changed().connect (sigc::mem_fun (*this, &ComboStringOption::changed));
}
void
-OptionEditor::click_emphasis_chosen (std::string path)
-{
- click_emphasis_path_entry.set_text (path);
- click_emphasis_sound_changed ();
+ComboStringOption::set_state_from_config () {
+ _combo->set_active_text (_get());
}
void
-OptionEditor::click_sound_changed ()
+ComboStringOption::add_to_page (OptionEditorPage* p)
{
- 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);
- }
- }
- }
+ add_widgets_to_page (p, _label, _combo);
}
+/** Set the allowed strings for this option
+ * @param strings a vector of allowed strings
+ */
void
-OptionEditor::click_emphasis_sound_changed ()
-{
- 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);
- }
- }
+ComboStringOption::set_popdown_strings (const std::vector<std::string>& strings) {
+ _combo->clear_items ();
+ for (std::vector<std::string>::const_iterator i = strings.begin(); i != strings.end(); ++i) {
+ _combo->append_text (*i);
}
}
void
-OptionEditor::show_waveforms_clicked ()
-{
- editor.set_show_waveforms (show_waveforms_button.get_active());
+ComboStringOption::clear () {
+ _combo->clear_items();
}
void
-OptionEditor::show_waveforms_recording_clicked ()
-{
- editor.set_show_waveforms_recording (show_waveforms_recording_button.get_active());
+ComboStringOption::changed () {
+ _set (_combo->get_active_text ());
}
void
-OptionEditor::show_measures_clicked ()
-{
- editor.set_show_measures (show_measures_button.get_active());
+ComboStringOption::set_sensitive (bool yn) {
+ _combo->set_sensitive (yn);
}
-void
-OptionEditor::follow_playhead_clicked ()
+/*--------------------------*/
+
+/** Construct a BoolComboOption.
+ * @param i id
+ * @param n User-visible name.
+ * @param t Text to give for the variable being true.
+ * @param f Text to give for the variable being false.
+ * @param g Slot to get the variable's value.
+ * @param s Slot to set the variable's value.
+ */
+BoolComboOption::BoolComboOption (
+ string const & i, string const & n, string const & t, string const & f,
+ sigc::slot<bool> g, sigc::slot<bool, bool> s
+ )
+ : Option (i, n)
+ , _get (g)
+ , _set (s)
{
- editor.set_follow_playhead (follow_playhead_button.get_active());
+ _label = manage (new Label (n + ":"));
+ _label->set_alignment (0, 0.5);
+ _combo = manage (new ComboBoxText);
+
+ /* option 0 is the false option */
+ _combo->append_text (f);
+ /* and option 1 is the true */
+ _combo->append_text (t);
+
+ _combo->signal_changed().connect (sigc::mem_fun (*this, &BoolComboOption::changed));
}
void
-OptionEditor::strip_width_clicked ()
+BoolComboOption::set_state_from_config ()
{
- mixer.set_strip_width (mixer_strip_width_button.get_active() ? Narrow : Wide);
+ _combo->set_active (_get() ? 1 : 0);
}
-
void
-OptionEditor::just_close_win()
+BoolComboOption::add_to_page (OptionEditorPage* p)
{
- hide_all();
- ARDOUR_UI::instance()->allow_focus(false);
+ add_widgets_to_page (p, _label, _combo);
}
void
-OptionEditor::queue_session_control_changed (Session::ControlType t)
+BoolComboOption::changed ()
{
- ui.call_slot (bind (mem_fun(*this, &OptionEditor::session_control_changed), t));
+ _set (_combo->get_active_row_number () == 0 ? false : true);
}
void
-OptionEditor::session_control_changed (Session::ControlType t)
-{
- switch (t) {
- case Session::SlaveType:
- switch (session->slave_source()) {
- case Session::None:
- slave_type_combo.get_entry()->set_text (positional_sync_strings[Session::None]);
- break;
- case Session::MTC:
- slave_type_combo.get_entry()->set_text (positional_sync_strings[Session::MTC]);
- break;
- case Session::JACK:
- slave_type_combo.get_entry()->set_text (positional_sync_strings[Session::JACK]);
- break;
- default:
- slave_type_combo.get_entry()->set_text (_("--unknown--"));
- break;
- }
-
- break;
-
- case Session::SendMTC:
- map_some_session_state (send_mtc_button, &Session::get_send_mtc);
- break;
-
- case Session::SendMMC:
- map_some_session_state (send_mmc_button, &Session::get_send_mmc);
- break;
-
- case Session::MMCControl:
- map_some_session_state (mmc_control_button, &Session::get_mmc_control);
- break;
-
- case Session::MidiFeedback:
- map_some_session_state (midi_feedback_button, &Session::get_midi_feedback);
- break;
-
- case Session::MidiControl:
- map_some_session_state (midi_control_button, &Session::get_midi_control);
- break;
-
- default:
- break;
- }
+BoolComboOption::set_sensitive (bool yn)
+{
+ _combo->set_sensitive (yn);
}
-gint
-OptionEditor::native_format_chosen (GdkEventAny *ignored)
+/*--------------------------*/
+
+FaderOption::FaderOption (string const & i, string const & n, sigc::slot<gain_t> g, sigc::slot<bool, gain_t> 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)
{
- string which;
+ _db_slider = manage (new ArdourWidgets::HSliderController (&_db_adjustment, boost::shared_ptr<PBD::Controllable>(), 220, 18));
- if (session == 0) {
- return FALSE;
- }
+ _label.set_text (n + ":");
+ _label.set_alignment (0, 0.5);
+ _label.set_name (X_("OptionsLabel"));
- bool use_bwf = (native_format_combo.get_entry()->get_text() == native_format_strings[0]);
+ _fader_centering_box.pack_start (*_db_slider, true, false);
- if (use_bwf != Config->get_native_format_is_bwf()) {
- Config->set_native_format_is_bwf (use_bwf);
- session->reset_native_file_format ();
- }
+ _box.set_spacing (4);
+ _box.set_homogeneous (false);
+ _box.pack_start (_fader_centering_box, false, false);
+ _box.pack_start (_db_display, false, false);
+ _box.pack_start (*manage (new Label ("dB")), false, false);
+ _box.show_all ();
+
+ set_size_request_to_display_given_text (_db_display, "-99.00", 12, 0);
- return TRUE;
+ _db_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &FaderOption::db_changed));
+ _db_display.signal_activate().connect (sigc::mem_fun (*this, &FaderOption::on_activate));
+ _db_display.signal_key_press_event().connect (sigc::mem_fun (*this, &FaderOption::on_key_press), false);
}
-gint
-OptionEditor::slave_type_chosen (GdkEventAny *ignored)
+void
+FaderOption::set_state_from_config ()
{
- string which;
+ gain_t const val = _get ();
+ _db_adjustment.set_value (gain_to_slider_position_with_max (val, Config->get_max_gain ()));
- if (session == 0) {
- return FALSE;
- }
+ char buf[16];
- which = slave_type_combo.get_entry()->get_text();
+ if (val == 0.0) {
+ snprintf (buf, sizeof (buf), "-inf");
+ } else {
+ snprintf (buf, sizeof (buf), "%.2f", accurate_coefficient_to_dB (val));
+ }
- if (which == positional_sync_strings[Session::None]) {
- session->request_slave_source (Session::None);
- } else if (which == positional_sync_strings[Session::MTC]) {
- session->request_slave_source (Session::MTC);
- } else if (which == positional_sync_strings[Session::JACK]) {
- session->request_slave_source (Session::JACK);
- }
- return FALSE;
+ _db_display.set_text (buf);
}
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;
- }
+FaderOption::db_changed ()
+{
+ _set (slider_position_to_gain_with_max (_db_adjustment.get_value (), Config->get_max_gain()));
}
void
-OptionEditor::setup_click_editor ()
+FaderOption::on_activate ()
{
- 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.activate.connect (mem_fun(*this, &OptionEditor::click_sound_changed));
- click_emphasis_path_entry.activate.connect (mem_fun(*this, &OptionEditor::click_emphasis_sound_changed));
-
- click_path_entry.signal_focus_in_event()().connect (mem_fun (Keyboard::the_keyboard(), &Keyboard::focus_in_handler));
- 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_in_event()().connect (mem_fun (Keyboard::the_keyboard(), &Keyboard::focus_in_handler));
- click_emphasis_path_entry.signal_focus_out_event()().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_emphasis_sound_changed));
+ float db_val = atof (_db_display.get_text ().c_str ());
+ gain_t coeff_val = dB_to_coefficient (db_val);
- 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));
-
- click_packer.set_border_width (12);
- click_packer.set_spacing (5);
-
- click_io_selector = new IOSelector (*session, session->click_io(), false);
- click_gpm = new GainMeter (session->click_io(), *session);
-
- 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, 0, 0);
- click_table.attach (click_path_entry, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, 0);
- click_table.attach (click_browse_button, 2, 3, 0, 1, 0, 0);
-
- label = manage(new Label(_("Click emphasis audiofile")));
- label->set_name ("OptionsLabel");
- click_table.attach (*label, 0, 1, 1, 2, 0, 0);
- click_table.attach (click_emphasis_path_entry, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, 0);
- click_table.attach (click_emphasis_browse_button, 2, 3, 1, 2, 0, 0);
-
- hpacker->set_spacing (10);
- hpacker->pack_start (*click_io_selector, false, false);
- hpacker->pack_start (*click_gpm, false, false);
-
- click_packer.pack_start (click_table, false, false);
- click_packer.pack_start (*hpacker, false, false);
-
- click_packer.show_all ();
+ _db_adjustment.set_value (gain_to_slider_position_with_max (coeff_val, Config->get_max_gain ()));
}
-void
-OptionEditor::clear_auditioner_editor ()
-{
- 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;
+bool
+FaderOption::on_key_press (GdkEventKey* ev)
+{
+ if (ARDOUR_UI_UTILS::key_is_legal_for_numeric_entry (ev->keyval)) {
+ /* drop through to normal handling */
+ return false;
}
+ /* illegal key for gain entry */
+ return true;
}
void
-OptionEditor::setup_auditioner_editor ()
+FaderOption::add_to_page (OptionEditorPage* p)
{
- audition_packer.set_border_width (12);
- audition_packer.set_spacing (5);
- audition_hpacker.set_spacing (10);
-
- 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);
+ add_widgets_to_page (p, &_label, &_box);
}
-void
-OptionEditor::connect_audition_editor ()
-{
- auditioner_io_selector = new IOSelector (*session, session->the_auditioner(), false);
- auditioner_gpm = new GainMeter (session->the_auditioner(), *session);
-
- audition_hpacker.pack_start (*auditioner_io_selector, false, false);
- audition_hpacker.pack_start (*auditioner_gpm, false, false);
+/*--------------------------*/
- auditioner_io_selector->show_all ();
- auditioner_gpm->show_all ();
+ClockOption::ClockOption (string const & i, string const & n, sigc::slot<std::string> g, sigc::slot<bool, std::string> s)
+ : Option (i, n)
+ , _clock (X_("timecode-offset"), true, X_(""), true, false, true, false)
+ , _get (g)
+ , _set (s)
+{
+ _label.set_text (n + ":");
+ _label.set_alignment (0, 0.5);
+ _label.set_name (X_("OptionsLabel"));
+ _clock.ValueChanged.connect (sigc::mem_fun (*this, &ClockOption::save_clock_time));
}
-gint
-OptionEditor::focus_out_event_handler (GdkEventFocus* ev, void (OptionEditor::*pmf)())
+void
+ClockOption::set_state_from_config ()
{
- (this->*pmf)();
- return Keyboard::the_keyboard().focus_out_handler (ev);
+ Timecode::Time TC;
+ samplepos_t when;
+ if (!Timecode::parse_timecode_format(_get(), TC)) {
+ _clock.set (0, true);
+ }
+ TC.rate = _session->samples_per_timecode_frame();
+ TC.drop = _session->timecode_drop_frames();
+ _session->timecode_to_sample(TC, when, false, false);
+ if (TC.negative) { when=-when; }
+ _clock.set (when, true);
}
void
-OptionEditor::setup_misc_options()
-{
- Gtk::Table* table = manage (new Table (4, 2));
- table->set_homogeneous (true);
-
- misc_packer.set_border_width (8);
- misc_packer.set_spacing (3);
- misc_packer.pack_start (*table, true, true);
-
- table->attach (hw_monitor_button, 0, 1, 0, 1, Gtk::FILL, 0, 8, 0);
- table->attach (sw_monitor_button, 0, 1, 1, 2, Gtk::FILL, 0, 8, 0);
- table->attach (plugins_stop_button, 0, 1, 2, 3, Gtk::FILL, 0, 8, 0);
- table->attach (plugins_on_rec_button, 0, 1, 3, 4, Gtk::FILL, 0, 8, 0);
- table->attach (verify_remove_last_capture_button, 0, 1, 4, 5, Gtk::FILL, 0, 8, 0);
-
- table->attach (stop_rec_on_xrun_button, 1, 2, 0, 1, Gtk::FILL, 0, 8, 0);
- table->attach (stop_at_end_button, 1, 2, 1, 2, Gtk::FILL, 0, 8, 0);
- table->attach (debug_keyboard_button, 1, 2, 2, 3, Gtk::FILL, 0, 8, 0);
- table->attach (speed_quieten_button, 1, 2, 3, 4, Gtk::FILL, 0, 8, 0);
-
- Gtk::VBox* connect_box = manage (new VBox);
- connect_box->set_spacing (3);
- connect_box->set_border_width (8);
-
- auto_connect_output_manual_button.set_group (auto_connect_output_master_button.get_group());
- auto_connect_output_physical_button.set_group (auto_connect_output_master_button.get_group());
-
- Gtk::HBox* useless_box = manage (new HBox);
- useless_box->pack_start (auto_connect_inputs_button, false, false);
- connect_box->pack_start (*useless_box, false, false);
- connect_box->pack_start (auto_connect_output_master_button, false, false);
- connect_box->pack_start (auto_connect_output_physical_button, false, false);
- connect_box->pack_start (auto_connect_output_manual_button, false);
-
- misc_packer.pack_start (*connect_box, false, false);
-
- hw_monitor_button.set_name ("OptionEditorToggleButton");
- sw_monitor_button.set_name ("OptionEditorToggleButton");
- plugins_stop_button.set_name ("OptionEditorToggleButton");
- plugins_on_rec_button.set_name ("OptionEditorToggleButton");
- verify_remove_last_capture_button.set_name ("OptionEditorToggleButton");
- auto_connect_inputs_button.set_name ("OptionEditorToggleButton");
- auto_connect_output_physical_button.set_name ("OptionEditorToggleButton");
- auto_connect_output_master_button.set_name ("OptionEditorToggleButton");
- auto_connect_output_manual_button.set_name ("OptionEditorToggleButton");
- stop_rec_on_xrun_button.set_name ("OptionEditorToggleButton");
- stop_at_end_button.set_name ("OptionEditorToggleButton");
- debug_keyboard_button.set_name ("OptionEditorToggleButton");
- speed_quieten_button.set_name ("OptionEditorToggleButton");
-
- hw_monitor_button.set_active (Config->get_use_hardware_monitoring());
- sw_monitor_button.set_active (!Config->get_no_sw_monitoring());
- plugins_stop_button.set_active (Config->get_plugins_stop_with_transport());
- stop_rec_on_xrun_button.set_active (Config->get_stop_recording_on_xrun());
- stop_at_end_button.set_active (Config->get_stop_at_session_end());
- debug_keyboard_button.set_active (false);
- speed_quieten_button.set_active (Config->get_quieten_at_speed() != 1.0f);
-
- hw_monitor_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::hw_monitor_clicked));
- sw_monitor_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::sw_monitor_clicked));
- plugins_stop_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::plugins_stop_with_transport_clicked));
- plugins_on_rec_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::plugins_on_while_recording_clicked));
- verify_remove_last_capture_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::verify_remove_last_capture_clicked));
- auto_connect_inputs_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::auto_connect_inputs_clicked));
- auto_connect_output_physical_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::auto_connect_output_physical_clicked));
- auto_connect_output_master_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::auto_connect_output_master_clicked));
- auto_connect_output_manual_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::auto_connect_output_manual_clicked));
- stop_rec_on_xrun_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::stop_rec_on_xrun_clicked));
- stop_at_end_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::stop_at_end_clicked));
- debug_keyboard_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::debug_keyboard_clicked));
- speed_quieten_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::speed_quieten_clicked));
+ClockOption::save_clock_time ()
+{
+ Timecode::Time TC;
+ _session->sample_to_timecode(_clock.current_time(), TC, false, false);
+ _set (Timecode::timecode_format_time(TC));
}
void
-OptionEditor::speed_quieten_clicked ()
+ClockOption::add_to_page (OptionEditorPage* p)
{
- if (speed_quieten_button.get_active()) {
- Config->set_quieten_at_speed (0.251189); // -12dB reduction for ffwd or rewind
- } else {
- Config->set_quieten_at_speed (1.0); /* no change */
- }
+ add_widgets_to_page (p, &_label, &_clock);
}
void
-OptionEditor::debug_keyboard_clicked ()
+ClockOption::set_session (Session* s)
{
- extern bool debug_keyboard;
- debug_keyboard = debug_keyboard_button.get_active ();
+ _session = s;
+ _clock.set_session (s);
}
-void
-OptionEditor::auto_connect_inputs_clicked ()
+/*--------------------------*/
+
+WidgetOption::WidgetOption (string const & i, string const & n, Gtk::Widget& w)
+ : Option (i, n)
+ , _widget (&w)
{
- if (session) {
- session->set_input_auto_connect (auto_connect_inputs_button.get_active());
- }
}
void
-OptionEditor::auto_connect_output_master_clicked ()
+WidgetOption::add_to_page (OptionEditorPage* p)
{
- if (session) {
- if (auto_connect_output_master_button.get_active()) {
- session->set_output_auto_connect (Session::AutoConnectMaster);
- }
- }
+ add_widget_to_page (p, _widget);
}
-void
-OptionEditor::auto_connect_output_physical_clicked ()
+/*--------------------------*/
+
+OptionEditorPage::OptionEditorPage ()
+ : table (1, 3)
{
- if (session) {
- if (auto_connect_output_physical_button.get_active()) {
- session->set_output_auto_connect (Session::AutoConnectPhysical);
- }
- }
+ init ();
}
-void
-OptionEditor::auto_connect_output_manual_clicked ()
+OptionEditorPage::OptionEditorPage (Gtk::Notebook& n, std::string const & t)
+ : table (1, 3)
{
- if (session) {
- if (auto_connect_output_manual_button.get_active()) {
- session->set_output_auto_connect (Session::AutoConnectOption (0));
- }
- }
+ init ();
+ box.pack_start (table, false, false);
+ box.set_border_width (4);
+ n.append_page (box, t);
}
void
-OptionEditor::hw_monitor_clicked ()
+OptionEditorPage::init ()
{
- Config->set_use_hardware_monitoring (hw_monitor_button.get_active());
+ table.set_spacings (4);
+ table.set_col_spacing (0, 32);
}
+/*--------------------------*/
+
void
-OptionEditor::sw_monitor_clicked ()
+OptionEditorMiniPage::add_to_page (OptionEditorPage* p)
{
- Config->set_no_sw_monitoring (!sw_monitor_button.get_active());
+ int const n = p->table.property_n_rows();
+ int m = n + 1;
+ if (!_note.empty ()) {
+ ++m;
+ }
+ p->table.resize (m, 3);
+ p->table.attach (box, 0, 3, n, n + 1, FILL | EXPAND, SHRINK, 0, 0);
+ maybe_add_note (p, n + 1);
}
-void
-OptionEditor::plugins_stop_with_transport_clicked ()
+/*--------------------------*/
+
+/** Construct an OptionEditor.
+ * @param o Configuration to edit.
+ * @param t Title for the dialog.
+ */
+OptionEditor::OptionEditor (PBD::Configuration* c)
+ : _config (c)
+ , option_tree (TreeStore::create (option_columns))
+ , option_treeview (option_tree)
{
- Config->set_plugins_stop_with_transport (plugins_stop_button.get_active());
+ using namespace Notebook_Helpers;
+
+ _notebook.set_show_tabs (false);
+ _notebook.set_show_border (true);
+ _notebook.set_name ("OptionsNotebook");
+
+ option_treeview.append_column ("", option_columns.name);
+ option_treeview.set_enable_search(true);
+ option_treeview.set_search_column(0);
+ option_treeview.set_name ("OptionsTreeView");
+ option_treeview.set_headers_visible (false);
+
+ option_treeview.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
+ option_treeview.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &OptionEditor::treeview_row_selected));
+
+ /* Watch out for changes to parameters */
+ _config->ParameterChanged.connect (config_connection, invalidator (*this), boost::bind (&OptionEditor::parameter_changed, this, _1), gui_context());
}
-void
-OptionEditor::plugins_on_while_recording_clicked ()
+OptionEditor::~OptionEditor ()
{
- if (session) {
- session->set_recording_plugins (plugins_on_rec_button.get_active());
+ for (std::map<std::string, OptionEditorPage*>::iterator i = _pages.begin(); i != _pages.end(); ++i) {
+ for (std::list<OptionEditorComponent*>::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::verify_remove_last_capture_clicked ()
+OptionEditor::parameter_changed (std::string const & p)
{
- Config->set_verify_remove_last_capture(verify_remove_last_capture_button.get_active());
+ ENSURE_GUI_THREAD (*this, &OptionEditor::parameter_changed, p)
+
+ for (std::map<std::string, OptionEditorPage*>::iterator i = _pages.begin(); i != _pages.end(); ++i) {
+ for (std::list<OptionEditorComponent*>::iterator j = i->second->components.begin(); j != i->second->components.end(); ++j) {
+ (*j)->parameter_changed (p);
+ }
+ }
}
void
-OptionEditor::stop_rec_on_xrun_clicked ()
+OptionEditor::treeview_row_selected ()
{
- Config->set_stop_recording_on_xrun (stop_rec_on_xrun_button.get_active());
-}
+ Glib::RefPtr<Gtk::TreeSelection> selection = option_treeview.get_selection();
+ TreeModel::iterator iter = selection->get_selected();
-void
-OptionEditor::stop_at_end_clicked ()
-{
- Config->set_stop_at_session_end (stop_at_end_button.get_active());
-}
-
-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 }
-};
+ if (iter) {
+ TreeModel::Row row = *iter;
+ Gtk::Widget* w = row[option_columns.widget];
+ if (w) {
+ _notebook.set_current_page (_notebook.page_num (*w));
+ }
+ }
+}
-void
-OptionEditor::setup_keyboard_options ()
+TreeModel::iterator
+OptionEditor::find_path_in_treemodel (std::string const & pn, bool create_missing)
{
- vector<string> dumb;
- Label* label;
+ /* split page name, which is actually a path, into each component */
- keyboard_mouse_table.set_border_width (12);
- keyboard_mouse_table.set_row_spacings (5);
- keyboard_mouse_table.set_col_spacings (5);
+ std::vector<std::string> components;
+ split (pn, components, '/');
- /* internationalize and prepare for use with combos */
+ /* start with top level children */
- for (int i = 0; modifiers[i].name; ++i) {
- dumb.push_back (_(modifiers[i].name));
- }
+ TreeModel::Children children = option_tree->children();
+ TreeModel::iterator iter;
- set_popdown_strings (edit_modifier_combo, dumb);
- edit_modifier_combo.get_popwin()->signal_unmap_event().connect (mem_fun(*this, &OptionEditor::edit_modifier_chosen));
+ /* foreach path component ... */
- for (int x = 0; modifiers[x].name; ++x) {
- if (modifiers[x].modifier == Keyboard::edit_modifier ()) {
- edit_modifier_combo.get_entry()->set_text (_(modifiers[x].name));
- break;
- }
- }
+ for (std::vector<std::string>::const_iterator s = components.begin(); s != components.end(); ++s) {
- 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, 0);
- keyboard_mouse_table.attach (edit_modifier_combo, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, 0);
-
- label = manage (new Label (_("+ button")));
- label->set_name ("OptionsLabel");
-
- keyboard_mouse_table.attach (*label, 3, 4, 0, 1, Gtk::FILL|Gtk::EXPAND, 0);
- keyboard_mouse_table.attach (edit_button_spin, 4, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, 0);
-
- edit_button_spin.set_name ("OptionsEntry");
- edit_button_adjustment.set_value (Keyboard::edit_button());
- edit_button_adjustment.value_changed.connect (mem_fun(*this, &OptionEditor::edit_button_changed));
-
- set_popdown_strings (delete_modifier_combo, dumb);
- delete_modifier_combo.get_popwin()->signal_unmap_event().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.get_entry()->set_text (_(modifiers[x].name));
- break;
+ for (iter = children.begin(); iter != children.end(); ++iter) {
+ TreeModel::Row row = *iter;
+ const std::string row_name = row[option_columns.name];
+ if (row_name == (*s)) {
+ break;
+ }
}
- }
- 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, 0);
- keyboard_mouse_table.attach (delete_modifier_combo, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, 0);
-
- label = manage (new Label (_("+ button")));
- label->set_name ("OptionsLabel");
-
- keyboard_mouse_table.attach (*label, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, 0);
- keyboard_mouse_table.attach (delete_button_spin, 4, 5, 1, 2, Gtk::FILL|Gtk::EXPAND, 0);
-
- delete_button_spin.set_name ("OptionsEntry");
- delete_button_adjustment.set_value (Keyboard::delete_button());
- delete_button_adjustment.value_changed.connect (mem_fun(*this, &OptionEditor::delete_button_changed));
-
- set_popdown_strings (snap_modifier_combo, dumb);
- snap_modifier_combo.get_popwin()->signal_unmap_event().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.get_entry()->set_text (_(modifiers[x].name));
- break;
+ if (iter == children.end()) {
+ /* the current component is missing; bail out or create it */
+ if (!create_missing) {
+ return option_tree->get_iter(TreeModel::Path(""));
+ } else {
+ iter = option_tree->append (children);
+ TreeModel::Row row = *iter;
+ row[option_columns.name] = *s;
+ row[option_columns.widget] = 0;
+ }
}
+
+ /* from now on, iter points to a valid row, either the one we found or a new one */
+ /* set children to the row's children to continue searching */
+ children = (*iter)->children ();
+
}
- 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, 0);
- keyboard_mouse_table.attach (snap_modifier_combo, 1, 2, 2, 3, Gtk::FILL|Gtk::EXPAND, 0);
+ return iter;
}
-gint
-OptionEditor::edit_modifier_chosen (GdkEventAny *ev)
+void
+OptionEditor::add_path_to_treeview (std::string const & pn, Gtk::Widget& widget)
{
- string txt;
-
- txt = edit_modifier_combo.get_entry()->get_text();
+ option_treeview.set_model (Glib::RefPtr<TreeStore>());
- for (int i = 0; modifiers[i].name; ++i) {
- if (txt == _(modifiers[i].name)) {
- Keyboard::set_edit_modifier (modifiers[i].modifier);
- break;
- }
- }
- return TRUE;
+ TreeModel::iterator row_iter = find_path_in_treemodel(pn, true);
+
+ assert(row_iter);
+
+ TreeModel::Row row = *row_iter;
+ row[option_columns.widget] = &widget;
+
+ option_treeview.set_model (option_tree);
+ option_treeview.expand_all ();
}
-gint
-OptionEditor::delete_modifier_chosen (GdkEventAny *ev)
+/** 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::add_option (std::string const & pn, OptionEditorComponent* o)
{
- string txt;
-
- txt = delete_modifier_combo.get_entry()->get_text();
+ if (_pages.find (pn) == _pages.end()) {
+ OptionEditorPage* oep = new OptionEditorPage (_notebook, pn);
+ _pages[pn] = oep;
- for (int i = 0; modifiers[i].name; ++i) {
- if (txt == _(modifiers[i].name)) {
- Keyboard::set_delete_modifier (modifiers[i].modifier);
- break;
- }
+ add_path_to_treeview (pn, oep->box);
}
- return TRUE;
+
+ OptionEditorPage* p = _pages[pn];
+ p->components.push_back (o);
+
+ o->add_to_page (p);
+ o->set_state_from_config ();
}
-gint
-OptionEditor::snap_modifier_chosen (GdkEventAny *ev)
+/** Add a new page
+ * @param pn Page name (will be created if it doesn't already exist)
+ * @param w widget that fills the page
+ */
+void
+OptionEditor::add_page (std::string const & pn, Gtk::Widget& w)
{
- string txt;
-
- txt = snap_modifier_combo.get_entry()->get_text();
-
- for (int i = 0; modifiers[i].name; ++i) {
- if (txt == _(modifiers[i].name)) {
- Keyboard::set_snap_modifier (modifiers[i].modifier);
- break;
- }
+ if (_pages.find (pn) == _pages.end()) {
+ OptionEditorPage* oep = new OptionEditorPage (_notebook, pn);
+ _pages[pn] = oep;
+ add_path_to_treeview (pn, oep->box);
}
- return TRUE;
+
+ OptionEditorPage* p = _pages[pn];
+ p->box.pack_start (w, true, true);
}
void
-OptionEditor::delete_button_changed ()
+OptionEditor::set_current_page (string const & p)
{
- Keyboard::set_delete_button ((guint) delete_button_adjustment.get_value());
+ TreeModel::iterator row_iter = find_path_in_treemodel(p);
+
+ if (row_iter) {
+ option_treeview.get_selection()->select(row_iter);
+ }
+
+}
+
+/*--------------------------*/
+
+DirectoryOption::DirectoryOption (string const & i, string const & n, sigc::slot<string> g, sigc::slot<bool, string> s)
+ : Option (i, n)
+ , _get (g)
+ , _set (s)
+{
+ _file_chooser.set_action (Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER);
+ _file_chooser.signal_selection_changed().connect (sigc::mem_fun (*this, &DirectoryOption::selection_changed));
}
void
-OptionEditor::edit_button_changed ()
+DirectoryOption::set_state_from_config ()
{
- Keyboard::set_edit_button ((guint) edit_button_adjustment.get_value());
+ _file_chooser.set_current_folder (poor_mans_glob(_get ()));
}
void
-OptionEditor::fixup_combo_size (Gtk::Combo& combo, vector<string>& strings)
+DirectoryOption::add_to_page (OptionEditorPage* p)
{
- /* find the widest string */
+ Gtk::Label *label = manage (new Label (_name));
+ label->set_alignment (0, 0.5);
+ label->set_name (X_("OptionsLabel"));
+ add_widgets_to_page (p, label, &_file_chooser);
+}
- string::size_type maxlen = 0;
- string maxstring;
+void
+DirectoryOption::selection_changed ()
+{
+ _set (poor_mans_glob(_file_chooser.get_filename ()));
+}
- for (vector<string>::iterator i = strings.begin(); i != strings.end(); ++i) {
- string::size_type l;
+/*--------------------------*/
- if ((l = (*i).length()) > maxlen) {
- maxlen = l;
- maxstring = *i;
- }
- }
+OptionEditorContainer::OptionEditorContainer (PBD::Configuration* c, string const& str)
+ : OptionEditor (c)
+{
+ set_border_width (4);
+ Frame* f = manage (new Frame ());
+ f->add (treeview());
+ f->set_shadow_type (Gtk::SHADOW_OUT);
+ f->set_border_width (0);
+ hpacker.pack_start (*f, false, false, 4);
+ hpacker.pack_start (notebook(), false, false);
+ pack_start (hpacker, true, true);
- /* try to include ascenders and descenders */
+ show_all ();
+}
- if (maxstring.length() > 2) {
- maxstring[0] = 'g';
- maxstring[1] = 'l';
- }
+OptionEditorWindow::OptionEditorWindow (PBD::Configuration* c, string const& str)
+ : OptionEditor (c)
+ , ArdourWindow (str)
+{
+ container.set_border_width (4);
+ Frame* f = manage (new Frame ());
+ f->add (treeview());
+ f->set_shadow_type (Gtk::SHADOW_OUT);
+ f->set_border_width (0);
+ hpacker.pack_start (*f, false, false);
+ hpacker.pack_start (notebook(), true, true, 4);
- const guint32 FUDGE = 10; // Combo's are stupid - they steal space from the entry for the button
+ container.pack_start (hpacker, true, true);
- set_size_request_to_display_given_text (*combo.get_entry(), maxstring.c_str(), 10 + FUDGE, 10);
-}
+ hpacker.show_all ();
+ container.show ();
-void
-OptionEditor::map_some_session_state (CheckButton& button, bool (Session::*get)() const)
-{
- if (session) {
- button.set_active ((session->*get)());
- }
+ add (container);
}
-