From 29f60441801d3dbef9d2f4fc0db04a9f883261c2 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 15 Oct 2016 23:16:09 +0200 Subject: [PATCH] Mixer strip list: click to move strip into view --- gtk2_ardour/mixer_ui.cc | 48 +++++++++++++++++++++++++++++++++++++++++ gtk2_ardour/mixer_ui.h | 2 ++ 2 files changed, 50 insertions(+) diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc index 978e6500e2..de530340a2 100644 --- a/gtk2_ardour/mixer_ui.cc +++ b/gtk2_ardour/mixer_ui.cc @@ -1480,10 +1480,58 @@ Mixer_UI::track_display_button_press (GdkEventButton* ev) show_track_list_menu (); return true; } + if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 1)) { + TreeModel::Path path; + TreeViewColumn* column; + int cellx, celly; + if (track_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) { + TreeIter iter = track_model->get_iter (path); + if ((*iter)[stripable_columns.visible]) { + boost::shared_ptr s = (*iter)[stripable_columns.stripable]; + move_stripable_into_view (s); + } + } + } return false; } +void +Mixer_UI::move_stripable_into_view (boost::shared_ptr s) +{ + if (!scroller.get_hscrollbar()) { + return; + } + bool found = false; + int x0 = 0; + int x1 = 0; + for (list::const_iterator i = strips.begin(); i != strips.end(); ++i) { + if ((*i)->route() == s) { + int y; + found = true; + (*i)->translate_coordinates (strip_packer, 0, 0, x0, y); + x1 = x0 + (*i)->get_width (); + break; + } + } + if (!found) { + return; + } + + Adjustment* adj = scroller.get_hscrollbar()->get_adjustment(); + int sl = adj->get_value(); + int sr = sl + scroller.get_width(); + + if (x0 < sl) { + scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), x0 - 1.0))); + } + else if (x1 > sr) { + // TODO: align left side of left most track, if possible + double re = x1 - scroller.get_width(); + scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), re))); + } +} + void Mixer_UI::build_track_menu () { diff --git a/gtk2_ardour/mixer_ui.h b/gtk2_ardour/mixer_ui.h index a85006af5a..fb0ba57496 100644 --- a/gtk2_ardour/mixer_ui.h +++ b/gtk2_ardour/mixer_ui.h @@ -176,6 +176,8 @@ class Mixer_UI : public Gtkmm2ext::Tabbable, public PBD::ScopedConnectionList, p void scroll_right (); void toggle_midi_input_active (bool flip_others); + void move_stripable_into_view (boost::shared_ptr); + void add_stripables (ARDOUR::StripableList&); void add_routes (ARDOUR::RouteList&);