2 Copyright (C) 2002 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "ardour/amp.h"
23 #include "ardour/io.h"
24 #include "ardour/route.h"
25 #include "ardour/route_group.h"
26 #include "ardour/session.h"
27 #include "ardour/session_route.h"
28 #include "ardour/dB.h"
29 #include "ardour/utils.h"
31 #include <gtkmm/style.h>
32 #include <gdkmm/color.h>
33 #include <gtkmm2ext/utils.h>
34 #include <gtkmm2ext/fastmeter.h>
35 #include <gtkmm2ext/barcontroller.h>
36 #include <gtkmm2ext/gtk_ui.h>
37 #include "midi++/manager.h"
38 #include "pbd/fastlog.h"
39 #include "pbd/stacktrace.h"
41 #include "ardour_ui.h"
42 #include "gain_meter.h"
43 #include "global_signals.h"
45 #include "gui_thread.h"
47 #include "public_editor.h"
50 #include "ardour/session.h"
51 #include "ardour/route.h"
52 #include "ardour/meter.h"
56 using namespace ARDOUR;
58 using namespace Gtkmm2ext;
61 using Gtkmm2ext::Keyboard;
63 sigc::signal<void> GainMeterBase::ResetAllPeakDisplays;
64 sigc::signal<void,RouteGroup*> GainMeterBase::ResetGroupPeakDisplays;
66 map<string,Glib::RefPtr<Gdk::Pixmap> > GainMeter::metric_pixmaps;
67 Glib::RefPtr<Gdk::Pixbuf> GainMeter::slider;
71 GainMeter::setup_slider_pix ()
73 if ((slider = ::get_icon ("fader_belt")) == 0) {
74 throw failed_constructor();
78 GainMeterBase::GainMeterBase (Session* s,
79 const Glib::RefPtr<Gdk::Pixbuf>& pix,
82 : 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.
83 , gain_automation_style_button ("")
84 , gain_automation_state_button ("")
85 , style_changed (false)
90 using namespace Menu_Helpers;
94 ignore_toggle = false;
96 next_release_selects = false;
100 gain_slider = manage (new HSliderController (pix,
105 gain_slider = manage (new VSliderController (pix,
111 level_meter = new LevelMeter(_session);
113 gain_slider->signal_button_press_event().connect (sigc::mem_fun(*this, &GainMeter::gain_slider_button_press));
114 gain_slider->signal_button_release_event().connect (sigc::mem_fun(*this, &GainMeter::gain_slider_button_release));
115 gain_slider->set_name ("GainFader");
117 gain_display.set_name ("MixerStripGainDisplay");
118 gain_display.set_has_frame (false);
119 set_size_request_to_display_given_text (gain_display, "-80.g", 2, 6); /* note the descender */
120 gain_display.signal_activate().connect (sigc::mem_fun (*this, &GainMeter::gain_activated));
121 gain_display.signal_focus_in_event().connect (sigc::mem_fun (*this, &GainMeter::gain_focused), false);
122 gain_display.signal_focus_out_event().connect (sigc::mem_fun (*this, &GainMeter::gain_focused), false);
124 peak_display.set_name ("MixerStripPeakDisplay");
125 // peak_display.set_has_frame (false);
126 // peak_display.set_editable (false);
127 set_size_request_to_display_given_text (peak_display, "-80.g", 2, 6); /* note the descender */
128 max_peak = minus_infinity();
129 peak_display.set_label (_("-inf"));
130 peak_display.unset_flags (Gtk::CAN_FOCUS);
132 gain_automation_style_button.set_name ("MixerAutomationModeButton");
133 gain_automation_state_button.set_name ("MixerAutomationPlaybackButton");
135 ARDOUR_UI::instance()->set_tip (gain_automation_state_button, _("Fader automation mode"));
136 ARDOUR_UI::instance()->set_tip (gain_automation_style_button, _("Fader automation type"));
138 gain_automation_style_button.unset_flags (Gtk::CAN_FOCUS);
139 gain_automation_state_button.unset_flags (Gtk::CAN_FOCUS);
141 gain_automation_state_button.set_size_request(15, 15);
142 gain_automation_style_button.set_size_request(15, 15);
144 gain_astyle_menu.items().push_back (MenuElem (_("Trim")));
145 gain_astyle_menu.items().push_back (MenuElem (_("Abs")));
147 gain_astate_menu.set_name ("ArdourContextMenu");
148 gain_astyle_menu.set_name ("ArdourContextMenu");
150 gain_adjustment.signal_value_changed().connect (sigc::mem_fun(*this, &GainMeterBase::gain_adjusted));
151 peak_display.signal_button_release_event().connect (sigc::mem_fun(*this, &GainMeterBase::peak_button_release), false);
152 gain_display.signal_key_press_event().connect (sigc::mem_fun(*this, &GainMeterBase::gain_key_press), false);
154 ResetAllPeakDisplays.connect (sigc::mem_fun(*this, &GainMeterBase::reset_peak_display));
155 ResetGroupPeakDisplays.connect (sigc::mem_fun(*this, &GainMeterBase::reset_group_peak_display));
157 UI::instance()->theme_changed.connect (sigc::mem_fun(*this, &GainMeterBase::on_theme_changed));
158 ColorsChanged.connect (sigc::bind(sigc::mem_fun (*this, &GainMeterBase::color_handler), false));
159 DPIReset.connect (sigc::bind(sigc::mem_fun (*this, &GainMeterBase::color_handler), true));
162 GainMeterBase::~GainMeterBase ()
169 GainMeterBase::set_controls (boost::shared_ptr<Route> r,
170 boost::shared_ptr<PeakMeter> pm,
171 boost::shared_ptr<Amp> amp)
173 connections.clear ();
174 model_connections.drop_connections ();
177 level_meter->set_meter (0);
178 gain_slider->set_controllable (boost::shared_ptr<PBD::Controllable>());
189 level_meter->set_meter (pm.get());
190 gain_slider->set_controllable (amp->gain_control());
192 if (!_route || _route->output()->n_ports().n_midi() == 0) {
194 gain_adjustment.set_lower (0.0);
195 gain_adjustment.set_upper (1.0);
196 gain_adjustment.set_step_increment (0.01);
197 gain_adjustment.set_page_increment (0.1);
200 gain_adjustment.set_lower (0.0);
201 gain_adjustment.set_upper (2.0);
202 gain_adjustment.set_step_increment (0.05);
203 gain_adjustment.set_page_increment (0.1);
206 if (!_route || !_route->is_hidden()) {
208 using namespace Menu_Helpers;
210 gain_astate_menu.items().clear ();
212 gain_astate_menu.items().push_back (MenuElem (_("Manual"),
213 sigc::bind (sigc::mem_fun (*(amp.get()), &Automatable::set_parameter_automation_state),
214 Evoral::Parameter(GainAutomation), (AutoState) Off)));
215 gain_astate_menu.items().push_back (MenuElem (_("Play"),
216 sigc::bind (sigc::mem_fun (*(amp.get()), &Automatable::set_parameter_automation_state),
217 Evoral::Parameter(GainAutomation), (AutoState) Play)));
218 gain_astate_menu.items().push_back (MenuElem (_("Write"),
219 sigc::bind (sigc::mem_fun (*(amp.get()), &Automatable::set_parameter_automation_state),
220 Evoral::Parameter(GainAutomation), (AutoState) Write)));
221 gain_astate_menu.items().push_back (MenuElem (_("Touch"),
222 sigc::bind (sigc::mem_fun (*(amp.get()), &Automatable::set_parameter_automation_state),
223 Evoral::Parameter(GainAutomation), (AutoState) Touch)));
225 connections.push_back (gain_automation_style_button.signal_button_press_event().connect (sigc::mem_fun(*this, &GainMeterBase::gain_automation_style_button_event), false));
226 connections.push_back (gain_automation_state_button.signal_button_press_event().connect (sigc::mem_fun(*this, &GainMeterBase::gain_automation_state_button_event), false));
228 boost::shared_ptr<AutomationControl> gc = amp->gain_control();
230 gc->alist()->automation_state_changed.connect (model_connections, invalidator (*this), boost::bind (&GainMeter::gain_automation_state_changed, this), gui_context());
231 gc->alist()->automation_style_changed.connect (model_connections, invalidator (*this), boost::bind (&GainMeter::gain_automation_style_changed, this), gui_context());
233 gain_automation_state_changed ();
236 amp->gain_control()->Changed.connect (model_connections, invalidator (*this), boost::bind (&GainMeterBase::gain_changed, this), gui_context());
240 update_gain_sensitive ();
244 GainMeterBase::hide_all_meters ()
246 level_meter->hide_meters();
250 GainMeter::hide_all_meters ()
252 bool remove_metric_area = false;
254 GainMeterBase::hide_all_meters ();
256 if (remove_metric_area) {
257 if (meter_metric_area.get_parent()) {
258 level_meter->remove (meter_metric_area);
264 GainMeterBase::setup_meters (int len)
266 level_meter->setup_meters(len, 5);
270 GainMeter::setup_meters (int len)
272 if (!meter_metric_area.get_parent()) {
273 level_meter->pack_end (meter_metric_area, false, false);
274 meter_metric_area.show_all ();
276 GainMeterBase::setup_meters (len);
280 GainMeterBase::gain_key_press (GdkEventKey* ev)
282 if (key_is_legal_for_numeric_entry (ev->keyval)) {
283 /* drop through to normal handling */
286 /* illegal key for gain entry */
291 GainMeterBase::peak_button_release (GdkEventButton* ev)
293 /* reset peak label */
295 if (ev->button == 1 && Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier|Keyboard::TertiaryModifier)) {
296 ResetAllPeakDisplays ();
297 } else if (ev->button == 1 && Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
299 ResetGroupPeakDisplays (_route->route_group());
302 reset_peak_display ();
309 GainMeterBase::reset_peak_display ()
312 level_meter->clear_meters();
313 max_peak = -INFINITY;
314 peak_display.set_label (_("-Inf"));
315 peak_display.set_name ("MixerStripPeakDisplay");
319 GainMeterBase::reset_group_peak_display (RouteGroup* group)
321 if (_route && group == _route->route_group()) {
322 reset_peak_display ();
327 GainMeterBase::popup_meter_menu (GdkEventButton *ev)
329 using namespace Menu_Helpers;
331 if (meter_menu == 0) {
332 meter_menu = new Gtk::Menu;
333 MenuList& items = meter_menu->items();
335 items.push_back (MenuElem ("-inf .. +0dBFS"));
336 items.push_back (MenuElem ("-10dB .. +0dBFS"));
337 items.push_back (MenuElem ("-4 .. +0dBFS"));
338 items.push_back (SeparatorElem());
339 items.push_back (MenuElem ("-inf .. -2dBFS"));
340 items.push_back (MenuElem ("-10dB .. -2dBFS"));
341 items.push_back (MenuElem ("-4 .. -2dBFS"));
344 meter_menu->popup (1, ev->time);
348 GainMeterBase::gain_focused (GdkEventFocus* ev)
351 gain_display.select_region (0, -1);
353 gain_display.select_region (0, 0);
359 GainMeterBase::gain_activated ()
363 if (sscanf (gain_display.get_text().c_str(), "%f", &f) == 1) {
365 /* clamp to displayable values */
369 _amp->set_gain (dB_to_coefficient(f), this);
371 if (gain_display.has_focus()) {
372 PublicEditor::instance().reset_focus();
378 GainMeterBase::show_gain ()
382 float v = gain_adjustment.get_value();
386 strcpy (buf, _("-inf"));
388 snprintf (buf, sizeof (buf), "%.1f", accurate_coefficient_to_dB (slider_position_to_gain (v)));
391 snprintf (buf, sizeof (buf), "%.1f", v);
394 gain_display.set_text (buf);
398 GainMeterBase::gain_adjusted ()
400 if (!ignore_toggle) {
401 if (_route && _route->amp() == _amp) {
403 _route->set_gain (gain_adjustment.get_value(), this);
405 _route->set_gain (slider_position_to_gain (gain_adjustment.get_value()), this);
408 _amp->set_gain (slider_position_to_gain (gain_adjustment.get_value()), this);
416 GainMeterBase::effective_gain_display ()
420 if (!_route || _route->output()->n_ports().n_midi() == 0) {
421 value = gain_to_slider_position (_amp->gain());
423 value = _amp->gain ();
426 //cerr << this << " for " << _io->name() << " EGAIN = " << value
427 // << " AGAIN = " << gain_adjustment.get_value () << endl;
428 // stacktrace (cerr, 20);
430 if (gain_adjustment.get_value() != value) {
431 ignore_toggle = true;
432 gain_adjustment.set_value (value);
433 ignore_toggle = false;
438 GainMeterBase::gain_changed ()
440 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&GainMeterBase::effective_gain_display, this));
444 GainMeterBase::set_meter_strip_name (const char * name)
446 meter_metric_area.set_name (name);
450 GainMeterBase::set_fader_name (const char * name)
452 uint32_t rgb_active = rgba_from_style (name, 0xff, 0, 0xff, 0, "bg", STATE_ACTIVE, false);
453 uint32_t rgb_normal = rgba_from_style (name, 0xff, 0xff, 0, 0, "bg", STATE_NORMAL, false);
455 gain_slider->set_border_colors (rgb_normal, rgb_active);
459 GainMeterBase::update_gain_sensitive ()
461 bool x = !(_amp->gain_control()->alist()->automation_state() & Play);
462 static_cast<Gtkmm2ext::SliderController*>(gain_slider)->set_sensitive (x);
466 next_meter_point (MeterPoint mp)
470 return MeterPreFader;
474 return MeterPostFader;
491 GainMeterBase::meter_press(GdkEventButton* ev)
493 wait_for_release = false;
499 if (!ignore_toggle) {
501 if (Keyboard::is_context_menu_event (ev)) {
503 // no menu at this time.
507 if (Keyboard::is_button2_event(ev)) {
509 // Primary-button2 click is the midi binding click
510 // button2-click is "momentary"
512 if (!Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier))) {
513 wait_for_release = true;
514 old_meter_point = _route->meter_point ();
518 if (_route && (ev->button == 1 || Keyboard::is_button2_event (ev))) {
520 if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) {
522 /* Primary+Tertiary-click applies change to all routes */
524 _session->foreach_route (this, &GainMeterBase::set_meter_point, next_meter_point (_route->meter_point()));
527 } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
529 /* Primary-click: solo mix group.
530 NOTE: Primary-button2 is MIDI learn.
533 if (ev->button == 1) {
534 set_route_group_meter_point (*_route, next_meter_point (_route->meter_point()));
539 /* click: change just this route */
543 _route->set_meter_point (next_meter_point (_route->meter_point()));
554 GainMeterBase::meter_release(GdkEventButton*)
557 if (wait_for_release){
558 wait_for_release = false;
561 set_meter_point (*_route, old_meter_point);
570 GainMeterBase::set_meter_point (Route& route, MeterPoint mp)
572 route.set_meter_point (mp);
576 GainMeterBase::set_route_group_meter_point (Route& route, MeterPoint mp)
578 RouteGroup* route_group;
580 if ((route_group = route.route_group ()) != 0) {
581 route_group->foreach_route (boost::bind (&Route::set_meter_point, _1, mp, false));
583 route.set_meter_point (mp);
588 GainMeterBase::meter_point_clicked ()
596 GainMeterBase::gain_slider_button_press (GdkEventButton* ev)
599 case GDK_BUTTON_PRESS:
600 _amp->gain_control()->start_touch (_amp->session().transport_frame());
610 GainMeterBase::gain_slider_button_release (GdkEventButton* ev)
612 _amp->gain_control()->stop_touch (false, _amp->session().transport_frame());
617 GainMeterBase::gain_automation_state_button_event (GdkEventButton *ev)
619 if (ev->type == GDK_BUTTON_RELEASE) {
623 switch (ev->button) {
625 gain_astate_menu.popup (1, ev->time);
635 GainMeterBase::gain_automation_style_button_event (GdkEventButton *ev)
637 if (ev->type == GDK_BUTTON_RELEASE) {
641 switch (ev->button) {
643 gain_astyle_menu.popup (1, ev->time);
652 GainMeterBase::astate_string (AutoState state)
654 return _astate_string (state, false);
658 GainMeterBase::short_astate_string (AutoState state)
660 return _astate_string (state, true);
664 GainMeterBase::_astate_string (AutoState state, bool shrt)
670 sstr = (shrt ? "M" : _("M"));
673 sstr = (shrt ? "P" : _("P"));
676 sstr = (shrt ? "T" : _("T"));
679 sstr = (shrt ? "W" : _("W"));
687 GainMeterBase::astyle_string (AutoStyle style)
689 return _astyle_string (style, false);
693 GainMeterBase::short_astyle_string (AutoStyle style)
695 return _astyle_string (style, true);
699 GainMeterBase::_astyle_string (AutoStyle style, bool shrt)
704 /* XXX it might different in different languages */
706 return (shrt ? _("Abs") : _("Abs"));
711 GainMeterBase::gain_automation_style_changed ()
715 gain_automation_style_button.set_label (astyle_string(_amp->gain_control()->alist()->automation_style()));
718 gain_automation_style_button.set_label (short_astyle_string(_amp->gain_control()->alist()->automation_style()));
724 GainMeterBase::gain_automation_state_changed ()
726 ENSURE_GUI_THREAD (*this, &GainMeterBase::gain_automation_state_changed)
732 gain_automation_state_button.set_label (astate_string(_amp->gain_control()->alist()->automation_state()));
735 gain_automation_state_button.set_label (short_astate_string(_amp->gain_control()->alist()->automation_state()));
739 x = (_amp->gain_control()->alist()->automation_state() != Off);
741 if (gain_automation_state_button.get_active() != x) {
742 ignore_toggle = true;
743 gain_automation_state_button.set_active (x);
744 ignore_toggle = false;
747 update_gain_sensitive ();
749 /* start watching automation so that things move */
751 gain_watching.disconnect();
754 gain_watching = ARDOUR_UI::RapidScreenUpdate.connect (sigc::mem_fun (*this, &GainMeterBase::effective_gain_display));
759 GainMeterBase::update_meters()
762 float mpeak = level_meter->update_meters();
764 if (mpeak > max_peak) {
766 if (mpeak <= -200.0f) {
767 peak_display.set_label (_("-inf"));
769 snprintf (buf, sizeof(buf), "%.1f", mpeak);
770 peak_display.set_label (buf);
774 peak_display.set_name ("MixerStripPeakDisplayPeak");
779 void GainMeterBase::color_handler(bool dpi)
781 color_changed = true;
782 dpi_changed = (dpi) ? true : false;
787 GainMeterBase::set_width (Width w, int len)
790 level_meter->setup_meters (len);
795 GainMeterBase::on_theme_changed()
797 style_changed = true;
800 GainMeter::GainMeter (Session* s, int fader_length)
801 : GainMeterBase (s, slider, false, fader_length)
803 gain_display_box.set_homogeneous (true);
804 gain_display_box.set_spacing (2);
805 gain_display_box.pack_start (gain_display, true, true);
807 meter_metric_area.set_name ("AudioTrackMetrics");
808 set_size_request_to_display_given_text (meter_metric_area, "-127", 0, 0);
810 gain_automation_style_button.set_name ("MixerAutomationModeButton");
811 gain_automation_state_button.set_name ("MixerAutomationPlaybackButton");
813 ARDOUR_UI::instance()->set_tip (gain_automation_state_button, _("Fader automation mode"));
814 ARDOUR_UI::instance()->set_tip (gain_automation_style_button, _("Fader automation type"));
816 gain_automation_style_button.unset_flags (Gtk::CAN_FOCUS);
817 gain_automation_state_button.unset_flags (Gtk::CAN_FOCUS);
819 gain_automation_state_button.set_size_request(15, 15);
820 gain_automation_style_button.set_size_request(15, 15);
822 fader_vbox = manage (new Gtk::VBox());
823 fader_vbox->set_spacing (0);
824 fader_vbox->pack_start (*gain_slider, false, false, 0);
826 hbox.set_spacing (2);
827 hbox.pack_start (*fader_vbox, false, false, 4);
831 pack_start (gain_display_box, Gtk::PACK_SHRINK);
832 pack_start (hbox, Gtk::PACK_SHRINK);
834 meter_metric_area.signal_expose_event().connect (sigc::mem_fun(*this, &GainMeter::meter_metrics_expose));
838 GainMeter::set_controls (boost::shared_ptr<Route> r,
839 boost::shared_ptr<PeakMeter> meter,
840 boost::shared_ptr<Amp> amp)
842 if (level_meter->get_parent()) {
843 hbox.remove (*level_meter);
846 if (peak_display.get_parent()) {
847 gain_display_box.remove (peak_display);
850 if (gain_automation_state_button.get_parent()) {
851 fader_vbox->remove (gain_automation_state_button);
854 GainMeterBase::set_controls (r, meter, amp);
857 _meter->ConfigurationChanged.connect (
858 model_connections, invalidator (*this), ui_bind (&GainMeter::meter_configuration_changed, this, _1), gui_context()
861 meter_configuration_changed (_meter->input_streams ());
866 if we have a non-hidden route (ie. we're not the click or the auditioner),
867 pack some route-dependent stuff.
870 gain_display_box.pack_end (peak_display, true, true);
871 hbox.pack_start (*level_meter, true, true);
873 if (r && !r->is_hidden()) {
874 fader_vbox->pack_start (gain_automation_state_button, false, false, 0);
882 GainMeter::get_gm_width ()
885 hbox.size_request (sz);
889 Glib::RefPtr<Gdk::Pixmap>
890 GainMeter::render_metrics (Gtk::Widget& w, vector<DataType> types)
892 Glib::RefPtr<Gdk::Window> win (w.get_window());
893 Glib::RefPtr<Gdk::GC> bg_gc (w.get_style()->get_bg_gc (Gtk::STATE_NORMAL));
896 win->get_size (width, height);
898 Glib::RefPtr<Gdk::Pixmap> pixmap = Gdk::Pixmap::create (win, width, height);
900 metric_pixmaps[w.get_name()] = pixmap;
902 pixmap->draw_rectangle (bg_gc, true, 0, 0, width, height);
904 Glib::RefPtr<Pango::Layout> layout = w.create_pango_layout ("");
906 for (vector<DataType>::const_iterator i = types.begin(); i != types.end(); ++i) {
908 Glib::RefPtr<Gdk::GC> fg_gc (w.get_style()->get_fg_gc (Gtk::STATE_NORMAL));
910 if (types.size() > 1) {
911 /* we're overlaying more than 1 set of marks, so use different colours */
914 case DataType::AUDIO:
915 c.set_rgb_p (1, 1, 1);
918 c.set_rgb_p (0.2, 0.2, 0.5);
922 fg_gc->set_rgb_fg_color (c);
928 case DataType::AUDIO:
929 points.push_back (-50);
930 points.push_back (-40);
931 points.push_back (-30);
932 points.push_back (-20);
933 points.push_back (-10);
934 points.push_back (-3);
935 points.push_back (0);
936 points.push_back (4);
940 points.push_back (0);
941 if (types.size() == 1) {
942 points.push_back (32);
944 /* tweak so as not to overlay the -30dB mark */
945 points.push_back (48);
947 points.push_back (64);
948 points.push_back (96);
949 points.push_back (127);
955 for (vector<int>::const_iterator j = points.begin(); j != points.end(); ++j) {
959 case DataType::AUDIO:
960 fraction = log_meter (*j);
963 fraction = *j / 127.0;
967 gint const pos = height - (gint) floor (height * fraction);
969 snprintf (buf, sizeof (buf), "%d", abs (*j));
971 layout->set_text (buf);
973 /* we want logical extents, not ink extents here */
976 layout->get_pixel_size (tw, th);
978 pixmap->draw_line (fg_gc, 0, pos, 4, pos);
980 int p = pos - (th / 2);
981 p = min (p, height - th);
984 pixmap->draw_layout (fg_gc, 6, p, layout);
992 GainMeter::meter_metrics_expose (GdkEventExpose *ev)
994 Glib::RefPtr<Gdk::Window> win (meter_metric_area.get_window());
995 Glib::RefPtr<Gdk::GC> bg_gc (meter_metric_area.get_style()->get_bg_gc (Gtk::STATE_INSENSITIVE));
996 GdkRectangle base_rect;
997 GdkRectangle draw_rect;
1000 win->get_size (width, height);
1002 base_rect.width = width;
1003 base_rect.height = height;
1007 Glib::RefPtr<Gdk::Pixmap> pixmap;
1008 std::map<string,Glib::RefPtr<Gdk::Pixmap> >::iterator i = metric_pixmaps.find (meter_metric_area.get_name());
1010 if (i == metric_pixmaps.end() || style_changed || dpi_changed) {
1011 pixmap = render_metrics (meter_metric_area, _types);
1016 gdk_rectangle_intersect (&ev->area, &base_rect, &draw_rect);
1017 win->draw_drawable (bg_gc, pixmap, draw_rect.x, draw_rect.y, draw_rect.x, draw_rect.y, draw_rect.width, draw_rect.height);
1018 style_changed = false;
1022 boost::shared_ptr<PBD::Controllable>
1023 GainMeterBase::get_controllable()
1026 return _amp->gain_control();
1028 return boost::shared_ptr<PBD::Controllable>();
1033 GainMeter::meter_configuration_changed (ChanCount c)
1037 for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
1038 if (c.get (*i) > 0) {
1039 _types.push_back (*i);
1043 style_changed = true;
1044 meter_metric_area.queue_draw ();