Browse Source

Merge branch 'master' into features/Controls/ScrollViewer/Add_Page_Scroll_Methods

pull/4667/head
Steven Kirk 6 years ago
committed by GitHub
parent
commit
9cf791f46b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .gitignore
  2. 5
      .ncrunch/Sandbox.v3.ncrunchproject
  3. 52
      Avalonia.sln
  4. 1
      nukebuild/Build.cs
  5. 8
      samples/Sandbox/App.axaml
  6. 22
      samples/Sandbox/App.axaml.cs
  7. 4
      samples/Sandbox/MainWindow.axaml
  8. 20
      samples/Sandbox/MainWindow.axaml.cs
  9. 17
      samples/Sandbox/Program.cs
  10. 18
      samples/Sandbox/Sandbox.csproj
  11. 8
      src/Avalonia.Controls.DataGrid/DataGridBoundColumn.cs
  12. 7
      src/Avalonia.Controls/Selection/SelectionModel.cs
  13. 2
      src/Avalonia.ReactiveUI.Events/Avalonia.ReactiveUI.Events.csproj
  14. 9
      src/Avalonia.Visuals/Rendering/SleepLoopRenderTimer.cs
  15. 82
      tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests.cs
  16. 15
      tests/Avalonia.ReactiveUI.Events.UnitTests/Avalonia.ReactiveUI.Events.UnitTests.csproj
  17. 44
      tests/Avalonia.ReactiveUI.Events.UnitTests/BasicControlEventsTest.cs

1
.gitignore

@ -117,6 +117,7 @@ ClientBin/
*.[Pp]ublish.xml
*.pfx
*.publishsettings
Events_Avalonia.cs
# RIA/Silverlight projects
Generated_Code/

5
.ncrunch/Sandbox.v3.ncrunchproject

@ -0,0 +1,5 @@
<ProjectConfiguration>
<Settings>
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely>
</Settings>
</ProjectConfiguration>

52
Avalonia.sln

