Scroll the new selected song to the middle of the screen

Updated _UpdateList() to scroll the song list, that the new selected song is in the middle of the screen.
This commit is contained in:
Stefan authored and GitHub committed 2020-01-11 16:17:28 +01:00
1 parent fcf212df12
commit a1e43aa1ce
1 file changed
+18 -3
+18 -3
View File
@@ -592,13 +592,28 @@ namespace VocaluxeLib.Menu.SongMenu
private void _UpdateList(bool force = false)
{
bool isInCategory = CBase.Songs.IsInCategory();
int itemCount = isInCategory ? CBase.Songs.GetNumSongsVisible() : CBase.Songs.GetNumCategories();
int halfListLength = _ListLength / 2;
int offset;
if (_SelectionNr < _Offset && _SelectionNr >= 0)
offset = _SelectionNr;
{
if (_SelectionNr - halfListLength >= 0)
offset = _SelectionNr - halfListLength;
else
offset = 0;
}
else if (_SelectionNr >= _Offset + _ListLength)
offset = _SelectionNr - _ListLength + 1;
{
if (_SelectionNr + halfListLength > itemCount)
offset = itemCount - _ListLength;
else
offset = _SelectionNr - halfListLength;
}
else
offset = _Offset;
_UpdateList(offset, force);
}
@@ -653,4 +668,4 @@ namespace VocaluxeLib.Menu.SongMenu
base.LoadSkin();
}
}
}
}