mirror of
https://github.com/rmcrackan/Libation.git
synced 2026-12-02 10:09:26 +01:00
Make auto-scroll mean the same thing in both UIs
WinForms had been changed to pin the first active download to the top on every start, which interrupts anyone who has scrolled further down the queue - the behaviour master's comment says it deliberately avoids. Avalonia kept master's gentler version but never read the setting, so Chardonnay's checkbox did nothing. Both now run master's logic - scroll the new item into view only when the previous one is visible - gated by AutoScrollQueue. VirtualFlowControl.ScrollToTop had no callers left, so it goes.
This commit is contained in:
@@ -51,11 +51,16 @@ internal partial class ProcessQueueControl : UserControl
|
||||
if (!ViewModel.AutoScrollQueue) return;
|
||||
Invoke(() =>
|
||||
{
|
||||
// Pin the first active download to the top so all parallel in-progress items are visible.
|
||||
int firstActiveIndex = ViewModel.Queue.Completed.Count;
|
||||
if (firstActiveIndex < ViewModel.Queue.Count)
|
||||
virtualFlowControl2.ScrollToTop(firstActiveIndex);
|
||||
if (ViewModel.Queue?.IndexOf(e) is int newtBookIndex && newtBookIndex > 0 && itemIsVisible(newtBookIndex - 1))
|
||||
{
|
||||
// Only scroll the new item into view if the previous item is visible.
|
||||
// This allows users to scroll through the queue without being interrupted.
|
||||
virtualFlowControl2.ScrollIntoView(newtBookIndex);
|
||||
}
|
||||
});
|
||||
|
||||
bool itemIsVisible(int newtBookIndex)
|
||||
=> virtualFlowControl2.FirstRealizedIndex <= newtBookIndex && virtualFlowControl2.LastRealizedIndex >= newtBookIndex;
|
||||
}
|
||||
|
||||
private void LogEntries_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user