#include <limits.h>
#include "ardour/amp.h"
-#include "ardour/io.h"
-#include "ardour/route.h"
#include "ardour/route_group.h"
-#include "ardour/session.h"
#include "ardour/session_route.h"
#include "ardour/dB.h"
#include "ardour/utils.h"
sigc::signal<void,RouteGroup*> GainMeterBase::ResetGroupPeakDisplays;
GainMeter::MetricPatterns GainMeter::metric_patterns;
-Glib::RefPtr<Gdk::Pixbuf> GainMeter::slider;
-
-
-void
-GainMeter::setup_slider_pix ()
-{
- if ((slider = ::get_icon ("fader_belt")) == 0) {
- throw failed_constructor();
- }
-}
-GainMeterBase::GainMeterBase (Session* s,
- const Glib::RefPtr<Gdk::Pixbuf>& pix,
- bool horizontal,
- int fader_length)
+GainMeterBase::GainMeterBase (Session* s, bool horizontal, int fader_length, int fader_girth)
: gain_adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0.0, 1.0, 0.01, 0.1)
, gain_automation_style_button ("")
, gain_automation_state_button ("")
_width = Wide;
if (horizontal) {
- gain_slider = manage (new HSliderController (pix,
- &gain_adjustment,
- fader_length,
- false));
+ gain_slider = manage (new HSliderController (&gain_adjustment, fader_length, fader_girth, false));
} else {
- gain_slider = manage (new VSliderController (pix,
- &gain_adjustment,
- fader_length,
- false));
+ gain_slider = manage (new VSliderController (&gain_adjustment, fader_length, fader_girth, false));
}
level_meter = new LevelMeter(_session);
meter_metric_area.signal_button_press_event().connect (sigc::mem_fun (*this, &GainMeterBase::level_meter_button_press));
meter_metric_area.add_events (Gdk::BUTTON_PRESS_MASK);
- 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->signal_button_press_event().connect (sigc::mem_fun(*this, &GainMeter::gain_slider_button_press), false);
+ gain_slider->signal_button_release_event().connect (sigc::mem_fun(*this, &GainMeter::gain_slider_button_release), false);
gain_slider->set_name ("GainFader");
gain_display.set_name ("MixerStripGainDisplay");
peak_display.set_label (_("-inf"));
peak_display.unset_flags (Gtk::CAN_FOCUS);
- gain_automation_style_button.set_name ("MixerAutomationModeButton");
- gain_automation_state_button.set_name ("MixerAutomationPlaybackButton");
+ gain_automation_style_button.set_name ("mixer strip button");
+ gain_automation_state_button.set_name ("mixer strip button");
ARDOUR_UI::instance()->set_tip (gain_automation_state_button, _("Fader automation mode"));
ARDOUR_UI::instance()->set_tip (gain_automation_style_button, _("Fader automation type"));
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));
+
+// PBD::ScopedConnection _config_connection;
+// Config->ParameterChanged.connect ( _config_connection, MISSING_INVALIDATOR, boost::bind(&GainMeterBase::set_flat_buttons, this, _1), gui_context() );
+}
+
+void
+GainMeterBase::set_flat_buttons ()
+{
+printf("set_flat_butt\n");
+// gain_slider->set_flat_buttons( ARDOUR_UI::config()->flat_buttons.get() );
}
GainMeterBase::~GainMeterBase ()
if (amp) {
amp->ConfigurationChanged.connect (
- model_connections, invalidator (*this), ui_bind (&GainMeterBase::setup_gain_adjustment, this), gui_context ()
+ model_connections, invalidator (*this), boost::bind (&GainMeterBase::setup_gain_adjustment, this), gui_context ()
);
}
_data_type = DataType::MIDI;
gain_adjustment.set_lower (0.0);
gain_adjustment.set_upper (2.0);
- gain_adjustment.set_step_increment (0.05);
- gain_adjustment.set_page_increment (0.1);
- gain_slider->set_default_value (1);
+ gain_adjustment.set_step_increment (1.0/128.0);
+ gain_adjustment.set_page_increment (10.0/128.0);
+ gain_slider->set_default_value (1.0);
}
ignore_toggle = false;
{
float f;
- if (sscanf (gain_display.get_text().c_str(), "%f", &f) == 1) {
+ {
+ // Switch to user's preferred locale so that
+ // if they use different LC_NUMERIC conventions,
+ // we will honor them.
- /* clamp to displayable values */
+ PBD::LocaleGuard lg ("");
+ if (sscanf (gain_display.get_text().c_str(), "%f", &f) != 1) {
+ return;
+ }
+ }
+ /* clamp to displayable values */
+ if (_data_type == DataType::AUDIO) {
f = min (f, 6.0f);
-
_amp->set_gain (dB_to_coefficient(f), this);
+ } else {
+ f = min (fabs (f), 2.0f);
+ _amp->set_gain (f, this);
+ }
- if (gain_display.has_focus()) {
- PublicEditor::instance().reset_focus();
+ if (gain_display.has_focus()) {
+ Gtk::Widget* w = gain_display.get_toplevel();
+ if (w) {
+ Gtk::Window* win = dynamic_cast<Gtk::Window*> (w);
+
+ /* sigh. gtkmm doesn't wrap get_default_widget() */
+
+ if (win) {
+ GtkWidget* f = gtk_window_get_default_widget (win->gobj());
+ if (f) {
+ gtk_widget_grab_focus (f);
+ return;
+ }
+ }
}
}
}
void
GainMeterBase::gain_adjusted ()
{
- gain_t value = 0;
+ gain_t value;
- switch (_data_type) {
- case DataType::AUDIO:
+ /* convert from adjustment range (0..1) to gain coefficient */
+
+ if (_data_type == DataType::AUDIO) {
value = slider_position_to_gain_with_max (gain_adjustment.get_value(), Config->get_max_gain());
- break;
- case DataType::MIDI:
- value = gain_adjustment.get_value ();
- break;
+ } else {
+ value = gain_adjustment.get_value();
}
if (!ignore_toggle) {
void
GainMeterBase::set_fader_name (const char * 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);
+ gain_slider->set_name (name);
}
void
return false;
}
- return true;
+ return false;
}
bool
GainMeterBase::gain_slider_button_release (GdkEventButton*)
{
_amp->gain_control()->stop_touch (false, _amp->session().transport_frame());
- return true;
+ return false;
}
gint
{
switch (_width) {
case Wide:
- gain_automation_style_button.set_label (astyle_string(_amp->gain_control()->alist()->automation_style()));
+ gain_automation_style_button.set_text (astyle_string(_amp->gain_control()->alist()->automation_style()));
break;
case Narrow:
- gain_automation_style_button.set_label (short_astyle_string(_amp->gain_control()->alist()->automation_style()));
+ gain_automation_style_button.set_text (short_astyle_string(_amp->gain_control()->alist()->automation_style()));
break;
}
}
switch (_width) {
case Wide:
- gain_automation_state_button.set_label (astate_string(_amp->gain_control()->alist()->automation_state()));
+ gain_automation_state_button.set_text (astate_string(_amp->gain_control()->alist()->automation_state()));
break;
case Narrow:
- gain_automation_state_button.set_label (short_astate_string(_amp->gain_control()->alist()->automation_state()));
+ gain_automation_state_button.set_text (short_astate_string(_amp->gain_control()->alist()->automation_state()));
break;
}
}
GainMeter::GainMeter (Session* s, int fader_length)
- : GainMeterBase (s, slider, false, fader_length)
+ : GainMeterBase (s, false, fader_length, 24)
, gain_display_box(true, 0)
, hbox(true, 2)
{
- gain_display_box.pack_start (gain_display, true, true);
+// 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, "-127", 0, 0);
- gain_automation_style_button.set_name ("MixerAutomationModeButton");
- gain_automation_state_button.set_name ("MixerAutomationPlaybackButton");
+ gain_automation_style_button.set_name ("mixer strip button");
+ gain_automation_state_button.set_name ("mixer strip button");
ARDOUR_UI::instance()->set_tip (gain_automation_state_button, _("Fader automation mode"));
ARDOUR_UI::instance()->set_tip (gain_automation_style_button, _("Fader automation type"));
hbox.remove (meter_alignment);
}
- if (peak_display.get_parent()) {
- gain_display_box.remove (peak_display);
- }
+// if (peak_display.get_parent()) {
+// gain_display_box.remove (peak_display);
+// }
- if (gain_automation_state_button.get_parent()) {
- fader_vbox->remove (gain_automation_state_button);
- }
+// if (gain_automation_state_button.get_parent()) {
+// fader_vbox->remove (gain_automation_state_button);
+// }
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()
+ model_connections, invalidator (*this), boost::bind (&GainMeter::meter_configuration_changed, this, _1), gui_context()
);
meter_configuration_changed (_meter->input_streams ());
pack some route-dependent stuff.
*/
- gain_display_box.pack_end (peak_display, true, true);
+// gain_display_box.pack_end (peak_display, true, true);
hbox.pack_start (meter_alignment, true, true);
- if (r && !r->is_hidden()) {
- fader_vbox->pack_start (gain_automation_state_button, false, false, 0);
- }
+// if (r && !r->is_hidden()) {
+// fader_vbox->pack_start (gain_automation_state_button, false, false, 0);
+// }
setup_meters ();
hbox.show_all ();