colinf's vertical double arrow track resize cursor patch
[ardour.git] / gtk2_ardour / gain_meter.cc
index 950071ba1300083d72ec93243a6b0e139adceeca..e391bc59336909db8c9679dd7f7a042fa3fd1dd9 100644 (file)
@@ -26,6 +26,7 @@
 #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 "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 +75,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 +88,8 @@ GainMeterBase::GainMeterBase (Session& s,
 {
        using namespace Menu_Helpers;
 
+       set_session (s);
+
        ignore_toggle = false;
        meter_menu = 0;
        next_release_selects = false;
@@ -131,8 +132,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 +171,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 +226,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, boost::bind (&GainMeter::gain_automation_state_changed, this), gui_context());
+               gc->alist()->automation_style_changed.connect (model_connections, 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, boost::bind (&GainMeterBase::gain_changed, this), gui_context());
 
        gain_changed ();
        show_gain ();
@@ -518,7 +520,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)) {
@@ -787,7 +789,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 +802,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);