On selection, move/scroll VCA into view

This commit is contained in:
Robin Gareus 2019-03-14 01:29:10 +01:00
parent 41e0255b97
commit 12fd048358
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 43 additions and 1 deletions

View File

@ -1641,15 +1641,56 @@ Mixer_UI::track_display_button_press (GdkEventButton* ev)
return false;
}
void
Mixer_UI::move_vca_into_view (boost::shared_ptr<ARDOUR::Stripable> s)
{
if (!vca_scroller.get_hscrollbar()) {
return;
}
bool found = false;
int x0 = 0;
Gtk::Allocation alloc;
TreeModel::Children rows = track_model->children();
for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
AxisView* av = (*i)[stripable_columns.strip];
VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
if (vms && vms->stripable () == s) {
int y;
found = true;
vms->translate_coordinates (vca_hpacker, 0, 0, x0, y);
alloc = vms->get_allocation ();
break;
}
}
if (!found) {
return;
}
Adjustment* adj = vca_scroller.get_hscrollbar()->get_adjustment();
if (x0 < adj->get_value()) {
adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x0)));
} else if (x0 + alloc.get_width() >= adj->get_value() + adj->get_page_size()) {
int x1 = x0 + alloc.get_width() - adj->get_page_size();
adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x1)));
}
}
void
Mixer_UI::move_stripable_into_view (boost::shared_ptr<ARDOUR::Stripable> s)
{
if (!scroller.get_hscrollbar()) {
return;
}
if (s->presentation_info().special () || s->presentation_info().flag_match (PresentationInfo::VCA)) {
if (s->presentation_info().special ()) {
return;
}
if (s->presentation_info().flag_match (PresentationInfo::VCA)) {
move_vca_into_view (s);
}
#ifdef MIXBUS
if (s->mixbus ()) {
return;

View File

@ -203,6 +203,7 @@ private:
void vca_scroll_right ();
void toggle_midi_input_active (bool flip_others);
void move_vca_into_view (boost::shared_ptr<ARDOUR::Stripable>);
void move_stripable_into_view (boost::shared_ptr<ARDOUR::Stripable>);
void add_stripables (ARDOUR::StripableList&);