change metric-scale on the sides of meterbridge when scrolling
This commit is contained in:
parent
8eaaede05d
commit
244f233d9e
@ -474,7 +474,12 @@ MeterStrip::meter_metrics_expose (GdkEventExpose *ev)
|
||||
void
|
||||
MeterStrip::set_metric_mode (int metricmode, ARDOUR::MeterType mt)
|
||||
{
|
||||
if (metric_type == mt && _metricmode == metricmode) {
|
||||
return;
|
||||
}
|
||||
metric_type = mt;
|
||||
_metricmode = metricmode;
|
||||
|
||||
_types.clear ();
|
||||
switch(metricmode) {
|
||||
case 0:
|
||||
|
@ -65,6 +65,7 @@ class MeterStrip : public Gtk::VBox, public RouteUI
|
||||
void set_meter_type_multi (int, ARDOUR::RouteGroup*, ARDOUR::MeterType);
|
||||
|
||||
void set_metric_mode (int, ARDOUR::MeterType);
|
||||
int get_metric_mode() { return _metricmode; }
|
||||
void set_tick_bar (int);
|
||||
int get_tick_bar() { return _tick_bar; }
|
||||
bool has_midi() { return _has_midi; }
|
||||
@ -121,6 +122,7 @@ class MeterStrip : public Gtk::VBox, public RouteUI
|
||||
bool _has_midi;
|
||||
int _tick_bar;
|
||||
int _strip_type;
|
||||
int _metricmode;
|
||||
|
||||
LevelMeterHBox *level_meter;
|
||||
|
||||
|
@ -376,6 +376,10 @@ Meterbridge::on_size_allocate (Gtk::Allocation& a)
|
||||
const Gtk::Scrollbar * hsc = scroller.get_hscrollbar();
|
||||
|
||||
if (scroller.get_hscrollbar_visible() && hsc) {
|
||||
if (!scroll_connection.connected()) {
|
||||
scroll_connection = scroller.get_hscrollbar()->get_adjustment()->signal_value_changed().connect(sigc::mem_fun (*this, &Meterbridge::on_scroll));
|
||||
scroller.get_hscrollbar()->get_adjustment()->signal_changed().connect(sigc::mem_fun (*this, &Meterbridge::on_scroll));
|
||||
}
|
||||
gint scrollbar_spacing;
|
||||
gtk_widget_style_get (GTK_WIDGET (scroller.gobj()),
|
||||
"scrollbar-spacing", &scrollbar_spacing, NULL);
|
||||
@ -389,6 +393,41 @@ Meterbridge::on_size_allocate (Gtk::Allocation& a)
|
||||
Gtk::Window::on_size_allocate(a);
|
||||
}
|
||||
|
||||
void
|
||||
Meterbridge::on_scroll()
|
||||
{
|
||||
if (!scroller.get_hscrollbar()) return;
|
||||
|
||||
Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
|
||||
int leftend = adj->get_value();
|
||||
int rightend = scroller.get_width() + leftend;
|
||||
|
||||
int mm_left = _mm_left;
|
||||
int mm_right = _mm_right;
|
||||
ARDOUR::MeterType mt_left = _mt_left;
|
||||
ARDOUR::MeterType mt_right = _mt_right;
|
||||
|
||||
for (unsigned int i = 0; i < _metrics.size(); ++i) {
|
||||
int sx, dx, dy;
|
||||
int mm = _metrics[i]->get_metric_mode();
|
||||
sx = (mm & 2) ? _metrics[i]->get_width() : 0;
|
||||
|
||||
_metrics[i]->translate_coordinates(meterarea, sx, 0, dx, dy);
|
||||
|
||||
if (dx < leftend && !(mm&2)) {
|
||||
mm_left = mm;
|
||||
mt_left = _metrics[i]->meter_type();
|
||||
}
|
||||
if (dx > rightend && (mm&2)) {
|
||||
mm_right = mm;
|
||||
mt_right = _metrics[i]->meter_type();
|
||||
break;
|
||||
}
|
||||
}
|
||||
metrics_left.set_metric_mode(mm_left, mt_left);
|
||||
metrics_right.set_metric_mode(mm_right, mt_right);
|
||||
}
|
||||
|
||||
void
|
||||
Meterbridge::set_session (Session* s)
|
||||
{
|
||||
@ -722,6 +761,13 @@ Meterbridge::sync_order_keys (RouteSortOrderKey)
|
||||
delete (_metrics.back());
|
||||
_metrics.pop_back();
|
||||
}
|
||||
|
||||
_mm_left = metrics_left.get_metric_mode();
|
||||
_mt_left = metrics_left.meter_type();
|
||||
_mm_right = metrics_right.get_metric_mode();
|
||||
_mt_right = metrics_right.meter_type();
|
||||
|
||||
on_scroll();
|
||||
queue_resize();
|
||||
}
|
||||
|
||||
|
@ -147,6 +147,12 @@ class Meterbridge :
|
||||
|
||||
void parameter_changed (std::string const & p);
|
||||
void on_theme_changed ();
|
||||
|
||||
void on_scroll ();
|
||||
sigc::connection scroll_connection;
|
||||
|
||||
int _mm_left, _mm_right;
|
||||
ARDOUR::MeterType _mt_left, _mt_right;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user