only the last step-edited note remains selected after each note addition; waf install...
[ardour.git] / gtk2_ardour / gain_meter.cc
index 950071ba1300083d72ec93243a6b0e139adceeca..b8a6ad2df9c07d899b1c4b036a0d27f509687147 100644 (file)
 #include "ardour/session.h"
 #include "ardour/session_route.h"
 #include "ardour/dB.h"
+#include "ardour/utils.h"
 
 #include <gtkmm/style.h>
 #include <gdkmm/color.h>
 #include <gtkmm2ext/utils.h>
 #include <gtkmm2ext/fastmeter.h>
-#include <gtkmm2ext/stop_signal.h>
 #include <gtkmm2ext/barcontroller.h>
 #include <gtkmm2ext/gtk_ui.h>
 #include "midi++/manager.h"
 
 #include "ardour_ui.h"
 #include "gain_meter.h"
-#include "utils.h"
 #include "logmeter.h"
 #include "gui_thread.h"
 #include "keyboard.h"
 #include "public_editor.h"
+#include "utils.h"
 
 #include "ardour/session.h"
 #include "ardour/route.h"
@@ -74,13 +74,11 @@ GainMeter::setup_slider_pix ()
        }
 }
 
-GainMeterBase::GainMeterBase (Session& s,
+GainMeterBase::GainMeterBase (Session* s,
                              const Glib::RefPtr<Gdk::Pixbuf>& pix,
                              bool horizontal,
                              int fader_length)
-       : _session (s)
-         // 0.781787 is the value needed for gain to be set to 0.
-       , gain_adjustment (0.781787, 0.0, 1.0, 0.01, 0.1)
+       : gain_adjustment (0.781787, 0.0, 1.0, 0.01, 0.1)  // 0.781787 is the value needed for gain to be set to 0.
        , gain_automation_style_button ("")
        , gain_automation_state_button ("")
        , dpi_changed (false)
@@ -89,6 +87,8 @@ GainMeterBase::GainMeterBase (Session& s,
 {
        using namespace Menu_Helpers;
 
+       set_session (s);
+
        ignore_toggle = false;
        meter_menu = 0;
        next_release_selects = false;
@@ -131,8 +131,8 @@ GainMeterBase::GainMeterBase (Session& s,
        gain_automation_style_button.set_name ("MixerAutomationModeButton");
        gain_automation_state_button.set_name ("MixerAutomationPlaybackButton");
 
-       ARDOUR_UI::instance()->tooltips().set_tip (gain_automation_state_button, _("Fader automation mode"));
-       ARDOUR_UI::instance()->tooltips().set_tip (gain_automation_style_button, _("Fader automation type"));
+       ARDOUR_UI::instance()->set_tip (gain_automation_state_button, _("Fader automation mode"));
+       ARDOUR_UI::instance()->set_tip (gain_automation_style_button, _("Fader automation type"));
 
        gain_automation_style_button.unset_flags (Gtk::CAN_FOCUS);
        gain_automation_state_button.unset_flags (Gtk::CAN_FOCUS);
@@ -170,6 +170,7 @@ GainMeterBase::set_controls (boost::shared_ptr<Route> r,
                             boost::shared_ptr<Amp> amp)
 {
        connections.clear ();
+       model_connections.drop_connections ();
 
        if (!pm && !amp) {
                level_meter->set_meter (0);
@@ -224,14 +225,14 @@ GainMeterBase::set_controls (boost::shared_ptr<Route> r,
                connections.push_back (gain_automation_state_button.signal_button_press_event().connect (sigc::mem_fun(*this, &GainMeterBase::gain_automation_state_button_event), false));
 
                boost::shared_ptr<AutomationControl> gc = amp->gain_control();
-
-               connections.push_back (gc->alist()->automation_state_changed.connect (sigc::mem_fun(*this, &GainMeter::gain_automation_state_changed)));
-               connections.push_back (gc->alist()->automation_style_changed.connect (sigc::mem_fun(*this, &GainMeter::gain_automation_style_changed)));
-
+               
+               gc->alist()->automation_state_changed.connect (model_connections, invalidator (*this), boost::bind (&GainMeter::gain_automation_state_changed, this), gui_context());
+               gc->alist()->automation_style_changed.connect (model_connections, invalidator (*this), boost::bind (&GainMeter::gain_automation_style_changed, this), gui_context());
+               
                gain_automation_state_changed ();
        }
-
-       connections.push_back (amp->gain_control()->Changed.connect (sigc::mem_fun (*this, &GainMeterBase::gain_changed)));
+       
+       amp->gain_control()->Changed.connect (model_connections, invalidator (*this), boost::bind (&GainMeterBase::gain_changed, this), gui_context());
 
        gain_changed ();
        show_gain ();
@@ -437,7 +438,7 @@ GainMeterBase::effective_gain_display ()
 void
 GainMeterBase::gain_changed ()
 {
-       Gtkmm2ext::UI::instance()->call_slot (boost::bind (&GainMeterBase::effective_gain_display, this));
+       Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&GainMeterBase::effective_gain_display, this));
 }
 
 void
@@ -518,7 +519,7 @@ GainMeterBase::meter_press(GdkEventButton* ev)
 
                                        /* Primary+Tertiary-click applies change to all routes */
 
-                                       _session.foreach_route (this, &GainMeterBase::set_meter_point, next_meter_point (_route->meter_point()));
+                                       _session->foreach_route (this, &GainMeterBase::set_meter_point, next_meter_point (_route->meter_point()));
 
 
                                } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
@@ -537,7 +538,7 @@ GainMeterBase::meter_press(GdkEventButton* ev)
 
                                        // XXX no undo yet
 
-                                       _route->set_meter_point (next_meter_point (_route->meter_point()), this);
+                                       _route->set_meter_point (next_meter_point (_route->meter_point()));
                                }
                        }
                }
