From ce525ae440d7707304cd2233be929cbbc64b4943 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 16 Nov 2009 02:18:51 +0000 Subject: Neaten up option editor layouts a bit. git-svn-id: svn://localhost/ardour2/branches/3.0@6095 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/option_editor.cc | 2 +- gtk2_ardour/option_editor.h | 4 +- gtk2_ardour/rc_option_editor.cc | 148 +++++++++++++++------------------------- gtk2_ardour/rc_option_editor.h | 2 +- 4 files changed, 58 insertions(+), 98 deletions(-) diff --git a/gtk2_ardour/option_editor.cc b/gtk2_ardour/option_editor.cc index bc3691dff4..c2937acec2 100644 --- a/gtk2_ardour/option_editor.cc +++ b/gtk2_ardour/option_editor.cc @@ -42,7 +42,7 @@ OptionEditorComponent::add_widgets_to_page (OptionEditorPage* p, Gtk::Widget* wa { int const n = p->table.property_n_rows(); p->table.resize (n + 1, 3); - p->table.attach (*wa, 1, 2, n, n + 1, FILL | EXPAND); + p->table.attach (*wa, 1, 2, n, n + 1, FILL); p->table.attach (*wb, 2, 3, n, n + 1, FILL | EXPAND); } diff --git a/gtk2_ardour/option_editor.h b/gtk2_ardour/option_editor.h index fb6663e3f9..b584338471 100644 --- a/gtk2_ardour/option_editor.h +++ b/gtk2_ardour/option_editor.h @@ -201,7 +201,7 @@ public: _set (s) { _label = manage (new Gtk::Label (n + ":")); - _label->set_alignment (1, 0.5); + _label->set_alignment (0, 0.5); _combo = manage (new Gtk::ComboBoxText); _combo->signal_changed().connect (sigc::mem_fun (*this, &ComboOption::changed)); } @@ -292,7 +292,7 @@ public: _scale (scale) { _label = manage (new Gtk::Label (n + ":")); - _label->set_alignment (1, 0.5); + _label->set_alignment (0, 0.5); _spin = manage (new Gtk::SpinButton); _spin->set_range (min, max); diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc index 507cd7ae41..acf4c06db4 100644 --- a/gtk2_ardour/rc_option_editor.cc +++ b/gtk2_ardour/rc_option_editor.cc @@ -27,9 +27,10 @@ using namespace ARDOUR; class MIDIPorts : public OptionEditorBox { public: - MIDIPorts (RCConfiguration* c) + MIDIPorts (RCConfiguration* c, list* > const & o) : _rc_config (c), - _add_port_button (Stock::ADD) + _add_port_button (Stock::ADD), + _port_combos (o) { _store = ListStore::create (_model); _view.set_model (_store); @@ -51,87 +52,15 @@ public: _box->pack_start (*h); - Table* t = manage (new Table (2, 4)); - t->set_spacings (12); - - int n = 0; - Label* l = manage (new Label (_("Receive MTC via:"))); - l->set_alignment (1, 0.5); - t->attach (*l, 0, 1, n, n + 1, EXPAND | FILL, FILL); - t->attach (_mtc_combo, 1, 2, n, n + 1, EXPAND | FILL, EXPAND | FILL); - ++n; - - l = manage (new Label (_("Receive MIDI clock via:"))); - l->set_alignment (1, 0.5); - t->attach (*l, 0, 1, n, n + 1, FILL, FILL); - t->attach (_midi_clock_combo, 1, 2, n, n + 1, FILL, FILL); - ++n; - - l = manage (new Label (_("Receive MMC via:"))); - l->set_alignment (1, 0.5); - t->attach (*l, 0, 1, n, n + 1, FILL, FILL); - t->attach (_mmc_combo, 1, 2, n, n + 1, FILL, FILL); - ++n; - - l = manage (new Label (_("Receive MIDI parameter control via:"))); - l->set_alignment (1, 0.5); - t->attach (*l, 0, 1, n, n + 1, FILL, FILL); - t->attach (_mpc_combo, 1, 2, n, n + 1, FILL, FILL); - ++n; - - _box->pack_start (*t, true, true); - ports_changed (); _store->signal_row_changed().connect (mem_fun (*this, &MIDIPorts::model_changed)); _add_port_button.signal_clicked().connect (mem_fun (*this, &MIDIPorts::add_port_clicked)); - _mtc_combo.signal_changed().connect (mem_fun (*this, &MIDIPorts::mtc_combo_changed)); - _mmc_combo.signal_changed().connect (mem_fun (*this, &MIDIPorts::mmc_combo_changed)); - _mpc_combo.signal_changed().connect (mem_fun (*this, &MIDIPorts::mpc_combo_changed)); - _midi_clock_combo.signal_changed().connect (mem_fun (*this, &MIDIPorts::midi_clock_combo_changed)); - } - - void parameter_changed (string const & p) - { - if (p == "mtc-port-name") { - _mtc_combo.set_active_text (_rc_config->get_mtc_port_name()); - } else if (p == "mmc-port-name") { - _mmc_combo.set_active_text (_rc_config->get_mmc_port_name()); - } else if (p == "midi-port-name") { - _mpc_combo.set_active_text (_rc_config->get_midi_port_name()); - } else if (p == "midi-clock-port-name") { - _midi_clock_combo.set_active_text (_rc_config->get_midi_clock_port_name()); - } - } - - void set_state_from_config () - { - parameter_changed ("mtc-port-name"); - parameter_changed ("mmc-port-name"); - parameter_changed ("midi-port-name"); - parameter_changed ("midi-clock-port-name"); - } - - void mtc_combo_changed () - { - _rc_config->set_mtc_port_name (_mtc_combo.get_active_text()); - } - - void mmc_combo_changed () - { - _rc_config->set_mmc_port_name (_mmc_combo.get_active_text()); - } - - void mpc_combo_changed () - { - _rc_config->set_midi_port_name (_mpc_combo.get_active_text()); } - void midi_clock_combo_changed () - { - _rc_config->set_midi_clock_port_name (_midi_clock_combo.get_active_text()); - } + void parameter_changed (string const &) {} + void set_state_from_config () {} private: @@ -162,19 +91,16 @@ private: } } - - - } - void setup_ports_combo (ComboBoxText& c) + void setup_ports_combo (ComboOption* c) { - c.clear_items (); + c->clear (); MIDI::Manager::PortList const & ports = MIDI::Manager::instance()->get_midi_ports (); for (MIDI::Manager::PortList::const_iterator i = ports.begin(); i != ports.end(); ++i) { - c.append_text ((*i)->name()); + c->add ((*i)->name(), (*i)->name()); } - } + } void ports_changed () { @@ -202,10 +128,9 @@ private: r[_model.port] = (*i); } - setup_ports_combo (_mtc_combo); - setup_ports_combo (_midi_clock_combo); - setup_ports_combo (_mmc_combo); - setup_ports_combo (_mpc_combo); + for (list* >::iterator i = _port_combos.begin(); i != _port_combos.end(); ++i) { + setup_ports_combo (*i); + } } void port_offline_changed (MIDI::Port* p) @@ -290,6 +215,7 @@ private: ComboBoxText _midi_clock_combo; ComboBoxText _mmc_combo; ComboBoxText _mpc_combo; + list* > _port_combos; }; @@ -304,7 +230,7 @@ public: t->set_spacings (4); Label* l = manage (new Label (_("Click audio file:"))); - l->set_alignment (1, 0.5); + l->set_alignment (0, 0.5); t->attach (*l, 0, 1, 0, 1, FILL); t->attach (_click_path_entry, 1, 2, 0, 1, FILL); Button* b = manage (new Button (_("Browse..."))); @@ -312,7 +238,7 @@ public: t->attach (*b, 2, 3, 0, 1, FILL); l = manage (new Label (_("Click emphasis audio file:"))); - l->set_alignment (1, 0.5); + l->set_alignment (0, 0.5); t->attach (*l, 0, 1, 1, 2, FILL); t->attach (_click_emphasis_path_entry, 1, 2, 1, 2, FILL); b = manage (new Button (_("Browse..."))); @@ -544,7 +470,7 @@ public: Label* l = manage (new Label (_("Edit using:"))); l->set_name ("OptionsLabel"); - l->set_alignment (1.0, 0.5); + l->set_alignment (0, 0.5); t->attach (*l, 0, 1, 0, 1, FILL | EXPAND, FILL); t->attach (_edit_modifier_combo, 1, 2, 0, 1, FILL | EXPAND, FILL); @@ -571,7 +497,7 @@ public: l = manage (new Label (_("Delete using:"))); l->set_name ("OptionsLabel"); - l->set_alignment (1.0, 0.5); + l->set_alignment (0, 0.5); t->attach (*l, 0, 1, 1, 2, FILL | EXPAND, FILL); t->attach (_delete_modifier_combo, 1, 2, 1, 2, FILL | EXPAND, FILL); @@ -598,7 +524,7 @@ public: l = manage (new Label (_("Toggle snap using:"))); l->set_name ("OptionsLabel"); - l->set_alignment (1.0, 0.5); + l->set_alignment (0, 0.5); t->attach (*l, 0, 1, 2, 3, FILL | EXPAND, FILL); t->attach (_snap_modifier_combo, 1, 2, 2, 3, FILL | EXPAND, FILL); @@ -615,7 +541,7 @@ public: l = manage (new Label (_("Keyboard layout:"))); l->set_name ("OptionsLabel"); - l->set_alignment (1.0, 0.5); + l->set_alignment (0, 0.5); t->attach (*l, 0, 1, 3, 4, FILL | EXPAND, FILL); t->attach (_keyboard_layout_selector, 1, 2, 3, 4, FILL | EXPAND, FILL); @@ -1334,7 +1260,41 @@ RCOptionEditor::RCOptionEditor () /* MIDI CONTROL */ - add_option (_("MIDI control"), new MIDIPorts (_rc_config)); + list* > midi_combos; + + midi_combos.push_back (new ComboOption ( + "mtc-port-name", + _("Receive MTC via"), + mem_fun (*_rc_config, &RCConfiguration::get_mtc_port_name), + mem_fun (*_rc_config, &RCConfiguration::set_mtc_port_name) + )); + + midi_combos.push_back (new ComboOption ( + "midi-clock-port-name", + _("Receive MIDI clock via"), + mem_fun (*_rc_config, &RCConfiguration::get_midi_clock_port_name), + mem_fun (*_rc_config, &RCConfiguration::set_midi_clock_port_name) + )); + + midi_combos.push_back (new ComboOption ( + "mmc-port-name", + _("Receive MMC via"), + mem_fun (*_rc_config, &RCConfiguration::get_mmc_port_name), + mem_fun (*_rc_config, &RCConfiguration::set_mmc_port_name) + )); + + midi_combos.push_back (new ComboOption ( + "midi-port-name", + _("Receive MIDI parameter control via"), + mem_fun (*_rc_config, &RCConfiguration::get_midi_port_name), + mem_fun (*_rc_config, &RCConfiguration::set_midi_port_name) + )); + + add_option (_("MIDI control"), new MIDIPorts (_rc_config, midi_combos)); + + for (list* >::iterator i = midi_combos.begin(); i != midi_combos.end(); ++i) { + add_option (_("MIDI control"), *i); + } add_option (_("MIDI control"), new SpinOption ( diff --git a/gtk2_ardour/rc_option_editor.h b/gtk2_ardour/rc_option_editor.h index 6ad1e1b11c..c0b558fac1 100644 --- a/gtk2_ardour/rc_option_editor.h +++ b/gtk2_ardour/rc_option_editor.h @@ -1,7 +1,7 @@ #include "option_editor.h" /** @file rc_option_editor.h - * @brief Editing of options which are obtained from and written back to one of the .rc files. + * @brief Editing of options which are obtained from and written back to one of the .rc files. * * This is subclassed from OptionEditor. Simple options (e.g. boolean and simple choices) * are expressed using subclasses of Option. More complex UI elements are represented -- cgit v1.2.3