#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"
using namespace PBD;
using namespace Gtkmm2ext;
using namespace Gtk;
-using namespace sigc;
using namespace std;
+using Gtkmm2ext::Keyboard;
sigc::signal<void> GainMeterBase::ResetAllPeakDisplays;
sigc::signal<void,RouteGroup*> GainMeterBase::ResetGroupPeakDisplays;
}
}
-GainMeterBase::GainMeterBase (Session& s,
+GainMeterBase::GainMeterBase (Session* s,
const Glib::RefPtr<Gdk::Pixbuf>& pix,
- bool horizontal)
- : _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)
+ bool horizontal,
+ int fader_length)
+ : 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)
, _is_midi (false)
-
+
{
using namespace Menu_Helpers;
+ set_session (s);
+
ignore_toggle = false;
meter_menu = 0;
next_release_selects = false;
_width = Wide;
if (horizontal) {
- gain_slider = manage (new HSliderController (pix,
+ gain_slider = manage (new HSliderController (pix,
&gain_adjustment,
+ fader_length,
false));
} else {
gain_slider = manage (new VSliderController (pix,
&gain_adjustment,
+ fader_length,
false));
}
level_meter = new LevelMeter(_session);
- gain_slider->signal_button_press_event().connect (mem_fun(*this, &GainMeter::start_gain_touch));
- gain_slider->signal_button_release_event().connect (mem_fun(*this, &GainMeter::end_gain_touch));
+ gain_slider->signal_button_press_event().connect (sigc::mem_fun(*this, &GainMeter::start_gain_touch));
+ gain_slider->signal_button_release_event().connect (sigc::mem_fun(*this, &GainMeter::end_gain_touch));
gain_slider->set_name ("GainFader");
gain_display.set_name ("MixerStripGainDisplay");
gain_display.set_has_frame (false);
set_size_request_to_display_given_text (gain_display, "-80.g", 2, 6); /* note the descender */
- gain_display.signal_activate().connect (mem_fun (*this, &GainMeter::gain_activated));
- gain_display.signal_focus_in_event().connect (mem_fun (*this, &GainMeter::gain_focused), false);
- gain_display.signal_focus_out_event().connect (mem_fun (*this, &GainMeter::gain_focused), false);
+ gain_display.signal_activate().connect (sigc::mem_fun (*this, &GainMeter::gain_activated));
+ gain_display.signal_focus_in_event().connect (sigc::mem_fun (*this, &GainMeter::gain_focused), false);
+ gain_display.signal_focus_out_event().connect (sigc::mem_fun (*this, &GainMeter::gain_focused), false);
peak_display.set_name ("MixerStripPeakDisplay");
// peak_display.set_has_frame (false);
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);
gain_automation_state_button.set_size_request(15, 15);
gain_automation_style_button.set_size_request(15, 15);
-
+
gain_astyle_menu.items().push_back (MenuElem (_("Trim")));
gain_astyle_menu.items().push_back (MenuElem (_("Abs")));
-
+
gain_astate_menu.set_name ("ArdourContextMenu");
gain_astyle_menu.set_name ("ArdourContextMenu");
- gain_adjustment.signal_value_changed().connect (mem_fun(*this, &GainMeterBase::gain_adjusted));
- peak_display.signal_button_release_event().connect (mem_fun(*this, &GainMeterBase::peak_button_release), false);
- gain_display.signal_key_press_event().connect (mem_fun(*this, &GainMeterBase::gain_key_press), false);
+ gain_adjustment.signal_value_changed().connect (sigc::mem_fun(*this, &GainMeterBase::gain_adjusted));
+ peak_display.signal_button_release_event().connect (sigc::mem_fun(*this, &GainMeterBase::peak_button_release), false);
+ gain_display.signal_key_press_event().connect (sigc::mem_fun(*this, &GainMeterBase::gain_key_press), false);
- ResetAllPeakDisplays.connect (mem_fun(*this, &GainMeterBase::reset_peak_display));
- ResetGroupPeakDisplays.connect (mem_fun(*this, &GainMeterBase::reset_group_peak_display));
+ ResetAllPeakDisplays.connect (sigc::mem_fun(*this, &GainMeterBase::reset_peak_display));
+ ResetGroupPeakDisplays.connect (sigc::mem_fun(*this, &GainMeterBase::reset_group_peak_display));
- UI::instance()->theme_changed.connect (mem_fun(*this, &GainMeterBase::on_theme_changed));
- ColorsChanged.connect (bind(mem_fun (*this, &GainMeterBase::color_handler), false));
- DPIReset.connect (bind(mem_fun (*this, &GainMeterBase::color_handler), true));
+ UI::instance()->theme_changed.connect (sigc::mem_fun(*this, &GainMeterBase::on_theme_changed));
+ ColorsChanged.connect (sigc::bind(sigc::mem_fun (*this, &GainMeterBase::color_handler), false));
+ DPIReset.connect (sigc::bind(sigc::mem_fun (*this, &GainMeterBase::color_handler), true));
}
GainMeterBase::~GainMeterBase ()
void
GainMeterBase::set_controls (boost::shared_ptr<Route> r,
- boost::shared_ptr<PeakMeter> pm,
+ boost::shared_ptr<PeakMeter> pm,
boost::shared_ptr<Amp> amp)
{
connections.clear ();
+ model_connections.drop_connections ();
if (!pm && !amp) {
level_meter->set_meter (0);
_amp.reset ();
_route.reset ();
return;
- }
+ }
_meter = pm;
_amp = amp;
level_meter->set_meter (pm.get());
gain_slider->set_controllable (amp->gain_control());
-
+
if (!_route || _route->output()->n_ports().n_midi() == 0) {
_is_midi = false;
gain_adjustment.set_lower (0.0);
gain_adjustment.set_step_increment (0.05);
gain_adjustment.set_page_increment (0.1);
}
-
+
if (!_route || !_route->is_hidden()) {
-
+
using namespace Menu_Helpers;
-
+
gain_astate_menu.items().clear ();
-
- gain_astate_menu.items().push_back (MenuElem (_("Manual"),
- bind (mem_fun (*(amp.get()), &Automatable::set_parameter_automation_state),
+
+ gain_astate_menu.items().push_back (MenuElem (_("Manual"),
+ sigc::bind (sigc::mem_fun (*(amp.get()), &Automatable::set_parameter_automation_state),
Evoral::Parameter(GainAutomation), (AutoState) Off)));
gain_astate_menu.items().push_back (MenuElem (_("Play"),
- bind (mem_fun (*(amp.get()), &Automatable::set_parameter_automation_state),
+ sigc::bind (sigc::mem_fun (*(amp.get()), &Automatable::set_parameter_automation_state),
Evoral::Parameter(GainAutomation), (AutoState) Play)));
gain_astate_menu.items().push_back (MenuElem (_("Write"),
- bind (mem_fun (*(amp.get()), &Automatable::set_parameter_automation_state),
+ sigc::bind (sigc::mem_fun (*(amp.get()), &Automatable::set_parameter_automation_state),
Evoral::Parameter(GainAutomation), (AutoState) Write)));
gain_astate_menu.items().push_back (MenuElem (_("Touch"),
- bind (mem_fun (*(amp.get()), &Automatable::set_parameter_automation_state),
+ sigc::bind (sigc::mem_fun (*(amp.get()), &Automatable::set_parameter_automation_state),
Evoral::Parameter(GainAutomation), (AutoState) Touch)));
-
- connections.push_back (gain_automation_style_button.signal_button_press_event().connect (mem_fun(*this, &GainMeterBase::gain_automation_style_button_event), false));
- connections.push_back (gain_automation_state_button.signal_button_press_event().connect (mem_fun(*this, &GainMeterBase::gain_automation_state_button_event), false));
- boost::shared_ptr<AutomationControl> gc = amp->gain_control();
+ connections.push_back (gain_automation_style_button.signal_button_press_event().connect (sigc::mem_fun(*this, &GainMeterBase::gain_automation_style_button_event), false));
+ connections.push_back (gain_automation_state_button.signal_button_press_event().connect (sigc::mem_fun(*this, &GainMeterBase::gain_automation_state_button_event), false));
- connections.push_back (gc->alist()->automation_state_changed.connect (mem_fun(*this, &GainMeter::gain_automation_state_changed)));
- connections.push_back (gc->alist()->automation_style_changed.connect (mem_fun(*this, &GainMeter::gain_automation_style_changed)));
+ boost::shared_ptr<AutomationControl> gc = amp->gain_control();
+
+ 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 (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 ();
level_meter->setup_meters(len, 5);
}
-void
+void
GainMeter::setup_meters (int len)
{
if (!meter_metric_area.get_parent()) {
} else {
value = _amp->gain ();
}
-
+
//cerr << this << " for " << _io->name() << " EGAIN = " << value
// << " AGAIN = " << gain_adjustment.get_value () << endl;
// stacktrace (cerr, 20);
if (gain_adjustment.get_value() != value) {
- ignore_toggle = true;
+ ignore_toggle = true;
gain_adjustment.set_value (value);
ignore_toggle = false;
}
void
GainMeterBase::gain_changed ()
{
- Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &GainMeterBase::effective_gain_display));
+ Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&GainMeterBase::effective_gain_display, this));
}
void
case MeterInput:
return MeterPreFader;
break;
-
+
case MeterPreFader:
return MeterPostFader;
break;
-
+
case MeterPostFader:
- return MeterInput;
+ return MeterCustom;
+ break;
+
+ case MeterCustom:
+ return MeterInput;
break;
}
+
/*NOTREACHED*/
return MeterInput;
}
GainMeterBase::meter_press(GdkEventButton* ev)
{
wait_for_release = false;
-
+
if (!_route) {
return FALSE;
}
if (!ignore_toggle) {
if (Keyboard::is_context_menu_event (ev)) {
-
+
// no menu at this time.
} else {
// Primary-button2 click is the midi binding click
// button2-click is "momentary"
-
+
if (!Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier))) {
wait_for_release = true;
old_meter_point = _route->meter_point ();
if (_route && (ev->button == 1 || Keyboard::is_button2_event (ev))) {
if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) {
-
+
/* Primary+Tertiary-click applies change to all routes */
- _session.begin_reversible_command (_("meter point change"));
- Session::GlobalMeteringStateCommand *cmd = new Session::GlobalMeteringStateCommand (_session, this);
- _session.foreach_route (this, &GainMeterBase::set_meter_point, next_meter_point (_route->meter_point()));
- cmd->mark();
- _session.add_command (cmd);
- _session.commit_reversible_command ();
-
-
+ _session->foreach_route (this, &GainMeterBase::set_meter_point, next_meter_point (_route->meter_point()));
+
+
} else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
/* Primary-click: solo mix group.
NOTE: Primary-button2 is MIDI learn.
*/
-
+
if (ev->button == 1) {
- _session.begin_reversible_command (_("meter point change"));
- Session::GlobalMeteringStateCommand *cmd = new Session::GlobalMeteringStateCommand (_session, this);
set_mix_group_meter_point (*_route, next_meter_point (_route->meter_point()));
- cmd->mark();
- _session.add_command (cmd);
- _session.commit_reversible_command ();
}
-
+
} else {
-
+
/* click: change just this route */
// 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()));
}
}
}
if(!ignore_toggle){
if (wait_for_release){
wait_for_release = false;
-
+
if (_route) {
set_meter_point (*_route, old_meter_point);
}
void
GainMeterBase::set_meter_point (Route& route, MeterPoint mp)
{
- route.set_meter_point (mp, this);
+ route.set_meter_point (mp);
}
void
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);
}
}
if (ev->type == GDK_BUTTON_RELEASE) {
return TRUE;
}
-
+
switch (ev->button) {
case 1:
gain_astate_menu.popup (1, ev->time);
void
GainMeterBase::gain_automation_state_changed ()
{
- ENSURE_GUI_THREAD(mem_fun(*this, &GainMeterBase::gain_automation_state_changed));
-
+ ENSURE_GUI_THREAD (*this, &GainMeterBase::gain_automation_state_changed)
+
bool x;
switch (_width) {
}
x = (_amp->gain_control()->alist()->automation_state() != Off);
-
+
if (gain_automation_state_button.get_active() != x) {
ignore_toggle = true;
gain_automation_state_button.set_active (x);
}
update_gain_sensitive ();
-
+
/* start watching automation so that things move */
-
+
gain_watching.disconnect();
if (x) {
- gain_watching = ARDOUR_UI::RapidScreenUpdate.connect (mem_fun (*this, &GainMeterBase::effective_gain_display));
+ gain_watching = ARDOUR_UI::RapidScreenUpdate.connect (sigc::mem_fun (*this, &GainMeterBase::effective_gain_display));
}
}
style_changed = true;
}
-GainMeter::GainMeter (Session& s)
- : GainMeterBase (s, slider, false)
+GainMeter::GainMeter (Session* s, int fader_length)
+ : GainMeterBase (s, slider, false, fader_length)
{
gain_display_box.set_homogeneous (true);
gain_display_box.set_spacing (2);
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);
pack_start (gain_display_box, Gtk::PACK_SHRINK);
pack_start (hbox, Gtk::PACK_SHRINK);
- meter_metric_area.signal_expose_event().connect (mem_fun(*this, &GainMeter::meter_metrics_expose));
+ meter_metric_area.signal_expose_event().connect (sigc::mem_fun(*this, &GainMeter::meter_metrics_expose));
}
-void
+void
GainMeter::set_controls (boost::shared_ptr<Route> r,
boost::shared_ptr<PeakMeter> meter,
boost::shared_ptr<Amp> amp)
GainMeterBase::set_controls (r, meter, amp);
- /*
- if we have a non-hidden route (ie. we're not the click or the auditioner),
+ /*
+ if we have a non-hidden route (ie. we're not the click or the auditioner),
pack some route-dependent stuff.
*/
-
+
gain_display_box.pack_end (peak_display, true, true);
hbox.pack_end (*level_meter, true, true);
-
- if (!r->is_hidden()) {
+
+ if (r && !r->is_hidden()) {
fader_vbox->pack_start (gain_automation_state_button, false, false, 0);
}
char buf[32];
win->get_size (width, height);
-
+
Glib::RefPtr<Gdk::Pixmap> pixmap = Gdk::Pixmap::create (win, width, height);
metric_pixmaps[w.get_name()] = pixmap;
gint width, height;
win->get_size (width, height);
-
+
base_rect.width = width;
base_rect.height = height;
base_rect.x = 0;