@ -224,7 +224,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Markup.Xaml.Loader
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.ReactiveUI.Events", "src\Avalonia.ReactiveUI.Events\Avalonia.ReactiveUI.Events.csproj", "{28F18757-C3E6-4BBE-A37D-11BA2AB9177C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.ReactiveUI.Events.UnitTests", "tests\Avalonia.ReactiveUI.Events.UnitTests\Avalonia.ReactiveUI.Events.UnitTests.csproj", "{780AC0FE-8DD2-419F-A1DC-AC7E3EB393F7}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sandbox", "samples\Sandbox\Sandbox.csproj", "{11BE52AF-E2DD-4CF0-B19A-05285ACAF571}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
@ -2040,30 +2040,30 @@ Global
{28F18757-C3E6-4BBE-A37D-11BA2AB9177C}.Release|iPhone.Build.0 = Release|Any CPU
{28F18757-C3E6-4BBE-A37D-11BA2AB9177C}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{28F18757-C3E6-4BBE-A37D-11BA2AB9177C}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{780AC0FE-8DD2-419F-A1DC-AC7E3EB393F7}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{780AC0FE-8DD2-419F-A1DC-AC7E3EB393F7}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{780AC0FE-8DD2-419F-A1DC-AC7E3EB393F7}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
{780AC0FE-8DD2-419F-A1DC-AC7E3EB393F7}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
{780AC0FE-8DD2-419F-A1DC-AC7E3EB393F7}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{780AC0FE-8DD2-419F-A1DC-AC7E3EB393F7}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
{780AC0FE-8DD2-419F-A1DC-AC7E3EB393F7}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{780AC0FE-8DD2-419F-A1DC-AC7E3EB393F7}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{780AC0FE-8DD2-419F-A1DC-AC7E3EB393F7}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{780AC0FE-8DD2-419F-A1DC-AC7E3EB393F7}.AppStore|iPhone.Build.0 = Debug|Any CPU
{780AC0FE-8DD2-419F-A1DC-AC7E3EB393F7}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{780AC0FE-8DD2-419F-A1DC-AC7E3EB393F7}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
{780AC0FE-8DD2-419F-A1DC-AC7E3EB393F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{780AC0FE-8DD2-419F-A1DC-AC7E3EB393F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{780AC0FE-8DD2-419F-A1DC-AC7E3EB393F7}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{780AC0FE-8DD2-419F-A1DC-AC7E3EB393F7}.Debug|iPhone.Build.0 = Debug|Any CPU
{780AC0FE-8DD2-419F-A1DC-AC7E3EB393F7}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{780AC0FE-8DD2-419F-A1DC-AC7E3EB393F7}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{780AC0FE-8DD2-419F-A1DC-AC7E3EB393F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{780AC0FE-8DD2-419F-A1DC-AC7E3EB393F7}.Release|Any CPU.Build.0 = Release|Any CPU
{780AC0FE-8DD2-419F-A1DC-AC7E3EB393F7}.Release|iPhone.ActiveCfg = Release|Any CPU
{780AC0FE-8DD2-419F-A1DC-AC7E3EB393F7}.Release|iPhone.Build.0 = Release|Any CPU
{780AC0FE-8DD2-419F-A1DC-AC7E3EB393F7}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{780AC0FE-8DD2-419F-A1DC-AC7E3EB393F7}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU
{11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU
{11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU
{11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU
{11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU
{11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU
{11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
{11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.AppStore|Any CPU.Build.0 = Release|Any CPU
{11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.AppStore|iPhone.ActiveCfg = Release|Any CPU
{11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.AppStore|iPhone.Build.0 = Release|Any CPU
{11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU
{11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU
{11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.Debug|Any CPU.Build.0 = Debug|Any CPU
{11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.Debug|iPhone.Build.0 = Debug|Any CPU
{11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.Release|Any CPU.ActiveCfg = Release|Any CPU
{11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.Release|Any CPU.Build.0 = Release|Any CPU
{11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.Release|iPhone.ActiveCfg = Release|Any CPU
{11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.Release|iPhone.Build.0 = Release|Any CPU
{11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -2122,7 +2122,7 @@ Global
{351337F5-D66F-461B-A957-4EF60BDB4BA6} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B}
{3C84E04B-36CF-4D0D-B965-C26DD649D1F3} = {A0CC0258-D18C-4AB3-854F-7101680FC3F9}
{909A8CBD-7D0E-42FD-B841-022AD8925820} = {8B6A8209-894F-4BA1-B880-965FD453982C}
{780AC0FE-8DD2-419F-A1DC-AC7E3EB393F7} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B}
{11BE52AF-E2DD-4CF0-B19A-05285ACAF571} = {9B9E3891-2366-4253-A952-D08BCEB71098}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {87366D66-1391-4D90-8999-95A620AD786A}

1
nukebuild/Build.cs

@ -241,7 +241,6 @@ partial class Build : NukeBuild
RunCoreTest("Avalonia.Visuals.UnitTests");
RunCoreTest("Avalonia.Skia.UnitTests");
RunCoreTest("Avalonia.ReactiveUI.UnitTests");
RunCoreTest("Avalonia.ReactiveUI.Events.UnitTests");
});
Target RunRenderTests => _ => _

8
samples/Sandbox/App.axaml

@ -0,0 +1,8 @@
<Application
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="Sandbox.App">
<Application.Styles>
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Accents/FluentDark.xaml"/>
</Application.Styles>
</Application>

22
samples/Sandbox/App.axaml.cs

@ -0,0 +1,22 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
namespace Sandbox
{
public class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktopLifetime)
{
desktopLifetime.MainWindow = new MainWindow();
}
}
}
}

4
samples/Sandbox/MainWindow.axaml

@ -0,0 +1,4 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
x:Class="Sandbox.MainWindow">
</Window>

20
samples/Sandbox/MainWindow.axaml.cs

@ -0,0 +1,20 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace Sandbox
{
public class MainWindow : Window
{
public MainWindow()
{
this.InitializeComponent();
this.AttachDevTools();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
}

17
samples/Sandbox/Program.cs

@ -0,0 +1,17 @@
using Avalonia;
using Avalonia.ReactiveUI;
namespace Sandbox
{
public class Program
{
static void Main(string[] args)
{
AppBuilder.Configure<App>()
.UsePlatformDetect()
.UseReactiveUI()
.LogToDebug()
.StartWithClassicDesktopLifetime(args);
}
}
}

18
samples/Sandbox/Sandbox.csproj

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj" />
<ProjectReference Include="..\..\src\Avalonia.ReactiveUI\Avalonia.ReactiveUI.csproj" />
<ProjectReference Include="..\..\src\Avalonia.Controls.DataGrid\Avalonia.Controls.DataGrid.csproj" />
</ItemGroup>
<Import Project="..\..\build\SampleApp.props" />
<Import Project="..\..\build\ReferenceCoreLibraries.props" />
<Import Project="..\..\build\BuildTargets.targets" />
</Project>

8
src/Avalonia.Controls.DataGrid/DataGridBoundColumn.cs

@ -49,8 +49,12 @@ namespace Avalonia.Controls
{
if(_binding is Avalonia.Data.Binding binding)
{
// Force the TwoWay binding mode if there is a Path present. TwoWay binding requires a Path.
if (!String.IsNullOrEmpty(binding.Path))
if (binding.Mode == BindingMode.OneWayToSource)
{
throw new InvalidOperationException("DataGridColumn doesn't support BindingMode.OneWayToSource. Use BindingMode.TwoWay instead.");
}
if (!String.IsNullOrEmpty(binding.Path) && binding.Mode == BindingMode.Default)
{
binding.Mode = BindingMode.TwoWay;
}

7
src/Avalonia.Controls/Selection/SelectionModel.cs

@ -242,12 +242,7 @@ namespace Avalonia.Controls.Selection
{
using var update = BatchUpdate();
var o = update.Operation;
var range = CoerceRange(start, end);
if (range.Begin == -1)
{
return;
}
var range = new IndexRange(Math.Max(0, start), end);
if (RangesEnabled)
{

2
src/Avalonia.ReactiveUI.Events/Avalonia.ReactiveUI.Events.csproj

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<PackageId>Avalonia.ReactiveUI</PackageId>
<PackageId>Avalonia.ReactiveUI.Events</PackageId>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\packages\Avalonia\Avalonia.csproj" />

9
src/Avalonia.Visuals/Rendering/SleepLoopRenderTimer.cs

@ -45,14 +45,13 @@ namespace Avalonia.Rendering
void LoopProc()
{
var now = _st.Elapsed;
var lastTick = now;
var lastTick = _st.Elapsed;
while (true)
{
var now = _st.Elapsed;
var timeTillNextTick = lastTick + _timeBetweenTicks - now;
if (timeTillNextTick.TotalMilliseconds > 1) Thread.Sleep(timeTillNextTick);
lastTick = now;
lock (_lock)
{
if (_count == 0)
@ -63,7 +62,7 @@ namespace Avalonia.Rendering
}
_tick?.Invoke(now);
now = _st.Elapsed;
}
}

82
tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests.cs

@ -1813,6 +1813,88 @@ namespace Avalonia.Controls.UnitTests.Primitives
Assert.Equal(1, raised);
}
[Fact]
public void Handles_Removing_Last_Item_In_Two_Controls_With_Bound_SelectedIndex()
{
var items = new ObservableCollection<string> { "foo" };
// Simulates problem with TabStrip and Carousel with bound SelectedIndex.
var tabStrip = new TestSelector
{
Items = items,
SelectionMode = SelectionMode.AlwaysSelected,
};
var carousel = new TestSelector
{
Items = items,
[!Carousel.SelectedIndexProperty] = tabStrip[!TabStrip.SelectedIndexProperty],
};
var tabStripRaised = 0;
var carouselRaised = 0;
tabStrip.SelectionChanged += (s, e) =>
{
Assert.Equal(new[] { "foo" }, e.RemovedItems);
Assert.Empty(e.AddedItems);
++tabStripRaised;
};
carousel.SelectionChanged += (s, e) =>
{
Assert.Equal(new[] { "foo" }, e.RemovedItems);
Assert.Empty(e.AddedItems);
++carouselRaised;
};
items.RemoveAt(0);
Assert.Equal(1, tabStripRaised);
Assert.Equal(1, carouselRaised);
}
[Fact]
public void Handles_Removing_Last_Item_In_Controls_With_Bound_SelectedItem()
{
var items = new ObservableCollection<string> { "foo" };
// Simulates problem with TabStrip and Carousel with bound SelectedItem.
var tabStrip = new TestSelector
{
Items = items,
SelectionMode = SelectionMode.AlwaysSelected,
};
var carousel = new TestSelector
{
Items = items,
[!Carousel.SelectedItemProperty] = tabStrip[!TabStrip.SelectedItemProperty],
};
var tabStripRaised = 0;
var carouselRaised = 0;
tabStrip.SelectionChanged += (s, e) =>
{
Assert.Equal(new[] { "foo" }, e.RemovedItems);
Assert.Empty(e.AddedItems);
++tabStripRaised;
};
carousel.SelectionChanged += (s, e) =>
{
Assert.Equal(new[] { "foo" }, e.RemovedItems);
Assert.Empty(e.AddedItems);
++carouselRaised;
};
items.RemoveAt(0);
Assert.Equal(1, tabStripRaised);
Assert.Equal(1, carouselRaised);
}
private static void Prepare(SelectingItemsControl target)
{
var root = new TestRoot

15
tests/Avalonia.ReactiveUI.Events.UnitTests/Avalonia.ReactiveUI.Events.UnitTests.csproj

@ -1,15 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<Import Project="..\..\build\UnitTests.NetCore.targets" />
<Import Project="..\..\build\Moq.props" />
<Import Project="..\..\build\XUnit.props" />
<Import Project="..\..\build\Rx.props" />
<Import Project="..\..\build\Microsoft.Reactive.Testing.props" />
<ItemGroup>
<ProjectReference Include="..\..\src\Markup\Avalonia.Markup.Xaml.Loader\Avalonia.Markup.Xaml.Loader.csproj" />
<ProjectReference Include="..\Avalonia.UnitTests\Avalonia.UnitTests.csproj" />
<ProjectReference Include="..\..\src\Avalonia.ReactiveUI.Events\Avalonia.ReactiveUI.Events.csproj" />
</ItemGroup>
</Project>

44
tests/Avalonia.ReactiveUI.Events.UnitTests/BasicControlEventsTest.cs

@ -1,44 +0,0 @@
using System;
using System.Reactive.Linq;
using Avalonia.Controls;
using Avalonia.UnitTests;
using Xunit;
namespace Avalonia.ReactiveUI.Events.UnitTests
{
public class BasicControlEventsTest
{
public class EventsControl : UserControl
{
public bool IsAttached { get; private set; }
public EventsControl()
{
var attached = this
.Events()
.AttachedToVisualTree
.Select(args => true);
this.Events()
.DetachedFromVisualTree
.Select(args => false)
.Merge(attached)
.Subscribe(marker => IsAttached = marker);
}
}
[Fact]
public void Should_Generate_Events_Wrappers()
{
var root = new TestRoot();
var control = new EventsControl();
Assert.False(control.IsAttached);
root.Child = control;
Assert.True(control.IsAttached);
root.Child = null;
Assert.False(control.IsAttached);
}
}
}
Loading…
Cancel
Save