From 84be4eafc5228eacfed02f78489fa82d401c2947 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 28 Jun 2011 16:55:41 +0000 Subject: basic infrastructure for enabling/disabling MIDI input to a given track git-svn-id: svn://localhost/ardour2/branches/3.0@9772 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/ardour3_widget_list.rc | 2 +- gtk2_ardour/icons/midi_socket_small.png | Bin 0 -> 751 bytes gtk2_ardour/mixer_strip.cc | 54 +++++++++++++++++++++++++++++--- gtk2_ardour/mixer_strip.h | 5 +++ 4 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 gtk2_ardour/icons/midi_socket_small.png (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/ardour3_widget_list.rc b/gtk2_ardour/ardour3_widget_list.rc index e85532515d..68bd29dfeb 100644 --- a/gtk2_ardour/ardour3_widget_list.rc +++ b/gtk2_ardour/ardour3_widget_list.rc @@ -399,7 +399,7 @@ widget "*TimeInfoSelectionLabel" style:highest "very_small_bright_when_active" widget "*TimeInfoPunchTitle" style:highest "very_small_bright_when_active" widget "*TimeInfoPunchLabel" style:highest "very_small_bright_when_active" widget "*TimeInfoPunchButton" style:highest "punch_button" - widget "*RouteNameEditorEntry" style:highest "text_cell_entry" widget "*RegionNameEditorEntry" style:highest "text_cell_entry" +widget "*MixerMidiInputEnableButton" style:highest "mouse_mode_button" diff --git a/gtk2_ardour/icons/midi_socket_small.png b/gtk2_ardour/icons/midi_socket_small.png new file mode 100644 index 0000000000..2ed5039a8c Binary files /dev/null and b/gtk2_ardour/icons/midi_socket_small.png differ diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index 39f8b4580d..4211e30953 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -40,6 +40,7 @@ #include "ardour/route.h" #include "ardour/route_group.h" #include "ardour/audio_track.h" +#include "ardour/midi_track.h" #include "ardour/pannable.h" #include "ardour/panner.h" #include "ardour/panner_shell.h" @@ -89,6 +90,7 @@ MixerStrip::MixerStrip (Mixer_UI& mx, Session* sess, bool in_mixer) , middle_button_table (1, 2) , bottom_button_table (1, 2) , meter_point_label (_("pre")) + , midi_input_enable_button (0) { init (); @@ -113,6 +115,7 @@ MixerStrip::MixerStrip (Mixer_UI& mx, Session* sess, boost::shared_ptr rt , middle_button_table (1, 2) , bottom_button_table (1, 2) , meter_point_label (_("pre")) + , midi_input_enable_button (0) { init (); set_route (rt); @@ -153,8 +156,7 @@ MixerStrip::init () input_button.add (input_label); input_button.set_name ("MixerIOButton"); input_label.set_name ("MixerIOButtonLabel"); - - Gtkmm2ext::set_size_request_to_display_given_text (input_button, longest_label.c_str(), 4, 4); + input_button_box.pack_start (input_button, true, true); output_label.set_text (_("Output")); ARDOUR_UI::instance()->set_tip (&output_button, _("Button 1 to choose outputs from a port matrix, button 3 to select inputs from a menu"), ""); @@ -227,7 +229,7 @@ MixerStrip::init () button_table.set_spacings (0); button_table.attach (name_button, 0, 1, 0, 1); - button_table.attach (input_button, 0, 1, 1, 2); + button_table.attach (input_button_box, 0, 1, 1, 2); button_table.attach (_invert_button_box, 0, 1, 2, 3); middle_button_table.set_homogeneous (true); @@ -399,6 +401,26 @@ MixerStrip::set_route (boost::shared_ptr rt) global_vpacker.pack_start (*spacer, false, false); } + if (is_midi_track()) { + if (midi_input_enable_button == 0) { + Image* img = manage (new Image (get_icon (X_("midi_socket_small")))); + midi_input_enable_button = manage (new ToggleButton); + midi_input_enable_button->set_name ("MixerMidiInputEnableButton"); + midi_input_enable_button->set_image (*img); + midi_input_enable_button->signal_toggled().connect (sigc::mem_fun (*this, &MixerStrip::midi_input_toggled)); + ARDOUR_UI::instance()->set_tip (midi_input_enable_button, _("Enable/Disable MIDI input")); + } + /* get current state */ + midi_input_status_changed (); + input_button_box.pack_start (*midi_input_enable_button, false, false); + } else { + if (midi_input_enable_button) { + /* removal from the container will delete it */ + input_button_box.remove (*midi_input_enable_button); + midi_input_enable_button = 0; + } + } + if (is_audio_track()) { boost::shared_ptr at = audio_track(); at->FreezeChange.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::map_frozen, this), gui_context()); @@ -486,8 +508,7 @@ MixerStrip::set_route (boost::shared_ptr rt) meter_point_label.show(); diskstream_button.show(); diskstream_label.show(); - input_button.show(); - input_label.show(); + input_button_box.show_all(); output_button.show(); output_label.show(); name_label.show(); @@ -1891,3 +1912,26 @@ MixerStrip::hide_things () { processor_box.hide_things (); } + +void +MixerStrip::midi_input_toggled () +{ + boost::shared_ptr mt = midi_track (); + + if (!mt) { + return; + } + + mt->set_input_active (midi_input_enable_button->get_active()); +} + +void +MixerStrip::midi_input_status_changed () +{ + if (midi_input_enable_button) { + boost::shared_ptr mt = midi_track (); + assert (mt); + cerr << "track input active? " << mt->input_active() << endl; + midi_input_enable_button->set_active (mt->input_active ()); + } +} diff --git a/gtk2_ardour/mixer_strip.h b/gtk2_ardour/mixer_strip.h index a24df01696..fa101513b9 100644 --- a/gtk2_ardour/mixer_strip.h +++ b/gtk2_ardour/mixer_strip.h @@ -178,12 +178,17 @@ class MixerStrip : public RouteUI, public Gtk::EventBox Gtk::Label diskstream_label; Gtk::Button input_button; + Gtk::ToggleButton* midi_input_enable_button; + Gtk::HBox input_button_box; Gtk::Label input_label; Gtk::Button output_button; Gtk::Label output_label; std::string longest_label; + void midi_input_status_changed (); + void midi_input_toggled (); + gint mark_update_safe (); guint32 mode_switch_in_progress; -- cgit v1.2.3