diff --git a/Avalonia.sln b/Avalonia.sln index d9ef7a7137..c06996ba0e 100644 --- a/Avalonia.sln +++ b/Avalonia.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.24720.0 +VisualStudioVersion = 14.0.25123.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Base", "src\Avalonia.Base\Avalonia.Base.csproj", "{B09B78D8-9B26-48B0-9149-D64A2F120F3F}" EndProject @@ -172,6 +172,8 @@ Global src\Shared\RenderHelpers\RenderHelpers.projitems*{47be08a7-5985-410b-9ffc-2264b8ea595f}*SharedItemsImports = 4 src\Skia\Avalonia.Skia\Avalonia.Skia.projitems*{47be08a7-5985-410b-9ffc-2264b8ea595f}*SharedItemsImports = 4 samples\TestApplicationShared\TestApplicationShared.projitems*{e3a1060b-50d0-44e8-88b6-f44ef2e5bd72}*SharedItemsImports = 4 + src\Shared\RenderHelpers\RenderHelpers.projitems*{bd43f7c0-396b-4aa1-bad9-dfde54d51298}*SharedItemsImports = 4 + src\Skia\Avalonia.Skia\Avalonia.Skia.projitems*{bd43f7c0-396b-4aa1-bad9-dfde54d51298}*SharedItemsImports = 4 src\Shared\RenderHelpers\RenderHelpers.projitems*{3e908f67-5543-4879-a1dc-08eace79b3cd}*SharedItemsImports = 4 src\Shared\PlatformSupport\PlatformSupport.projitems*{e1aa3dbf-9056-4530-9376-18119a7a3ffe}*SharedItemsImports = 4 EndGlobalSection diff --git a/samples/XamlTestApplicationPcl/TestScrollable.cs b/samples/XamlTestApplicationPcl/TestScrollable.cs index 1f0961af27..2b16899ee1 100644 --- a/samples/XamlTestApplicationPcl/TestScrollable.cs +++ b/samples/XamlTestApplicationPcl/TestScrollable.cs @@ -7,7 +7,7 @@ using Avalonia.VisualTree; namespace XamlTestApplication { - public class TestScrollable : Control, IScrollable + public class TestScrollable : Control, ILogicalScrollable { private int itemCount = 100; private Size _extent; @@ -18,12 +18,12 @@ namespace XamlTestApplication public bool IsLogicalScrollEnabled => true; public Action InvalidateScroll { get; set; } - Size IScrollable.Extent + Size ILogicalScrollable.Extent { get { return _extent; } } - Vector IScrollable.Offset + Vector ILogicalScrollable.Offset { get { return _offset; } @@ -34,7 +34,7 @@ namespace XamlTestApplication } } - Size IScrollable.Viewport + Size ILogicalScrollable.Viewport { get { return _viewport; } } diff --git a/src/Avalonia.Controls/Avalonia.Controls.csproj b/src/Avalonia.Controls/Avalonia.Controls.csproj index f3d7f10029..11f8979a43 100644 --- a/src/Avalonia.Controls/Avalonia.Controls.csproj +++ b/src/Avalonia.Controls/Avalonia.Controls.csproj @@ -74,7 +74,7 @@ - + diff --git a/src/Avalonia.Controls/Presenters/ItemVirtualizer.cs b/src/Avalonia.Controls/Presenters/ItemVirtualizer.cs index 63d4503df7..a92990b3ba 100644 --- a/src/Avalonia.Controls/Presenters/ItemVirtualizer.cs +++ b/src/Avalonia.Controls/Presenters/ItemVirtualizer.cs @@ -30,7 +30,7 @@ namespace Avalonia.Controls.Presenters public static ItemVirtualizer Create(ItemsPresenter owner) { var virtualizingPanel = owner.Panel as IVirtualizingPanel; - var scrollable = (IScrollable)owner; + var scrollable = (ILogicalScrollable)owner; if (virtualizingPanel != null && scrollable.InvalidateScroll != null) { diff --git a/src/Avalonia.Controls/Presenters/ItemVirtualizerSimple.cs b/src/Avalonia.Controls/Presenters/ItemVirtualizerSimple.cs index 538db9fa42..a5e04ad6d5 100644 --- a/src/Avalonia.Controls/Presenters/ItemVirtualizerSimple.cs +++ b/src/Avalonia.Controls/Presenters/ItemVirtualizerSimple.cs @@ -83,13 +83,13 @@ namespace Avalonia.Controls.Presenters public override void Arranging(Size finalSize) { CreateRemoveContainers(); - ((IScrollable)Owner).InvalidateScroll(); + ((ILogicalScrollable)Owner).InvalidateScroll(); } public override void ItemsChanged(IEnumerable items, NotifyCollectionChangedEventArgs e) { base.ItemsChanged(items, e); - ((IScrollable)Owner).InvalidateScroll(); + ((ILogicalScrollable)Owner).InvalidateScroll(); } private void CreateRemoveContainers() diff --git a/src/Avalonia.Controls/Presenters/ItemsPresenter.cs b/src/Avalonia.Controls/Presenters/ItemsPresenter.cs index 86636b1837..8c05067fc7 100644 --- a/src/Avalonia.Controls/Presenters/ItemsPresenter.cs +++ b/src/Avalonia.Controls/Presenters/ItemsPresenter.cs @@ -13,7 +13,7 @@ namespace Avalonia.Controls.Presenters /// /// Displays items inside an . /// - public class ItemsPresenter : ItemsPresenterBase, IScrollable + public class ItemsPresenter : ItemsPresenterBase, ILogicalScrollable { /// /// Defines the property. @@ -45,35 +45,35 @@ namespace Avalonia.Controls.Presenters } /// - bool IScrollable.IsLogicalScrollEnabled + bool ILogicalScrollable.IsLogicalScrollEnabled { get { return _virtualizer?.IsLogicalScrollEnabled ?? false; } } /// - Action IScrollable.InvalidateScroll { get; set; } + Action ILogicalScrollable.InvalidateScroll { get; set; } /// - Size IScrollable.Extent => _virtualizer.Extent; + Size ILogicalScrollable.Extent => _virtualizer.Extent; /// - Vector IScrollable.Offset + Vector ILogicalScrollable.Offset { get { return _virtualizer.Offset; } set { _virtualizer.Offset = CoerceOffset(value); } } /// - Size IScrollable.Viewport => _virtualizer.Viewport; + Size ILogicalScrollable.Viewport => _virtualizer.Viewport; /// - Size IScrollable.ScrollSize => new Size(0, 1); + Size ILogicalScrollable.ScrollSize => new Size(0, 1); /// - Size IScrollable.PageScrollSize => new Size(0, 1); + Size ILogicalScrollable.PageScrollSize => new Size(0, 1); /// - bool IScrollable.BringIntoView(IVisual target, Rect targetRect) + bool ILogicalScrollable.BringIntoView(IVisual target, Rect targetRect) { return _virtualizer?.BringIntoView(target, targetRect) ?? false; } @@ -90,7 +90,7 @@ namespace Avalonia.Controls.Presenters protected override void PanelCreated(IPanel panel) { _virtualizer = ItemVirtualizer.Create(this); - ((IScrollable)this).InvalidateScroll?.Invoke(); + ((ILogicalScrollable)this).InvalidateScroll?.Invoke(); if (!Panel.IsSet(KeyboardNavigation.DirectionalNavigationProperty)) { @@ -111,7 +111,7 @@ namespace Avalonia.Controls.Presenters private Vector CoerceOffset(Vector value) { - var scrollable = (IScrollable)this; + var scrollable = (ILogicalScrollable)this; var maxX = Math.Max(scrollable.Extent.Width - scrollable.Viewport.Width, 0); var maxY = Math.Max(scrollable.Extent.Height - scrollable.Viewport.Height, 0); return new Vector(Clamp(value.X, 0, maxX), Clamp(value.Y, 0, maxY)); diff --git a/src/Avalonia.Controls/Presenters/ScrollContentPresenter.cs b/src/Avalonia.Controls/Presenters/ScrollContentPresenter.cs index 4c7a00f6fd..4594e31ac8 100644 --- a/src/Avalonia.Controls/Presenters/ScrollContentPresenter.cs +++ b/src/Avalonia.Controls/Presenters/ScrollContentPresenter.cs @@ -117,7 +117,7 @@ namespace Avalonia.Controls.Presenters return false; } - var scrollable = Child as IScrollable; + var scrollable = Child as ILogicalScrollable; if (scrollable?.IsLogicalScrollEnabled == true) { @@ -231,7 +231,7 @@ namespace Avalonia.Controls.Presenters { if (Extent.Height > Viewport.Height) { - var scrollable = Child as IScrollable; + var scrollable = Child as ILogicalScrollable; if (scrollable?.IsLogicalScrollEnabled == true) { @@ -259,7 +259,7 @@ namespace Avalonia.Controls.Presenters private void UpdateScrollableSubscription(IControl child) { - var scrollable = child as IScrollable; + var scrollable = child as ILogicalScrollable; _scrollableSubscription?.Dispose(); _scrollableSubscription = null; @@ -278,7 +278,7 @@ namespace Avalonia.Controls.Presenters } } - private void UpdateFromScrollable(IScrollable scrollable) + private void UpdateFromScrollable(ILogicalScrollable scrollable) { var logicalScroll = _scrollableSubscription != null; diff --git a/src/Avalonia.Controls/Primitives/IScrollable.cs b/src/Avalonia.Controls/Primitives/ILogicalScrollable.cs similarity index 96% rename from src/Avalonia.Controls/Primitives/IScrollable.cs rename to src/Avalonia.Controls/Primitives/ILogicalScrollable.cs index b9155054b8..8c55e1d4a2 100644 --- a/src/Avalonia.Controls/Primitives/IScrollable.cs +++ b/src/Avalonia.Controls/Primitives/ILogicalScrollable.cs @@ -17,7 +17,7 @@ namespace Avalonia.Controls.Primitives /// whereas logical scrolling means that the scrolling is handled by the child control itself /// and it can choose to do handle the scroll information as it sees fit. /// - public interface IScrollable + public interface ILogicalScrollable { /// /// Gets a value indicating whether logical scrolling is enabled on the control. @@ -34,7 +34,7 @@ namespace Avalonia.Controls.Primitives /// /// /// This property is set by the parent when the - /// is placed inside it. + /// is placed inside it. /// /// Action InvalidateScroll { get; set; } diff --git a/tests/Avalonia.Controls.UnitTests/Presenters/ItemsPresenterTests_Virtualization.cs b/tests/Avalonia.Controls.UnitTests/Presenters/ItemsPresenterTests_Virtualization.cs index 2bdead4c7e..66bf70efb4 100644 --- a/tests/Avalonia.Controls.UnitTests/Presenters/ItemsPresenterTests_Virtualization.cs +++ b/tests/Avalonia.Controls.UnitTests/Presenters/ItemsPresenterTests_Virtualization.cs @@ -21,7 +21,7 @@ namespace Avalonia.Controls.UnitTests.Presenters target.ApplyTemplate(); - Assert.False(((IScrollable)target).IsLogicalScrollEnabled); + Assert.False(((ILogicalScrollable)target).IsLogicalScrollEnabled); } [Fact] @@ -31,7 +31,7 @@ namespace Avalonia.Controls.UnitTests.Presenters target.ApplyTemplate(); - Assert.False(((IScrollable)target).IsLogicalScrollEnabled); + Assert.False(((ILogicalScrollable)target).IsLogicalScrollEnabled); } [Fact] @@ -46,7 +46,7 @@ namespace Avalonia.Controls.UnitTests.Presenters target.ApplyTemplate(); - Assert.False(((IScrollable)target).IsLogicalScrollEnabled); + Assert.False(((ILogicalScrollable)target).IsLogicalScrollEnabled); } [Fact] @@ -56,7 +56,7 @@ namespace Avalonia.Controls.UnitTests.Presenters target.ApplyTemplate(); - Assert.True(((IScrollable)target).IsLogicalScrollEnabled); + Assert.True(((ILogicalScrollable)target).IsLogicalScrollEnabled); } [Fact] @@ -130,7 +130,7 @@ namespace Avalonia.Controls.UnitTests.Presenters target.ApplyTemplate(); - Assert.Equal(new Size(0, 20), ((IScrollable)target).Extent); + Assert.Equal(new Size(0, 20), ((ILogicalScrollable)target).Extent); } [Fact] @@ -140,7 +140,7 @@ namespace Avalonia.Controls.UnitTests.Presenters target.ApplyTemplate(); - Assert.Equal(new Size(20, 0), ((IScrollable)target).Extent); + Assert.Equal(new Size(20, 0), ((ILogicalScrollable)target).Extent); } [Fact] @@ -152,7 +152,7 @@ namespace Avalonia.Controls.UnitTests.Presenters target.Measure(new Size(100, 100)); target.Arrange(new Rect(0, 0, 100, 100)); - Assert.Equal(new Size(0, 10), ((IScrollable)target).Viewport); + Assert.Equal(new Size(0, 10), ((ILogicalScrollable)target).Viewport); } [Fact] @@ -164,7 +164,7 @@ namespace Avalonia.Controls.UnitTests.Presenters target.Measure(new Size(100, 100)); target.Arrange(new Rect(0, 0, 100, 100)); - Assert.Equal(new Size(10, 0), ((IScrollable)target).Viewport); + Assert.Equal(new Size(10, 0), ((ILogicalScrollable)target).Viewport); } [Fact] @@ -206,7 +206,7 @@ namespace Avalonia.Controls.UnitTests.Presenters .Take(5) .Concat(containers.Take(5)).ToList(); - Assert.Equal(new Vector(0, 5), ((IScrollable)target).Offset); + Assert.Equal(new Vector(0, 5), ((ILogicalScrollable)target).Offset); Assert.Equal(scrolledContainers, target.Panel.Children); for (var i = 0; i < target.Panel.Children.Count; ++i) @@ -215,7 +215,7 @@ namespace Avalonia.Controls.UnitTests.Presenters } scroller.Offset = new Vector(0, 0); - Assert.Equal(new Vector(0, 0), ((IScrollable)target).Offset); + Assert.Equal(new Vector(0, 0), ((ILogicalScrollable)target).Offset); Assert.Equal(containers, target.Panel.Children); var dcs = target.Panel.Children.Select(x => x.DataContext).ToList(); @@ -241,7 +241,7 @@ namespace Avalonia.Controls.UnitTests.Presenters scroller.Offset = new Vector(0, 20); - Assert.Equal(new Vector(0, 20), ((IScrollable)target).Offset); + Assert.Equal(new Vector(0, 20), ((ILogicalScrollable)target).Offset); Assert.Equal(containers, target.Panel.Children); for (var i = 0; i < target.Panel.Children.Count; ++i) diff --git a/tests/Avalonia.Controls.UnitTests/Presenters/ScrollContentPresenterTests_IScrollable.cs b/tests/Avalonia.Controls.UnitTests/Presenters/ScrollContentPresenterTests_IScrollable.cs index a690522e89..d0c6a386ac 100644 --- a/tests/Avalonia.Controls.UnitTests/Presenters/ScrollContentPresenterTests_IScrollable.cs +++ b/tests/Avalonia.Controls.UnitTests/Presenters/ScrollContentPresenterTests_IScrollable.cs @@ -237,7 +237,7 @@ namespace Avalonia.Controls.UnitTests Assert.Equal(new Rect(0, 0, 100, 100), scrollable.Bounds); } - private class TestScrollable : Control, IScrollable + private class TestScrollable : Control, ILogicalScrollable { private Size _extent; private Vector _offset;