13
0

Mixer strip list: click to move strip into view

This commit is contained in:
Robin Gareus 2016-10-15 23:16:09 +02:00
parent f52443e17e
commit 29f6044180
2 changed files with 50 additions and 0 deletions

View File

@ -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<ARDOUR::Stripable> s = (*iter)[stripable_columns.stripable];
move_stripable_into_view (s);
}
}
}
return false;
}
void
Mixer_UI::move_stripable_into_view (boost::shared_ptr<ARDOUR::Stripable> s)
{
if (!scroller.get_hscrollbar()) {
return;
}
bool found = false;
int x0 = 0;
int x1 = 0;
for (list<MixerStrip *>::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 ()
{

View File

@ -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<ARDOUR::Stripable>);
void add_stripables (ARDOUR::StripableList&);
void add_routes (ARDOUR::RouteList&);