initial part of vca assignment via context menu
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 29 Feb 2016 19:45:03 +0000 (14:45 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 31 May 2016 19:30:38 +0000 (15:30 -0400)
gtk2_ardour/add_route_dialog.cc
gtk2_ardour/ardour_ui.cc
gtk2_ardour/ardour_ui.h
gtk2_ardour/mixer_strip.cc
gtk2_ardour/mixer_strip.h
gtk2_ardour/mixer_ui.cc
gtk2_ardour/vca_master_strip.cc
gtk2_ardour/vca_master_strip.h

index 79414f7cd0f6ee6d15382816d66a238cae6055c1..2b840ffd3a08cf8910e31e59ace92218e3ed12a3 100644 (file)
@@ -35,6 +35,7 @@
 #include "ardour/template_utils.h"
 #include "ardour/route_group.h"
 #include "ardour/session.h"
+#include "ardour/vca.h"
 
 #include "utils.h"
 #include "add_route_dialog.h"
@@ -264,7 +265,7 @@ AddRouteDialog::maybe_update_name_template_entry ()
                name_template_entry.set_text (_("Bus"));
                break;
        case VCAMaster:
-               name_template_entry.set_text (_("VCA"));
+               name_template_entry.set_text (VCA::default_name_template());
                break;
        }
 }
index 2b37ad8c3d27cf0fc46de50d1dcfc52c48d16992..1a5e131d3c614ed678581d7ec0fa05454b9b45ed 100644 (file)
@@ -1798,13 +1798,13 @@ ARDOUR_UI::open_session ()
 }
 
 void
-ARDOUR_UI::session_add_vca (const string& name_template)
+ARDOUR_UI::session_add_vca (const string& name_template, uint32_t n)
 {
        if (!_session) {
                return;
        }
 
-       _session->vca_manager().create_vca (name_template);
+       _session->vca_manager().create_vca (n, name_template);
 }
 
 void
@@ -4046,7 +4046,7 @@ ARDOUR_UI::add_route ()
                session_add_midi_bus (route_group, count, name_template, strict_io, instrument, 0);
                break;
        case AddRouteDialog::VCAMaster:
-               session_add_vca (name_template);
+               session_add_vca (name_template, count);
                break;
        }
 }
index cf6b400738b369dddbf1b7b6e0cd02f8e3a7ddfe..4227c5fb288d030e7b14ea140a68528be220f49c 100644 (file)
@@ -271,7 +271,7 @@ public:
        void flush_videotimeline_cache (bool localcacheonly=false);
        void export_video (bool range = false);
 
-       void session_add_vca (std::string const &);
+       void session_add_vca (std::string const &, uint32_t);
 
        void session_add_audio_track (
                int input_channels,
index c65a10b64414905803160364e7d85ea34a05a963..591b4f42507f9106060f74d125dd85b7a2c19733 100644 (file)
@@ -52,6 +52,8 @@
 #include "ardour/session.h"
 #include "ardour/types.h"
 #include "ardour/user_bundle.h"
+#include "ardour/vca.h"
+#include "ardour/vca_manager.h"
 
 #include "ardour_window.h"
 #include "mixer_strip.h"
@@ -217,9 +219,14 @@ MixerStrip::init ()
        for (uint32_t n = 0; n < n_vca_buttons; ++n) {
                ArdourButton* v = manage (new ArdourButton (ArdourButton::default_elements));
                vca_buttons.push_back (v); /* no ownership transfer, button is managed by its container */
-               vca_table.attach (*v, n, n+1, 0, 1);
+               v->set_no_show_all (true);
+               v->set_name (X_("vca assign"));
+               v->add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
+               v->signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &MixerStrip::vca_button_release), n), false);
+               UI::instance()->set_tip (*v, string_compose (_("VCA %1 assign"), n));
+               v->set_text (_("v."));
                v->show ();
-               v->set_text ("a");
+               vca_table.attach (*v, n, n+1, 0, 1);
        }
        vca_table.show ();
 
@@ -2483,3 +2490,48 @@ MixerStrip::set_meter_type (MeterType t)
        if (_suspend_menu_callbacks) return;
        gpm.set_type (t);
 }
