Remove IInternalScroller and move IScrollable to Avalonia.Base (#20519)
* Remove IInternalScroller and move IScrollable to Avalonia.Base * Update API suppressions
This commit is contained in:
committed by
GitHub
parent
62fac86360
commit
8d2f1475ca
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- https://learn.microsoft.com/dotnet/fundamentals/package-validation/diagnostic-ids -->
|
||||
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
<Suppression>
|
||||
@@ -37,4 +37,4 @@
|
||||
<Left>baseline/Avalonia.Win32.Interoperability/lib/net8.0-windows7.0/Avalonia.Win32.Interoperability.dll</Left>
|
||||
<Right>current/Avalonia.Win32.Interoperability/lib/net8.0-windows7.0/Avalonia.Win32.Interoperability.dll</Right>
|
||||
</Suppression>
|
||||
</Suppressions>
|
||||
</Suppressions>
|
||||
|
||||
@@ -7,6 +7,12 @@
|
||||
<Left>baseline/Avalonia/lib/net10.0/Avalonia.Base.dll</Left>
|
||||
<Right>current/Avalonia/lib/net10.0/Avalonia.Base.dll</Right>
|
||||
</Suppression>
|
||||
<Suppression>
|
||||
<DiagnosticId>CP0001</DiagnosticId>
|
||||
<Target>T:Avalonia.Controls.Primitives.IScrollable</Target>
|
||||
<Left>baseline/Avalonia/lib/net10.0/Avalonia.Controls.dll</Left>
|
||||
<Right>current/Avalonia/lib/net10.0/Avalonia.Controls.dll</Right>
|
||||
</Suppression>
|
||||
<Suppression>
|
||||
<DiagnosticId>CP0001</DiagnosticId>
|
||||
<Target>T:Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindings.CompiledBindingPath</Target>
|
||||
@@ -25,6 +31,12 @@
|
||||
<Left>baseline/Avalonia/lib/net8.0/Avalonia.Base.dll</Left>
|
||||
<Right>current/Avalonia/lib/net8.0/Avalonia.Base.dll</Right>
|
||||
</Suppression>
|
||||
<Suppression>
|
||||
<DiagnosticId>CP0001</DiagnosticId>
|
||||
<Target>T:Avalonia.Controls.Primitives.IScrollable</Target>
|
||||
<Left>baseline/Avalonia/lib/net8.0/Avalonia.Controls.dll</Left>
|
||||
<Right>current/Avalonia/lib/net8.0/Avalonia.Controls.dll</Right>
|
||||
</Suppression>
|
||||
<Suppression>
|
||||
<DiagnosticId>CP0001</DiagnosticId>
|
||||
<Target>T:Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindings.CompiledBindingPath</Target>
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Avalonia.Controls.Primitives;
|
||||
|
||||
// TODO12: Integrate with existing IScrollable interface, breaking change
|
||||
internal interface IInternalScroller
|
||||
{
|
||||
bool CanHorizontallyScroll { get; }
|
||||
|
||||
bool CanVerticallyScroll { get; }
|
||||
}
|
||||
+10
@@ -19,5 +19,15 @@ namespace Avalonia.Controls.Primitives
|
||||
/// Gets the size of the viewport, in logical units.
|
||||
/// </summary>
|
||||
Size Viewport { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the content can be scrolled horizontally.
|
||||
/// </summary>
|
||||
bool CanHorizontallyScroll { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the content can be scrolled horizontally.
|
||||
/// </summary>
|
||||
bool CanVerticallyScroll { get; }
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,7 @@ public partial class XYFocus
|
||||
return false;
|
||||
}
|
||||
|
||||
var closestScroller = candidate.FindAncestorOfType<IInternalScroller>(true);
|
||||
var closestScroller = candidate.FindAncestorOfType<IScrollable>(true);
|
||||
return ReferenceEquals(closestScroller, activeScroller);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public partial class XYFocus
|
||||
var parent = activeScroller.Parent;
|
||||
while (parent != null)
|
||||
{
|
||||
if (parent is IInternalScroller and Visual visual
|
||||
if (parent is IScrollable and Visual visual
|
||||
&& visual.IsVisualAncestorOf(candidate))
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -415,7 +415,7 @@ public partial class XYFocus
|
||||
while (parent != null)
|
||||
{
|
||||
var element = parent;
|
||||
if (element is IInternalScroller scrollable)
|
||||
if (element is IScrollable scrollable)
|
||||
{
|
||||
var isHorizontallyScrollable = scrollable.CanHorizontallyScroll;
|
||||
var isVerticallyScrollable = scrollable.CanVerticallyScroll;
|
||||
|
||||
@@ -45,35 +45,35 @@ namespace Avalonia.Controls.Presenters
|
||||
/// Gets the owner <see cref="ItemsControl"/>.
|
||||
/// </summary>
|
||||
internal ItemsControl? ItemsControl { get; private set; }
|
||||
|
||||
private bool CanHorizontallyScroll
|
||||
=> _logicalScrollable?.CanHorizontallyScroll ?? false;
|
||||
|
||||
bool ILogicalScrollable.CanHorizontallyScroll
|
||||
bool ILogicalScrollable.CanHorizontallyScroll
|
||||
{
|
||||
get => _logicalScrollable?.CanHorizontallyScroll ?? false;
|
||||
set
|
||||
{
|
||||
if (_logicalScrollable is not null)
|
||||
_logicalScrollable.CanHorizontallyScroll = value;
|
||||
}
|
||||
get => CanHorizontallyScroll;
|
||||
set => _logicalScrollable?.CanHorizontallyScroll = value;
|
||||
}
|
||||
|
||||
bool ILogicalScrollable.CanVerticallyScroll
|
||||
bool IScrollable.CanHorizontallyScroll
|
||||
=> CanHorizontallyScroll;
|
||||
|
||||
private bool CanVerticallyScroll
|
||||
=> _logicalScrollable?.CanVerticallyScroll ?? false;
|
||||
|
||||
bool ILogicalScrollable.CanVerticallyScroll
|
||||
{
|
||||
get => _logicalScrollable?.CanVerticallyScroll ?? false;
|
||||
set
|
||||
{
|
||||
if (_logicalScrollable is not null)
|
||||
_logicalScrollable.CanVerticallyScroll = value;
|
||||
}
|
||||
get => CanVerticallyScroll;
|
||||
set => _logicalScrollable?.CanVerticallyScroll = value;
|
||||
}
|
||||
|
||||
bool IScrollable.CanVerticallyScroll
|
||||
=> CanVerticallyScroll;
|
||||
|
||||
Vector IScrollable.Offset
|
||||
{
|
||||
get => _logicalScrollable?.Offset ?? default;
|
||||
set
|
||||
{
|
||||
if (_logicalScrollable is not null)
|
||||
_logicalScrollable.Offset = value;
|
||||
}
|
||||
set => _logicalScrollable?.Offset = value;
|
||||
}
|
||||
|
||||
bool ILogicalScrollable.IsLogicalScrollEnabled => _logicalScrollable?.IsLogicalScrollEnabled ?? false;
|
||||
|
||||
@@ -19,12 +19,12 @@ namespace Avalonia.Controls.Primitives
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the content can be scrolled horizontally.
|
||||
/// </summary>
|
||||
bool CanHorizontallyScroll { get; set; }
|
||||
new bool CanHorizontallyScroll { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the content can be scrolled horizontally.
|
||||
/// </summary>
|
||||
bool CanVerticallyScroll { get; set; }
|
||||
new bool CanVerticallyScroll { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether logical scrolling is enabled on the control.
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Avalonia.Controls
|
||||
/// </summary>
|
||||
[TemplatePart("PART_HorizontalScrollBar", typeof(ScrollBar))]
|
||||
[TemplatePart("PART_VerticalScrollBar", typeof(ScrollBar))]
|
||||
public class ScrollViewer : ContentControl, IScrollable, IScrollAnchorProvider, IInternalScroller
|
||||
public class ScrollViewer : ContentControl, IScrollable, IScrollAnchorProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the <see cref="BringIntoViewOnFocusChange "/> property.
|
||||
@@ -284,7 +284,7 @@ namespace Avalonia.Controls
|
||||
get => HorizontalScrollBarVisibility != ScrollBarVisibility.Disabled;
|
||||
}
|
||||
|
||||
bool IInternalScroller.CanHorizontallyScroll => CanHorizontallyScroll;
|
||||
bool IScrollable.CanHorizontallyScroll => CanHorizontallyScroll;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the viewer can scroll vertically.
|
||||
@@ -294,7 +294,7 @@ namespace Avalonia.Controls
|
||||
get => VerticalScrollBarVisibility != ScrollBarVisibility.Disabled;
|
||||
}
|
||||
|
||||
bool IInternalScroller.CanVerticallyScroll => CanVerticallyScroll;
|
||||
bool IScrollable.CanVerticallyScroll => CanVerticallyScroll;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Control? CurrentAnchor => (Presenter as IScrollAnchorProvider)?.CurrentAnchor;
|
||||
|
||||
@@ -29,9 +29,23 @@ namespace Avalonia.Controls
|
||||
private int _transitionFromIndex = -1;
|
||||
private CancellationTokenSource? _transition;
|
||||
private EventHandler? _scrollInvalidated;
|
||||
private bool _canHorizontallyScroll;
|
||||
private bool _canVerticallyScroll;
|
||||
|
||||
bool ILogicalScrollable.CanHorizontallyScroll { get; set; }
|
||||
bool ILogicalScrollable.CanVerticallyScroll { get; set; }
|
||||
bool ILogicalScrollable.CanHorizontallyScroll
|
||||
{
|
||||
get => _canHorizontallyScroll;
|
||||
set => _canHorizontallyScroll = value;
|
||||
}
|
||||
|
||||
bool ILogicalScrollable.CanVerticallyScroll
|
||||
{
|
||||
get => _canVerticallyScroll;
|
||||
set => _canVerticallyScroll = value;
|
||||
}
|
||||
|
||||
bool IScrollable.CanHorizontallyScroll => _canHorizontallyScroll;
|
||||
bool IScrollable.CanVerticallyScroll => _canVerticallyScroll;
|
||||
bool ILogicalScrollable.IsLogicalScrollEnabled => true;
|
||||
Size ILogicalScrollable.ScrollSize => new(1, 1);
|
||||
Size ILogicalScrollable.PageScrollSize => new(1, 1);
|
||||
|
||||
Reference in New Issue
Block a user