#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 "global_signals.h"
#include "logmeter.h"
#include "gui_thread.h"
#include "keyboard.h"
: 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 ("")
+ , style_changed (false)
, dpi_changed (false)
, _is_midi (false)
ignore_toggle = false;
meter_menu = 0;
next_release_selects = false;
- style_changed = true;
_width = Wide;
if (horizontal) {
level_meter = new LevelMeter(_session);
- 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->signal_button_press_event().connect (sigc::mem_fun(*this, &GainMeter::gain_slider_button_press));
+ gain_slider->signal_button_release_event().connect (sigc::mem_fun(*this, &GainMeter::gain_slider_button_release));
gain_slider->set_name ("GainFader");
gain_display.set_name ("MixerStripGainDisplay");
boost::shared_ptr<AutomationControl> gc = amp->gain_control();
- 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());
+ 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 ();
}
- amp->gain_control()->Changed.connect (model_connections, boost::bind (&GainMeterBase::gain_changed, this), gui_context());
+ amp->gain_control()->Changed.connect (model_connections, invalidator (*this), boost::bind (&GainMeterBase::gain_changed, this), gui_context());
gain_changed ();
show_gain ();
GainMeterBase::gain_adjusted ()
{
if (!ignore_toggle) {
- if (_route) {
- if (_route->amp() == _amp) {
- if (_is_midi) {
- _route->set_gain (gain_adjustment.get_value(), this);
- } else {
- _route->set_gain (slider_position_to_gain (gain_adjustment.get_value()), this);
- }
+ if (_route && _route->amp() == _amp) {
+ if (_is_midi) {
+ _route->set_gain (gain_adjustment.get_value(), this);
} else {
- _amp->set_gain (slider_position_to_gain (gain_adjustment.get_value()), this);
+ _route->set_gain (slider_position_to_gain (gain_adjustment.get_value()), this);
}
+ } else {
+ _amp->set_gain (slider_position_to_gain (gain_adjustment.get_value()), this);
}
}
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
void
GainMeterBase::set_fader_name (const char * name)
{
- gain_slider->set_name (name);
+ uint32_t rgb_active = rgba_from_style (name, 0xff, 0, 0xff, 0, "bg", STATE_ACTIVE, false);
+ uint32_t rgb_normal = rgba_from_style (name, 0xff, 0xff, 0, 0, "bg", STATE_NORMAL, false);
+
+ gain_slider->set_border_colors (rgb_normal, rgb_active);
}
void
break;
case MeterPostFader:
+ return MeterOutput;
+ break;
+
+ case MeterOutput:
return MeterCustom;
break;
*/
if (ev->button == 1) {
- set_mix_group_meter_point (*_route, next_meter_point (_route->meter_point()));
+ set_route_group_meter_point (*_route, next_meter_point (_route->meter_point()));
}
} else {
// 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()));
}
}
}
gint
GainMeterBase::meter_release(GdkEventButton*)
{
- if(!ignore_toggle){
- if (wait_for_release){
+ if (!ignore_toggle) {
+ if (wait_for_release) {
wait_for_release = false;
if (_route) {
void
GainMeterBase::set_meter_point (Route& route, MeterPoint mp)
{
- route.set_meter_point (mp, this);
+ route.set_meter_point (mp);
}
void
-GainMeterBase::set_mix_group_meter_point (Route& route, MeterPoint mp)
+GainMeterBase::set_route_group_meter_point (Route& route, MeterPoint mp)
{
- RouteGroup* mix_group;
+ RouteGroup* route_group;
- if((mix_group = route.route_group()) != 0){
- mix_group->apply (&Route::set_meter_point, mp, this);
+ if ((route_group = route.route_group ()) != 0) {
+ route_group->foreach_route (boost::bind (&Route::set_meter_point, _1, mp, false));
} else {
- route.set_meter_point (mp, this);
+ route.set_meter_point (mp);
}
}
}
}
-gint
-GainMeterBase::start_gain_touch (GdkEventButton*)
+bool
+GainMeterBase::gain_slider_button_press (GdkEventButton* ev)
{
- _amp->gain_control()->start_touch ();
- return FALSE;
+ switch (ev->type) {
+ case GDK_BUTTON_PRESS:
+ _amp->gain_control()->start_touch (_amp->session().transport_frame());
+ break;
+ default:
+ return false;
+ }
+
+ return true;
}
-gint
-GainMeterBase::end_gain_touch (GdkEventButton*)
+bool
+GainMeterBase::gain_slider_button_release (GdkEventButton* ev)
{
- _amp->gain_control()->stop_touch ();
- return FALSE;
+ _amp->gain_control()->stop_touch (false, _amp->session().transport_frame());
+ return true;
}
gint
gain_display_box.pack_start (gain_display, true, true);
meter_metric_area.set_name ("AudioTrackMetrics");
- set_size_request_to_display_given_text (meter_metric_area, "-50", 0, 0);
+ set_size_request_to_display_given_text (meter_metric_area, "-127", 0, 0);
gain_automation_style_button.set_name ("MixerAutomationModeButton");
gain_automation_state_button.set_name ("MixerAutomationPlaybackButton");
gain_automation_state_button.set_size_request(15, 15);
gain_automation_style_button.set_size_request(15, 15);
- HBox* fader_centering_box = manage (new HBox);
- fader_centering_box->pack_start (*gain_slider, true, false);
-
fader_vbox = manage (new Gtk::VBox());
fader_vbox->set_spacing (0);
- fader_vbox->pack_start (*fader_centering_box, false, false, 0);
+ fader_vbox->pack_start (*gain_slider, false, false, 0);
hbox.set_spacing (2);
- hbox.pack_start (*fader_vbox, true, true);
+ hbox.pack_start (*fader_vbox, false, false, 4);
set_spacing (2);
GainMeterBase::set_controls (r, meter, amp);
+ if (_meter) {
+ _meter->ConfigurationChanged.connect (
+ model_connections, invalidator (*this), ui_bind (&GainMeter::meter_configuration_changed, this, _1), gui_context()
+ );
+
+ meter_configuration_changed (_meter->input_streams ());
+ }
+
+
/*
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);
+ hbox.pack_start (*level_meter, true, true);
if (r && !r->is_hidden()) {
fader_vbox->pack_start (gain_automation_state_button, false, false, 0);
}
Glib::RefPtr<Gdk::Pixmap>
-GainMeter::render_metrics (Gtk::Widget& w)
+GainMeter::render_metrics (Gtk::Widget& w, vector<DataType> types)
{
Glib::RefPtr<Gdk::Window> win (w.get_window());
- Glib::RefPtr<Gdk::GC> fg_gc (w.get_style()->get_fg_gc (Gtk::STATE_NORMAL));
Glib::RefPtr<Gdk::GC> bg_gc (w.get_style()->get_bg_gc (Gtk::STATE_NORMAL));
- gint width, height;
- int db_points[] = { -50, -40, -20, -30, -10, -3, 0, 4 };
- char buf[32];
+ gint width, height;
win->get_size (width, height);
Glib::RefPtr<Gdk::Pixmap> pixmap = Gdk::Pixmap::create (win, width, height);
pixmap->draw_rectangle (bg_gc, true, 0, 0, width, height);
- Glib::RefPtr<Pango::Layout> layout = w.create_pango_layout("");
-
- for (uint32_t i = 0; i < sizeof (db_points)/sizeof (db_points[0]); ++i) {
-
- float fraction = log_meter (db_points[i]);
- gint pos = height - (gint) floor (height * fraction);
-
- snprintf (buf, sizeof (buf), "%d", abs (db_points[i]));
+ Glib::RefPtr<Pango::Layout> layout = w.create_pango_layout ("");
- layout->set_text (buf);
+ for (vector<DataType>::const_iterator i = types.begin(); i != types.end(); ++i) {
- /* we want logical extents, not ink extents here */
-
- int width, height;
- layout->get_pixel_size (width, height);
+ Glib::RefPtr<Gdk::GC> fg_gc (w.get_style()->get_fg_gc (Gtk::STATE_NORMAL));
+
+ if (types.size() > 1) {
+ /* we're overlaying more than 1 set of marks, so use different colours */
+ Gdk::Color c;
+ switch (*i) {
+ case DataType::AUDIO:
+ c.set_rgb_p (1, 1, 1);
+ break;
+ case DataType::MIDI:
+ c.set_rgb_p (0.2, 0.2, 0.5);
+ break;
+ }
+
+ fg_gc->set_rgb_fg_color (c);
+ }
- pixmap->draw_line (fg_gc, 0, pos, 4, pos);
- pixmap->draw_layout (fg_gc, 6, pos - (height/2), layout);
+ vector<int> points;
+
+ switch (*i) {
+ case DataType::AUDIO:
+ points.push_back (-50);
+ points.push_back (-40);
+ points.push_back (-30);
+ points.push_back (-20);
+ points.push_back (-10);
+ points.push_back (-3);
+ points.push_back (0);
+ points.push_back (4);
+ break;
+
+ case DataType::MIDI:
+ points.push_back (0);
+ if (types.size() == 1) {
+ points.push_back (32);
+ } else {
+ /* tweak so as not to overlay the -30dB mark */
+ points.push_back (48);
+ }
+ points.push_back (64);
+ points.push_back (96);
+ points.push_back (127);
+ break;
+ }
+
+ char buf[32];
+
+ for (vector<int>::const_iterator j = points.begin(); j != points.end(); ++j) {
+
+ float fraction = 0;
+ switch (*i) {
+ case DataType::AUDIO:
+ fraction = log_meter (*j);
+ break;
+ case DataType::MIDI:
+ fraction = *j / 127.0;
+ break;
+ }
+
+ gint const pos = height - (gint) floor (height * fraction);
+
+ snprintf (buf, sizeof (buf), "%d", abs (*j));
+
+ layout->set_text (buf);
+
+ /* we want logical extents, not ink extents here */
+
+ int tw, th;
+ layout->get_pixel_size (tw, th);
+
+ pixmap->draw_line (fg_gc, 0, pos, 4, pos);
+
+ int p = pos - (th / 2);
+ p = min (p, height - th);
+ p = max (p, 0);
+
+ pixmap->draw_layout (fg_gc, 6, p, layout);
+ }
}
return pixmap;
gint
GainMeter::meter_metrics_expose (GdkEventExpose *ev)
{
- static Glib::RefPtr<Gtk::Style> meter_style;
- if (style_changed) {
- meter_style = meter_metric_area.get_style();
- }
Glib::RefPtr<Gdk::Window> win (meter_metric_area.get_window());
- Glib::RefPtr<Gdk::GC> bg_gc (meter_style->get_bg_gc (Gtk::STATE_INSENSITIVE));
+ Glib::RefPtr<Gdk::GC> bg_gc (meter_metric_area.get_style()->get_bg_gc (Gtk::STATE_INSENSITIVE));
GdkRectangle base_rect;
GdkRectangle draw_rect;
gint width, height;
std::map<string,Glib::RefPtr<Gdk::Pixmap> >::iterator i = metric_pixmaps.find (meter_metric_area.get_name());
if (i == metric_pixmaps.end() || style_changed || dpi_changed) {
- pixmap = render_metrics (meter_metric_area);
+ pixmap = render_metrics (meter_metric_area, _types);
} else {
pixmap = i->second;
}
}
}
+void
+GainMeter::meter_configuration_changed (ChanCount c)
+{
+ _types.clear ();
+
+ for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
+ if (c.get (*i) > 0) {
+ _types.push_back (*i);
+ }
+ }
+ style_changed = true;
+ meter_metric_area.queue_draw ();
+}