+
+void
+MixerStrip::vca_menu_toggle (uint32_t n)
+{
+       if (!_route) {
+               return;
+       }
+
+       boost::shared_ptr<VCA> vca = _session->vca_manager().vca_by_number (n);
+
+       if (!vca) {
+               return;
+       }
+
+       vca->add (_route);
+}
+
+bool
+MixerStrip::vca_button_release (GdkEventButton* ev, uint32_t which)
+{
+       using namespace Gtk::Menu_Helpers;
+
+       if (!_session || !Keyboard::is_context_menu_event (ev)) {
+               return false;
+       }
+
+       VCAManager::VCAS vcas (_session->vca_manager().vcas());
+
+       if (vcas.empty()) {
+               /* XXX should probably show a message saying "No VCA masters" */
+               return true;
+       }
+
+       Menu* menu = new Menu;
+       MenuList& items = menu->items();
+       RadioMenuItem::Group group;
+
+       for (VCAManager::VCAS::iterator v = vcas.begin(); v != vcas.end(); ++v) {
+               items.push_back (RadioMenuElem (group, (*v)->name(), sigc::bind (sigc::mem_fun (*this, &MixerStrip::vca_menu_toggle), (*v)->number())));
+       }
+
+       menu->popup (1, ev->time);
+
+       return true;
+}
index df3b78dcd325329be227a529bcda0b2b054aff9d..1fbdb04120de1f176848dccb26d8246d9e839ece 100644 (file)
@@ -319,6 +319,9 @@ class MixerStrip : public RouteUI, public Gtk::EventBox
        PBD::ScopedConnection _level_meter_connection;
 
        std::string meter_point_string (ARDOUR::MeterPoint);
+
+       void vca_menu_toggle (uint32_t n);
+       bool vca_button_release (GdkEventButton* ev, uint32_t which);
 };
 
 #endif /* __ardour_mixer_strip__ */
index 5e45b9338c00e040302a7f266def9c485a9b344f..3efb1ce0f1e9b1b669eb56fbf7eedcae75dcc323 100644 (file)
@@ -368,7 +368,7 @@ Mixer_UI::show_window ()
 void
 Mixer_UI::add_masters (VCAList& vcas)
 {
-       cerr << "VCA added\n";
+       cerr << vcas.size() << " VCAs added\n";
 
        for (VCAList::iterator v = vcas.begin(); v != vcas.end(); ++v) {
 
@@ -1192,7 +1192,7 @@ Mixer_UI::redisplay_track_list ()
                if (vms) {
                        vca_packer.pack_start (*vms, false, false);
                        vms->show ();
-                       cerr << "Packed vca into vca_packer\n";
+                       cerr << "Packed vca " << vms->vca()->number() << " into vca_packer\n";
                        continue;
                }
 
index 7761b6f973f8655793dd060352c38957c2ea9bc0..038d995fb343fc25e818fd0e41ed35d3ec285244 100644 (file)
@@ -25,15 +25,15 @@ using std::string;
 
 VCAMasterStrip::VCAMasterStrip (Session* s, boost::shared_ptr<VCA> v)
        : AxisView (s)
-       , vca (v)
+       , _vca (v)
        , gain_meter (s, 250)
 {
        gain_meter.set_controls (boost::shared_ptr<Route>(),
                                 boost::shared_ptr<PeakMeter>(),
                                 boost::shared_ptr<Amp>(),
-                                vca->control());
+                                _vca->control());
 
-       name_button.set_text (vca->name());
+       name_button.set_text (_vca->name());
        active_button.set_text ("active");
 
        pack_start (active_button, false, false);
@@ -48,5 +48,5 @@ VCAMasterStrip::VCAMasterStrip (Session* s, boost::shared_ptr<VCA> v)
 string
 VCAMasterStrip::name() const
 {
-       return vca->name();
+       return _vca->name();
 }
index cef7290b9a5bc0b724c88f855cc2dcdf0efe6360..5043c6144e95bab5972ab0b195bddd2e1699e023 100644 (file)
@@ -39,9 +39,10 @@ class VCAMasterStrip : public AxisView, public Gtk::VBox
 
        std::string name() const;
        std::string state_id() const { return "VCAMasterStrip"; }
+       boost::shared_ptr<ARDOUR::VCA> vca() const { return _vca; }
 
       private:
-       boost::shared_ptr<ARDOUR::VCA> vca;
+       boost::shared_ptr<ARDOUR::VCA> _vca;
        ArdourButton name_button;
        ArdourButton active_button;
        GainMeter    gain_meter;