Fixed a bug in ListWindow() where setting the selected index would not

result in a repaint.
This commit is contained in:
casey langen 2016-10-03 23:38:30 -07:00
parent 3123701db2
commit 3476c7b2ed
2 changed files with 8 additions and 1 deletions

View File

@ -127,12 +127,13 @@ void TrackListView::ScrollToPlaying() {
DBID id = this->playing->Id();
for (size_t i = 0; i < this->metadata->Count(); i++) {
if (this->metadata->GetId(i) == id) {
this->SetSelectedIndex(i);
auto pos = this->GetScrollPosition();
size_t first = pos.firstVisibleEntryIndex;
size_t last = first + pos.visibleEntryCount;
if (i < first || i > last) {
/* only scroll if the playing track is not visible. */
this->SetSelectedIndex(i);
this->ScrollTo(i);
}
break;

View File

@ -176,6 +176,12 @@ void ListWindow::SetSelectedIndex(size_t index) {
if (this->selectedIndex != index) {
size_t prev = this->selectedIndex;
this->selectedIndex = index;
this->GetScrollAdapter().DrawPage(
this, index, &this->GetScrollPosition());
this->Repaint();
this->OnSelectionChanged(index, prev); /* internal */
this->SelectionChanged(this, index, prev); /* external */
}