diff --git a/gtk2_ardour/gain_meter.cc b/gtk2_ardour/gain_meter.cc index 18e16fdce5..00c41ff1ad 100644 --- a/gtk2_ardour/gain_meter.cc +++ b/gtk2_ardour/gain_meter.cc @@ -198,6 +198,7 @@ GainMeterBase::set_controls (boost::shared_ptr r, 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); } if (!_route || !_route->is_hidden()) { diff --git a/libs/gtkmm2ext/gtkmm2ext/pixfader.h b/libs/gtkmm2ext/gtkmm2ext/pixfader.h index 00a42769be..43df8e555e 100644 --- a/libs/gtkmm2ext/gtkmm2ext/pixfader.h +++ b/libs/gtkmm2ext/gtkmm2ext/pixfader.h @@ -38,6 +38,8 @@ class PixFader : public Gtk::DrawingArea void set_fader_length (int); void set_border_colors (uint32_t rgba_left, uint32_t rgba_right); + void set_default_value (float); + protected: Gtk::Adjustment& adjustment; @@ -82,6 +84,7 @@ class PixFader : public Gtk::DrawingArea void adjustment_changed (); int display_span (); void set_adjustment_from_event (GdkEventButton *); + void update_unity_position (); static int fine_scale_modifier; static int extra_fine_scale_modifier; diff --git a/libs/gtkmm2ext/pixfader.cc b/libs/gtkmm2ext/pixfader.cc index 6f8eb32e78..8dde56a989 100644 --- a/libs/gtkmm2ext/pixfader.cc +++ b/libs/gtkmm2ext/pixfader.cc @@ -369,9 +369,21 @@ PixFader::set_fader_length (int l) { if (_orien == VERT) { view.height = span = l; - unity_loc = (int) rint (view.height - (default_value * view.height)) - 1; } else { view.width = span = l; + } + + update_unity_position (); + + queue_draw (); +} + +void +PixFader::update_unity_position () +{ + if (_orien == VERT) { + unity_loc = (int) rint (view.height * (1 - (default_value / (adjustment.get_upper() - adjustment.get_lower())))) - 1; + } else { unity_loc = (int) rint (default_value * view.width); } @@ -402,3 +414,10 @@ PixFader::set_adjustment_from_event (GdkEventButton* ev) adjustment.set_value (fract * (adjustment.get_upper () - adjustment.get_lower ())); } + +void +PixFader::set_default_value (float d) +{ + default_value = d; + update_unity_position (); +}