@@ -566,7 +567,7 @@ GainMeterBase::meter_release(GdkEventButton*)
 void
 GainMeterBase::set_meter_point (Route& route, MeterPoint mp)
 {
-       route.set_meter_point (mp, this);
+       route.set_meter_point (mp);
 }
 
 void
@@ -575,9 +576,9 @@ GainMeterBase::set_mix_group_meter_point (Route& route, MeterPoint mp)
        RouteGroup* mix_group;
 
        if((mix_group = route.route_group()) != 0){
-               mix_group->apply (&Route::set_meter_point, mp, this);
+               mix_group->apply (&Route::set_meter_point, mp);
        } else {
-               route.set_meter_point (mp, this);
+               route.set_meter_point (mp);
        }
 }
 
@@ -787,7 +788,7 @@ GainMeterBase::on_theme_changed()
        style_changed = true;
 }
 
-GainMeter::GainMeter (Session& s, int fader_length)
+GainMeter::GainMeter (Session* s, int fader_length)
        : GainMeterBase (s, slider, false, fader_length)
 {
        gain_display_box.set_homogeneous (true);
@@ -800,8 +801,8 @@ GainMeter::GainMeter (Session& s, int fader_length)
        gain_automation_style_button.set_name ("MixerAutomationModeButton");
        gain_automation_state_button.set_name ("MixerAutomationPlaybackButton");
 
-       ARDOUR_UI::instance()->tooltips().set_tip (gain_automation_state_button, _("Fader automation mode"));
-       ARDOUR_UI::instance()->tooltips().set_tip (gain_automation_style_button, _("Fader automation type"));
+       ARDOUR_UI::instance()->set_tip (gain_automation_state_button, _("Fader automation mode"));
+       ARDOUR_UI::instance()->set_tip (gain_automation_style_button, _("Fader automation type"));
 
        gain_automation_style_button.unset_flags (Gtk::CAN_FOCUS);
        gain_automation_state_button.unset_flags (Gtk::CAN_FOCUS);