From e48ec558935d839de7b198a88745d57463d117cd Mon Sep 17 00:00:00 2001 From: Valeriy Kamyshniy Date: Mon, 12 May 2014 09:21:16 -0500 Subject: [PATCH] Implementing MIDI Device Connection Control [git-p4: depot-paths = "//Abdaw/dev_main/tracks/": change = 459708] --- gtk2_ardour/device_connection_control.cc | 61 ++++++++++++--- gtk2_ardour/device_connection_control.h | 3 + gtk2_ardour/tracks_control_panel.cc | 2 + gtk2_ardour/tracks_control_panel.h | 2 + gtk2_ardour/tracks_control_panel.logic.cc | 37 +++++++++- gtk2_ardour/tracks_control_panel.logic.h | 4 + ..._conrol.xml => device_capture_control.xml} | 0 gtk2_ardour/ui/midi_capture_control.xml | 33 +++++++++ gtk2_ardour/ui/midi_playback_control.xml | 26 +++++++ gtk2_ardour/ui/tracks_preferences.xml | 74 ++++++++++--------- 10 files changed, 193 insertions(+), 49 deletions(-) rename gtk2_ardour/ui/{device_capture_conrol.xml => device_capture_control.xml} (100%) create mode 100644 gtk2_ardour/ui/midi_capture_control.xml create mode 100644 gtk2_ardour/ui/midi_playback_control.xml diff --git a/gtk2_ardour/device_connection_control.cc b/gtk2_ardour/device_connection_control.cc index 1461e4df9e..75967c187f 100644 --- a/gtk2_ardour/device_connection_control.cc +++ b/gtk2_ardour/device_connection_control.cc @@ -27,8 +27,9 @@ DeviceConnectionControl::DeviceConnectionControl (std::string device_capture_nam , _active_off_button (NULL) , _name_label (NULL) , _track_name_label (NULL) + , _number_label (NULL) { - build_layout("device_capture_connection_conrol.xml"); + build_layout("device_capture_control.xml"); _active_on_button = &_children.get_waves_button ("capture_on_button"); _active_off_button = &_children.get_waves_button ("capture_off_button"); _name_label = &_children.get_label ("capture_name_label"); @@ -44,8 +45,9 @@ DeviceConnectionControl::DeviceConnectionControl (std::string device_playback_na , _active_off_button (NULL) , _name_label (NULL) , _track_name_label (NULL) + , _number_label (NULL) { - build_layout("device_playback_connection_conrol.xml"); + build_layout("device_playback_control.xml"); _active_on_button = &_children.get_waves_button ("playback_on_button"); _active_off_button = &_children.get_waves_button ("playback_off_button"); _name_label = &_children.get_label ("playback_name_label"); @@ -53,15 +55,54 @@ DeviceConnectionControl::DeviceConnectionControl (std::string device_playback_na init(device_playback_name, active, playback_number); } +DeviceConnectionControl::DeviceConnectionControl (std::string midi_capture_name, bool active) + + : Gtk::Layout() + , _active_on_button (NULL) + , _active_off_button (NULL) + , _name_label (NULL) + , _track_name_label (NULL) + , _number_label (NULL) +{ + build_layout("midi_capture_control.xml"); + _active_on_button = &_children.get_waves_button ("capture_on_button"); + _active_off_button = &_children.get_waves_button ("capture_off_button"); + _name_label = &_children.get_label ("capture_name_label"); + init(midi_capture_name, active, NoNumber); +} + +DeviceConnectionControl::DeviceConnectionControl (bool active) + + : Gtk::Layout() + , _active_on_button (NULL) + , _active_off_button (NULL) + , _name_label (NULL) + , _track_name_label (NULL) + , _number_label (NULL) +{ + build_layout("midi_playback_control.xml"); + _active_on_button = &_children.get_waves_button ("playback_on_button"); + _active_off_button = &_children.get_waves_button ("playback_off_button"); + init("", active, NoNumber); +} + void DeviceConnectionControl::init(std::string name, bool active, uint16_t number, std::string track_name) { _active_on_button->signal_clicked.connect (sigc::mem_fun (*this, &DeviceConnectionControl::on_active_on)); _active_off_button->signal_clicked.connect (sigc::mem_fun (*this, &DeviceConnectionControl::on_active_off)); - _name_label->set_text (name); - _number_label->set_text(PBD::to_string (number, std::dec)); + + if (_name_label != NULL) { + _name_label->set_text (name); + } + + if (_number_label != NULL) { + _number_label->set_text(PBD::to_string (number, std::dec)); + } + if (_track_name_label != NULL) { _track_name_label->set_text (track_name); } + _active_on_button->set_active (active); _active_off_button->set_active (!active); } @@ -86,11 +127,13 @@ DeviceConnectionControl::build_layout (std::string file_name) void DeviceConnectionControl::set_number (uint16_t number) { - if (number == DeviceConnectionControl::NoNumber) { - _number_label->get_parent()->hide (); - } else { - _number_label->get_parent()->show (); - _number_label->set_text(PBD::to_string (number, std::dec)); + if (_number_label != NULL) { + if (number == NoNumber) { + _number_label->get_parent()->hide (); + } else { + _number_label->get_parent()->show (); + _number_label->set_text(PBD::to_string (number, std::dec)); + } } } diff --git a/gtk2_ardour/device_connection_control.h b/gtk2_ardour/device_connection_control.h index 1968fc392d..28ba9c6c0b 100644 --- a/gtk2_ardour/device_connection_control.h +++ b/gtk2_ardour/device_connection_control.h @@ -35,6 +35,9 @@ class DeviceConnectionControl : public Gtk::Layout DeviceConnectionControl (std::string device_capture_name, bool active, uint16_t capture_number, std::string track_name); DeviceConnectionControl (std::string device_playback_name, bool active, uint16_t playback_number); + DeviceConnectionControl (std::string midi_capture_name, bool active); + DeviceConnectionControl (bool active); + bool build_layout (std::string file_name); void set_number (uint16_t number); void set_active (bool active); diff --git a/gtk2_ardour/tracks_control_panel.cc b/gtk2_ardour/tracks_control_panel.cc index 2dab48aa37..cd77822959 100644 --- a/gtk2_ardour/tracks_control_panel.cc +++ b/gtk2_ardour/tracks_control_panel.cc @@ -63,6 +63,8 @@ TracksControlPanel::TracksControlPanel () : WavesDialog ("tracks_preferences.xml") , _device_capture_list (named_children ().get_vbox("device_capture_list")) , _device_playback_list (named_children ().get_vbox("device_playback_list")) + , _midi_capture_list (named_children ().get_vbox("midi_capture_list")) + , _midi_playback_list (named_children ().get_vbox("midi_playback_list")) , _audio_settings_layout (named_children ().get_layout ("audio_settings_layout")) , _midi_settings_layout (named_children ().get_layout ("midi_settings_layout")) , _session_settings_layout (named_children ().get_layout ("session_settings_layout")) diff --git a/gtk2_ardour/tracks_control_panel.h b/gtk2_ardour/tracks_control_panel.h index 91adddc462..bc04668166 100644 --- a/gtk2_ardour/tracks_control_panel.h +++ b/gtk2_ardour/tracks_control_panel.h @@ -42,6 +42,8 @@ class TracksControlPanel : public WavesDialog, public PBD::ScopedConnectionList private: Gtk::VBox& _device_capture_list; Gtk::VBox& _device_playback_list; + Gtk::VBox& _midi_capture_list; + Gtk::VBox& _midi_playback_list; Gtk::Layout& _audio_settings_layout; Gtk::Layout& _midi_settings_layout; Gtk::Layout& _session_settings_layout; diff --git a/gtk2_ardour/tracks_control_panel.logic.cc b/gtk2_ardour/tracks_control_panel.logic.cc index 01ea467bdd..76e1582eab 100644 --- a/gtk2_ardour/tracks_control_panel.logic.cc +++ b/gtk2_ardour/tracks_control_panel.logic.cc @@ -70,8 +70,6 @@ TracksControlPanel::init () _buffer_size_combo.signal_changed().connect (sigc::mem_fun (*this, &TracksControlPanel::buffer_size_changed)); populate_engine_combo (); - _midi_settings_layout.hide (); - _session_settings_layout.hide (); _audio_settings_tab_button.set_active(true); _multi_out_button.set_active(ARDOUR::Config->get_output_auto_connect() & ARDOUR::AutoConnectPhysical); _stereo_out_button.set_active(ARDOUR::Config->get_output_auto_connect() & ARDOUR::AutoConnectMaster); @@ -93,6 +91,22 @@ DeviceConnectionControl& TracksControlPanel::add_device_playback_control(std::st return playback_control; } +DeviceConnectionControl& TracksControlPanel::add_midi_capture_control(std::string device_capture_name, bool active) +{ + DeviceConnectionControl &capture_control = *manage (new DeviceConnectionControl(device_capture_name, active)); + _midi_capture_list.pack_start (capture_control, false, false); + capture_control.signal_active_changed.connect (sigc::mem_fun (*this, &TracksControlPanel::on_midi_capture_active_changed)); + return capture_control; +} + +DeviceConnectionControl& TracksControlPanel::add_midi_playback_control(bool active) +{ + DeviceConnectionControl &playback_control = *manage (new DeviceConnectionControl(active)); + _midi_playback_list.pack_start (playback_control, false, false); + playback_control.signal_active_changed.connect(sigc::mem_fun (*this, &TracksControlPanel::on_midi_playback_active_changed)); + return playback_control; +} + void TracksControlPanel::populate_engine_combo() { @@ -225,11 +239,16 @@ TracksControlPanel::on_control_panel(WavesButton*) number++; active = !active; - std::string name = string_compose (_("Input %1"), number); + std::string name = string_compose (_("Audio Capture %1"), number); add_device_capture_control (name, active, number, name); - name = string_compose (_("Output %1"), number); + name = string_compose (_("Audio Playback Output %1"), number); add_device_playback_control (name, active, number); + + name = string_compose (_("Midi Capture %1"), number); + add_midi_capture_control (name, active); + + add_midi_playback_control (active); } void TracksControlPanel::engine_changed () @@ -523,6 +542,16 @@ void TracksControlPanel::on_playback_active_changed(DeviceConnectionControl* pla } +void TracksControlPanel::on_midi_capture_active_changed(DeviceConnectionControl* capture_control, bool active) +{ +} + + +void TracksControlPanel::on_midi_playback_active_changed(DeviceConnectionControl* playback_control, bool active) +{ +} + + std::string TracksControlPanel::bufsize_as_string (uint32_t sz) { diff --git a/gtk2_ardour/tracks_control_panel.logic.h b/gtk2_ardour/tracks_control_panel.logic.h index 45a134a42a..2333be96d6 100644 --- a/gtk2_ardour/tracks_control_panel.logic.h +++ b/gtk2_ardour/tracks_control_panel.logic.h @@ -73,6 +73,8 @@ virtual void init(); DeviceConnectionControl& add_device_capture_control(std::string device_capture_name, bool active, uint16_t capture_number, std::string track_name); DeviceConnectionControl& add_device_playback_control(std::string device_playback_name, bool active, uint16_t playback_number); + DeviceConnectionControl& add_midi_capture_control(std::string device_capture_name, bool active); + DeviceConnectionControl& add_midi_playback_control(bool active); void on_audio_settings (WavesButton*); void on_midi_settings (WavesButton*); @@ -85,6 +87,8 @@ void on_apply(WavesButton*); void on_capture_active_changed (DeviceConnectionControl* capture_control, bool active); void on_playback_active_changed (DeviceConnectionControl* playback_control, bool active); + void on_midi_capture_active_changed (DeviceConnectionControl* capture_control, bool active); + void on_midi_playback_active_changed (DeviceConnectionControl* playback_control, bool active); void engine_changed (); void device_changed (); diff --git a/gtk2_ardour/ui/device_capture_conrol.xml b/gtk2_ardour/ui/device_capture_control.xml similarity index 100% rename from gtk2_ardour/ui/device_capture_conrol.xml rename to gtk2_ardour/ui/device_capture_control.xml diff --git a/gtk2_ardour/ui/midi_capture_control.xml b/gtk2_ardour/ui/midi_capture_control.xml new file mode 100644 index 0000000000..136b5098e4 --- /dev/null +++ b/gtk2_ardour/ui/midi_capture_control.xml @@ -0,0 +1,33 @@ + + +