improve the behaviour of Mixer_UI::move_stripable_into_view()
authorPaul Davis <paul@linuxaudiosystems.com>
Sat, 28 Jan 2017 15:48:20 +0000 (16:48 +0100)
committerPaul Davis <paul@linuxaudiosystems.com>
Sat, 28 Jan 2017 15:48:20 +0000 (16:48 +0100)
Don't change anything if the strip is visible; if we have to move to show it, try
to show the requested strip in the middle

gtk2_ardour/mixer_ui.cc

index 05c2a51f628a631f59b1c5a4c663e6889ec1f741..a0e4322d40a36ad6fb85d9c9580025007aad91ad 100644 (file)
@@ -1598,7 +1598,15 @@ Mixer_UI::move_stripable_into_view (boost::shared_ptr<ARDOUR::Stripable> s)
        }
 
        Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
-       scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), x0 - 1.0)));
+
+       if ((x0 < adj->get_value()) || x0 >= (adj->get_value() + adj->get_page_size())) {
+               /* try to put left edge of strip in the middle */
+               double half_page = adj->get_page_size() / 2.0;
+               if (x0 >= half_page) {
+                       x0 -= half_page;
+               }
+               adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x0)));
+       }
 }
 
 void