Browse Source

Added IScrollable interface.

This is now the basic Extent/Offset/Viewport interface. Implemented by
ScrollViewer and ScrollContentPresenter.
pull/554/head
Steven Kirk 10 years ago
parent
commit
d346b35ab7
  1. 6
      samples/XamlTestApplicationPcl/TestScrollable.cs
  2. 1
      src/Avalonia.Controls/Avalonia.Controls.csproj
  3. 29
      src/Avalonia.Controls/IScrollable.cs
  4. 12
      src/Avalonia.Controls/Presenters/ItemsPresenter.cs
  5. 2
      src/Avalonia.Controls/Presenters/ScrollContentPresenter.cs
  6. 20
      src/Avalonia.Controls/Primitives/ILogicalScrollable.cs
  7. 2
      src/Avalonia.Controls/ScrollViewer.cs

6
samples/XamlTestApplicationPcl/TestScrollable.cs

@ -18,12 +18,12 @@ namespace XamlTestApplication
public bool IsLogicalScrollEnabled => true;
public Action InvalidateScroll { get; set; }
Size ILogicalScrollable.Extent
Size IScrollable.Extent
{
get { return _extent; }
}
Vector ILogicalScrollable.Offset
Vector IScrollable.Offset
{
get { return _offset; }
@ -34,7 +34,7 @@ namespace XamlTestApplication
}
}
Size ILogicalScrollable.Viewport
Size IScrollable.Viewport
{
get { return _viewport; }
}

1
src/Avalonia.Controls/Avalonia.Controls.csproj

@ -54,6 +54,7 @@
<Compile Include="Generators\TreeContainerIndex.cs" />
<Compile Include="HotkeyManager.cs" />
<Compile Include="IApplicationLifecycle.cs" />
<Compile Include="IScrollable.cs" />
<Compile Include="INameScope.cs" />
<Compile Include="IPseudoClasses.cs" />
<Compile Include="DropDownItem.cs" />

29
src/Avalonia.Controls/IScrollable.cs

@ -0,0 +1,29 @@
// Copyright (c) The Avalonia Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using Avalonia.VisualTree;
namespace Avalonia.Controls.Primitives
{
/// <summary>
/// Interface implemented by scrollable controls.
/// </summary>
public interface IScrollable
{
/// <summary>
/// Gets the extent of the scrollable content, in logical units
/// </summary>
Size Extent { get; }
/// <summary>
/// Gets or sets the current scroll offset, in logical units.
/// </summary>
Vector Offset { get; set; }
/// <summary>
/// Gets the size of the viewport, in logical units.
/// </summary>
Size Viewport { get; }
}
}

12
src/Avalonia.Controls/Presenters/ItemsPresenter.cs

@ -51,20 +51,20 @@ namespace Avalonia.Controls.Presenters
}
/// <inheritdoc/>
Action ILogicalScrollable.InvalidateScroll { get; set; }
/// <inheritdoc/>
Size ILogicalScrollable.Extent => _virtualizer.Extent;
Size IScrollable.Extent => _virtualizer.Extent;
/// <inheritdoc/>
Vector ILogicalScrollable.Offset
Vector IScrollable.Offset
{
get { return _virtualizer.Offset; }
set { _virtualizer.Offset = CoerceOffset(value); }
}
/// <inheritdoc/>
Size ILogicalScrollable.Viewport => _virtualizer.Viewport;
Size IScrollable.Viewport => _virtualizer.Viewport;
/// <inheritdoc/>
Action ILogicalScrollable.InvalidateScroll { get; set; }
/// <inheritdoc/>
Size ILogicalScrollable.ScrollSize => new Size(0, 1);

2
src/Avalonia.Controls/Presenters/ScrollContentPresenter.cs

@ -15,7 +15,7 @@ namespace Avalonia.Controls.Presenters
/// <summary>
/// Presents a scrolling view of content inside a <see cref="ScrollViewer"/>.
/// </summary>
public class ScrollContentPresenter : ContentPresenter, IPresenter
public class ScrollContentPresenter : ContentPresenter, IPresenter, IScrollable
{
/// <summary>
/// Defines the <see cref="Extent"/> property.

20
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 ILogicalScrollable
public interface ILogicalScrollable : IScrollable
{
/// <summary>
/// Gets a value indicating whether logical scrolling is enabled on the control.
@ -30,7 +30,8 @@ namespace Avalonia.Controls.Primitives
/// <remarks>
/// <para>
/// This method notifies the attached <see cref="ScrollViewer"/> of a change in
/// the <see cref="Extent"/>, <see cref="Offset"/> or <see cref="Viewport"/> properties.
/// the <see cref="IScrollable.Extent"/>, <see cref="IScrollable.Offset"/> or
/// <see cref="IScrollable.Viewport"/> properties.
/// </para>
/// <para>
/// This property is set by the parent <see cref="ScrollViewer"/> when the
@ -39,21 +40,6 @@ namespace Avalonia.Controls.Primitives
/// </remarks>
Action InvalidateScroll { get; set; }
/// <summary>
/// Gets the extent of the scrollable content, in logical units
/// </summary>
Size Extent { get; }
/// <summary>
/// Gets or sets the current scroll offset, in logical units.
/// </summary>
Vector Offset { get; set; }
/// <summary>
/// Gets the size of the viewport, in logical units.
/// </summary>
Size Viewport { get; }
/// <summary>
/// Gets the size to scroll by, in logical units.
/// </summary>

2
src/Avalonia.Controls/ScrollViewer.cs

@ -12,7 +12,7 @@ namespace Avalonia.Controls
/// <summary>
/// A control scrolls its content if the content is bigger than the space available.
/// </summary>
public class ScrollViewer : ContentControl
public class ScrollViewer : ContentControl, IScrollable
{
/// <summary>
/// Defines the <see cref="CanScrollHorizontally"/> property.

Loading…
Cancel
Save