From a1e43aa1ce7a2c321136cfdd7982d387dda66dab Mon Sep 17 00:00:00 2001 From: Stefan Date: Sat, 11 Jan 2020 16:17:28 +0100 Subject: [PATCH] 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. --- VocaluxeLib/Menu/SongMenu/CSongMenuList.cs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs index 2c85058a..89a43849 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs @@ -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(); } } -} \ No newline at end of file +}