Browse Source

Renamed IScrollable -> ILogicalScrollable

We're going to need IScrollable as an interface to ScrollViewer-type
controls.
Steven Kirk 9 years ago
parent
commit
b44589e0cb

+ 3 - 1
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

+ 4 - 4
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; }
         }

+ 1 - 1
src/Avalonia.Controls/Avalonia.Controls.csproj

@@ -74,7 +74,7 @@
     <Compile Include="Presenters\ItemVirtualizerSimple.cs" />
     <Compile Include="Presenters\ItemVirtualizer.cs" />
     <Compile Include="Primitives\HeaderedSelectingControl.cs" />
-    <Compile Include="Primitives\IScrollable.cs" />
+    <Compile Include="Primitives\ILogicalScrollable.cs" />
     <Compile Include="Primitives\TabStripItem.cs" />
     <Compile Include="Primitives\TemplateAppliedEventArgs.cs" />
     <Compile Include="SelectionChangedEventArgs.cs" />

+ 1 - 1
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)
             {

+ 2 - 2
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()

+ 11 - 11
src/Avalonia.Controls/Presenters/ItemsPresenter.cs

@@ -13,7 +13,7 @@ namespace Avalonia.Controls.Presenters
     /// <summary>
     /// Displays items inside an <see cref="ItemsControl"/>.
     /// </summary>
-    public class ItemsPresenter : ItemsPresenterBase, IScrollable
+    public class ItemsPresenter : ItemsPresenterBase, ILogicalScrollable
     {
         /// <summary>
         /// Defines the <see cref="VirtualizationMode"/> property.
@@ -45,35 +45,35 @@ namespace Avalonia.Controls.Presenters
         }
 
         /// <inheritdoc/>
-        bool IScrollable.IsLogicalScrollEnabled
+        bool ILogicalScrollable.IsLogicalScrollEnabled
         {
             get { return _virtualizer?.IsLogicalScrollEnabled ?? false; }
         }
 
         /// <inheritdoc/>
-        Action IScrollable.InvalidateScroll { get; set; }
+        Action ILogicalScrollable.InvalidateScroll { get; set; }
 
         /// <inheritdoc/>
-        Size IScrollable.Extent => _virtualizer.Extent;
+        Size ILogicalScrollable.Extent => _virtualizer.Extent;
 
         /// <inheritdoc/>
-        Vector IScrollable.Offset
+        Vector ILogicalScrollable.Offset
         {
             get { return _virtualizer.Offset; }
             set { _virtualizer.Offset = CoerceOffset(value); }
         }
 
         /// <inheritdoc/>
-        Size IScrollable.Viewport => _virtualizer.Viewport;
+        Size ILogicalScrollable.Viewport => _virtualizer.Viewport;
 
         /// <inheritdoc/>
-        Size IScrollable.ScrollSize => new Size(0, 1);
+        Size ILogicalScrollable.ScrollSize => new Size(0, 1);
 
         /// <inheritdoc/>
-        Size IScrollable.PageScrollSize => new Size(0, 1);
+        Size ILogicalScrollable.PageScrollSize => new Size(0, 1);
 
         /// <inheritdoc/>
-        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));

+ 4 - 4
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;
 

+ 2 - 2
src/Avalonia.Controls/Primitives/IScrollable.cs → 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.
     /// </remarks>
-    public interface IScrollable
+    public interface ILogicalScrollable
     {
         /// <summary>
         /// Gets a value indicating whether logical scrolling is enabled on the control.
@@ -34,7 +34,7 @@ namespace Avalonia.Controls.Primitives
         /// </para>
         /// <para>
         /// This property is set by the parent <see cref="ScrollViewer"/> when the 
-        /// <see cref="IScrollable"/> is placed inside it.
+        /// <see cref="ILogicalScrollable"/> is placed inside it.
         /// </para>
         /// </remarks>
         Action InvalidateScroll { get; set; }

+ 11 - 11
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)

+ 1 - 1
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;