Browse Source

Merge branch 'master' into fix/remove-mouse-capture-from-calendar-picker

pull/4812/head
danwalmsley 6 years ago
committed by GitHub
parent
commit
559e8a4634
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      samples/ControlCatalog/App.xaml.cs
  2. 2
      samples/ControlCatalog/MainView.xaml
  3. 4
      samples/ControlCatalog/MainView.xaml.cs
  4. 12
      src/Avalonia.Base/AvaloniaObject.cs
  5. 4
      src/Avalonia.Controls/MenuItem.cs
  6. 18
      src/Avalonia.Controls/Platform/DefaultMenuInteractionHandler.cs
  7. 3
      src/Avalonia.Controls/Presenters/TextPresenter.cs
  8. 2
      src/Avalonia.Themes.Fluent/Accents/Base.xaml
  9. BIN
      src/Avalonia.Themes.Fluent/Assets/Inter-Bold.ttf
  10. BIN
      src/Avalonia.Themes.Fluent/Assets/Inter-ExtraLight.ttf
  11. BIN
      src/Avalonia.Themes.Fluent/Assets/Inter-Light.ttf
  12. BIN
      src/Avalonia.Themes.Fluent/Assets/Inter-Medium.ttf
  13. BIN
      src/Avalonia.Themes.Fluent/Assets/Inter-Regular.ttf
  14. BIN
      src/Avalonia.Themes.Fluent/Assets/Inter-SemiBold.ttf
  15. BIN
      src/Avalonia.Themes.Fluent/Assets/Inter-Thin.ttf
  16. BIN
      src/Avalonia.Themes.Fluent/Assets/Roboto-Black.ttf
  17. BIN
      src/Avalonia.Themes.Fluent/Assets/Roboto-Bold.ttf
  18. BIN
      src/Avalonia.Themes.Fluent/Assets/Roboto-Light.ttf
  19. BIN
      src/Avalonia.Themes.Fluent/Assets/Roboto-Medium.ttf
  20. BIN
      src/Avalonia.Themes.Fluent/Assets/Roboto-Regular.ttf
  21. BIN
      src/Avalonia.Themes.Fluent/Assets/Roboto-Thin.ttf
  22. 61
      src/Avalonia.Visuals/Animation/CompositePageTransition.cs
  23. 29
      src/Avalonia.Visuals/Animation/CrossFade.cs
  24. 44
      src/Avalonia.Visuals/Animation/PageSlide.cs
  25. 43
      src/Skia/Avalonia.Skia/DrawingContextImpl.cs
  26. 4
      src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs
  27. 124
      tests/Avalonia.RenderTests/Media/RadialGradientBrushTests.cs
  28. BIN
      tests/TestFiles/Direct2D1/Media/RadialGradientBrush/RadialGradientBrush_RedBlue_Offset_Inside.expected.png
  29. BIN
      tests/TestFiles/Direct2D1/Media/RadialGradientBrush/RadialGradientBrush_RedBlue_Offset_Outside.expected.png
  30. BIN
      tests/TestFiles/Direct2D1/Media/RadialGradientBrush/RadialGradientBrush_RedGreenBlue_Offset_Inside.expected.png
  31. BIN
      tests/TestFiles/Direct2D1/Media/RadialGradientBrush/RadialGradientBrush_RedGreenBlue_Offset_Outside.expected.png
  32. BIN
      tests/TestFiles/Skia/Media/RadialGradientBrush/RadialGradientBrush_RedBlue_Offset_Inside.expected.png
  33. BIN
      tests/TestFiles/Skia/Media/RadialGradientBrush/RadialGradientBrush_RedBlue_Offset_Outside.expected.png
  34. BIN
      tests/TestFiles/Skia/Media/RadialGradientBrush/RadialGradientBrush_RedGreenBlue_Offset_Inside.expected.png
  35. BIN
      tests/TestFiles/Skia/Media/RadialGradientBrush/RadialGradientBrush_RedGreenBlue_Offset_Outside.expected.png

2
samples/ControlCatalog/App.xaml.cs

@ -81,7 +81,7 @@ namespace ControlCatalog
public override void Initialize() public override void Initialize()
{ {
Styles.Insert(0, FluentDark); Styles.Insert(0, FluentLight);
AvaloniaXamlLoader.Load(this); AvaloniaXamlLoader.Load(this);
} }

2
samples/ControlCatalog/MainView.xaml

@ -77,8 +77,8 @@
<ComboBoxItem>Full Decorations</ComboBoxItem> <ComboBoxItem>Full Decorations</ComboBoxItem>
</ComboBox> </ComboBox>
<ComboBox x:Name="Themes" SelectedIndex="0"> <ComboBox x:Name="Themes" SelectedIndex="0">
<ComboBoxItem>Fluent - Dark</ComboBoxItem>
<ComboBoxItem>Fluent - Light</ComboBoxItem> <ComboBoxItem>Fluent - Light</ComboBoxItem>
<ComboBoxItem>Fluent - Dark</ComboBoxItem>
<ComboBoxItem>Simple - Light</ComboBoxItem> <ComboBoxItem>Simple - Light</ComboBoxItem>
<ComboBoxItem>Simple - Dark</ComboBoxItem> <ComboBoxItem>Simple - Dark</ComboBoxItem>
</ComboBox> </ComboBox>

4
samples/ControlCatalog/MainView.xaml.cs

@ -38,10 +38,10 @@ namespace ControlCatalog
switch (themes.SelectedIndex) switch (themes.SelectedIndex)
{ {
case 0: case 0:
Application.Current.Styles[0] = App.FluentDark; Application.Current.Styles[0] = App.FluentLight;
break; break;
case 1: case 1:
Application.Current.Styles[0] = App.FluentLight; Application.Current.Styles[0] = App.FluentDark;
break; break;
case 2: case 2:
Application.Current.Styles[0] = App.DefaultLight; Application.Current.Styles[0] = App.DefaultLight;

12
src/Avalonia.Base/AvaloniaObject.cs

@ -113,16 +113,8 @@ namespace Avalonia
/// <param name="binding">The binding information.</param> /// <param name="binding">The binding information.</param>
public IBinding this[IndexerDescriptor binding] public IBinding this[IndexerDescriptor binding]
{ {
get get { return new IndexerBinding(this, binding.Property, binding.Mode); }
{ set { this.Bind(binding.Property, value); }
return new IndexerBinding(this, binding.Property, binding.Mode);
}
set
{
var sourceBinding = value as IBinding;
this.Bind(binding.Property, sourceBinding);
}
} }
public bool CheckAccess() => Dispatcher.UIThread.CheckAccess(); public bool CheckAccess() => Dispatcher.UIThread.CheckAccess();

4
src/Avalonia.Controls/MenuItem.cs

@ -101,7 +101,7 @@ namespace Avalonia.Controls
private ICommand? _command; private ICommand? _command;
private bool _commandCanExecute = true; private bool _commandCanExecute = true;
private Popup _popup; private Popup? _popup;
/// <summary> /// <summary>
/// Initializes static members of the <see cref="MenuItem"/> class. /// Initializes static members of the <see cref="MenuItem"/> class.
@ -145,7 +145,7 @@ namespace Avalonia.Controls
{ {
var parent = x as Control; var parent = x as Control;
return parent?.GetObservable(DefinitionBase.PrivateSharedSizeScopeProperty) ?? return parent?.GetObservable(DefinitionBase.PrivateSharedSizeScopeProperty) ??
Observable.Return<DefinitionBase.SharedSizeScope>(null); Observable.Return<DefinitionBase.SharedSizeScope?>(null);
}); });
this.Bind(DefinitionBase.PrivateSharedSizeScopeProperty, parentSharedSizeScope); this.Bind(DefinitionBase.PrivateSharedSizeScopeProperty, parentSharedSizeScope);

18
src/Avalonia.Controls/Platform/DefaultMenuInteractionHandler.cs

@ -148,6 +148,7 @@ namespace Avalonia.Controls.Platform
{ {
case Key.Up: case Key.Up:
case Key.Down: case Key.Down:
{
if (item?.IsTopLevel == true) if (item?.IsTopLevel == true)
{ {
if (item.HasSubMenu && !item.IsSubMenuOpen) if (item.HasSubMenu && !item.IsSubMenuOpen)
@ -161,8 +162,10 @@ namespace Avalonia.Controls.Platform
goto default; goto default;
} }
break; break;
}
case Key.Left: case Key.Left:
{
if (item?.Parent is IMenuItem parent && !parent.IsTopLevel && parent.IsSubMenuOpen) if (item?.Parent is IMenuItem parent && !parent.IsTopLevel && parent.IsSubMenuOpen)
{ {
parent.Close(); parent.Close();
@ -174,8 +177,10 @@ namespace Avalonia.Controls.Platform
goto default; goto default;
} }
break; break;
}
case Key.Right: case Key.Right:
{
if (item != null && !item.IsTopLevel && item.HasSubMenu) if (item != null && !item.IsTopLevel && item.HasSubMenu)
{ {
Open(item, true); Open(item, true);
@ -186,8 +191,10 @@ namespace Avalonia.Controls.Platform
goto default; goto default;
} }
break; break;
}
case Key.Enter: case Key.Enter:
{
if (item != null) if (item != null)
{ {
if (!item.HasSubMenu) if (!item.HasSubMenu)
@ -202,12 +209,14 @@ namespace Avalonia.Controls.Platform
e.Handled = true; e.Handled = true;
} }
break; break;
}
case Key.Escape: case Key.Escape:
if (item?.Parent != null) {
if (item?.Parent is IMenuElement parent)
{ {
item.Parent.Close(); parent.Close();
item.Parent.Focus(); parent.Focus();
} }
else else
{ {
@ -216,8 +225,10 @@ namespace Avalonia.Controls.Platform
e.Handled = true; e.Handled = true;
break; break;
}
default: default:
{
var direction = e.Key.ToNavigationDirection(); var direction = e.Key.ToNavigationDirection();
if (direction.HasValue) if (direction.HasValue)
@ -246,6 +257,7 @@ namespace Avalonia.Controls.Platform
} }
break; break;
}
} }
if (!e.Handled && item?.Parent is IMenuItem parentItem) if (!e.Handled && item?.Parent is IMenuItem parentItem)

3
src/Avalonia.Controls/Presenters/TextPresenter.cs

@ -77,7 +77,8 @@ namespace Avalonia.Controls.Presenters
static TextPresenter() static TextPresenter()
{ {
AffectsRender<TextPresenter>(SelectionBrushProperty); AffectsRender<TextPresenter>(SelectionBrushProperty, TextBlock.ForegroundProperty,
SelectionForegroundBrushProperty, CaretBrushProperty);
AffectsMeasure<TextPresenter>(TextProperty, PasswordCharProperty, RevealPasswordProperty, AffectsMeasure<TextPresenter>(TextProperty, PasswordCharProperty, RevealPasswordProperty,
TextAlignmentProperty, TextWrappingProperty, TextBlock.FontSizeProperty, TextAlignmentProperty, TextWrappingProperty, TextBlock.FontSizeProperty,
TextBlock.FontStyleProperty, TextBlock.FontWeightProperty, TextBlock.FontFamilyProperty); TextBlock.FontStyleProperty, TextBlock.FontWeightProperty, TextBlock.FontFamilyProperty);

2
src/Avalonia.Themes.Fluent/Accents/Base.xaml

@ -12,7 +12,7 @@
<Color x:Key="SystemColorHotlightColor">#FF0066CC</Color> <Color x:Key="SystemColorHotlightColor">#FF0066CC</Color>
<Color x:Key="SystemColorWindowColor">#FFFFFFFF</Color> <Color x:Key="SystemColorWindowColor">#FFFFFFFF</Color>
<Color x:Key="SystemColorWindowTextColor">#FF000000</Color> <Color x:Key="SystemColorWindowTextColor">#FF000000</Color>
<FontFamily x:Key="ContentControlThemeFontFamily">avares://Avalonia.Themes.Fluent/Assets#Roboto</FontFamily> <FontFamily x:Key="ContentControlThemeFontFamily">avares://Avalonia.Themes.Fluent/Assets#Inter</FontFamily>
<sys:Double x:Key="ControlContentThemeFontSize">14</sys:Double> <sys:Double x:Key="ControlContentThemeFontSize">14</sys:Double>
<SolidColorBrush x:Key="SystemControlTransparentBrush" Color="Transparent" /> <SolidColorBrush x:Key="SystemControlTransparentBrush" Color="Transparent" />

BIN
src/Avalonia.Themes.Fluent/Assets/Inter-Bold.ttf

Binary file not shown.

BIN
src/Avalonia.Themes.Fluent/Assets/Inter-ExtraLight.ttf

Binary file not shown.

BIN
src/Avalonia.Themes.Fluent/Assets/Inter-Light.ttf

Binary file not shown.

BIN
src/Avalonia.Themes.Fluent/Assets/Inter-Medium.ttf

Binary file not shown.

BIN
src/Avalonia.Themes.Fluent/Assets/Inter-Regular.ttf

Binary file not shown.

BIN
src/Avalonia.Themes.Fluent/Assets/Inter-SemiBold.ttf

Binary file not shown.

BIN
src/Avalonia.Themes.Fluent/Assets/Inter-Thin.ttf

Binary file not shown.

BIN
src/Avalonia.Themes.Fluent/Assets/Roboto-Black.ttf

Binary file not shown.

BIN
src/Avalonia.Themes.Fluent/Assets/Roboto-Bold.ttf

Binary file not shown.

BIN
src/Avalonia.Themes.Fluent/Assets/Roboto-Light.ttf

Binary file not shown.

BIN
src/Avalonia.Themes.Fluent/Assets/Roboto-Medium.ttf

Binary file not shown.

BIN
src/Avalonia.Themes.Fluent/Assets/Roboto-Regular.ttf

Binary file not shown.

BIN
src/Avalonia.Themes.Fluent/Assets/Roboto-Thin.ttf

Binary file not shown.

61
src/Avalonia.Visuals/Animation/CompositePageTransition.cs

@ -0,0 +1,61 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Avalonia.Metadata;
namespace Avalonia.Animation
{
/// <summary>
/// Defines a composite page transition that can be used to combine multiple transitions.
/// </summary>
/// <remarks>
/// <para>
/// Instantiate the <see cref="CompositePageTransition" /> in XAML and initialize the
/// <see cref="Transitions" /> property in order to have many animations triggered at once.
/// For example, you can combine <see cref="CrossFade"/> and <see cref="PageSlide"/>.
/// <code>
/// <![CDATA[
/// <reactiveUi:RoutedViewHost Router="{Binding Router}">
/// <reactiveUi:RoutedViewHost.PageTransition>
/// <CompositePageTransition>
/// <PageSlide Duration="0.5" />
/// <CrossFade Duration="0.5" />
/// </CompositePageTransition>
/// </reactiveUi:RoutedViewHost.PageTransition>
/// </reactiveUi:RoutedViewHost>
/// ]]>
/// </code>
/// </para>
/// </remarks>
public class CompositePageTransition : IPageTransition
{
/// <summary>
/// Gets or sets the transitions to be executed. Can be defined from XAML.
/// </summary>
[Content]
public List<IPageTransition> PageTransitions { get; set; } = new List<IPageTransition>();
/// <summary>
/// Starts the animation.
/// </summary>
/// <param name="from">
/// The control that is being transitioned away from. May be null.
/// </param>
/// <param name="to">
/// The control that is being transitioned to. May be null.
/// </param>
/// <param name="forward">
/// Defines the direction of the transition.
/// </param>
/// <returns>
/// A <see cref="Task"/> that tracks the progress of the animation.
/// </returns>
public Task Start(Visual from, Visual to, bool forward)
{
var transitionTasks = PageTransitions
.Select(transition => transition.Start(from, to, forward))
.ToList();
return Task.WhenAll(transitionTasks);
}
}
}

29
src/Avalonia.Visuals/Animation/CrossFade.cs

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Avalonia.Animation.Easings;
using Avalonia.Styling; using Avalonia.Styling;
using Avalonia.VisualTree; using Avalonia.VisualTree;
@ -74,14 +75,26 @@ namespace Avalonia.Animation
/// </summary> /// </summary>
public TimeSpan Duration public TimeSpan Duration
{ {
get get => _fadeOutAnimation.Duration;
{ set => _fadeOutAnimation.Duration = _fadeInAnimation.Duration = value;
return _fadeOutAnimation.Duration; }
}
set /// <summary>
{ /// Gets or sets element entrance easing.
_fadeOutAnimation.Duration = _fadeInAnimation.Duration = value; /// </summary>
} public Easing FadeInEasing
{
get => _fadeInAnimation.Easing;
set => _fadeInAnimation.Easing = value;
}
/// <summary>
/// Gets or sets element exit easing.
/// </summary>
public Easing FadeOutEasing
{
get => _fadeOutAnimation.Easing;
set => _fadeOutAnimation.Easing = value;
} }
/// <summary> /// <summary>

44
src/Avalonia.Visuals/Animation/PageSlide.cs

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Avalonia.Animation.Easings;
using Avalonia.Media; using Avalonia.Media;
using Avalonia.Styling; using Avalonia.Styling;
using Avalonia.VisualTree; using Avalonia.VisualTree;
@ -48,6 +49,16 @@ namespace Avalonia.Animation
/// Gets the duration of the animation. /// Gets the duration of the animation.
/// </summary> /// </summary>
public SlideAxis Orientation { get; set; } public SlideAxis Orientation { get; set; }
/// <summary>
/// Gets or sets element entrance easing.
/// </summary>
public Easing SlideInEasing { get; set; } = new LinearEasing();
/// <summary>
/// Gets or sets element exit easing.
/// </summary>
public Easing SlideOutEasing { get; set; } = new LinearEasing();
/// <summary> /// <summary>
/// Starts the animation. /// Starts the animation.
@ -75,18 +86,12 @@ namespace Avalonia.Animation
{ {
var animation = new Animation var animation = new Animation
{ {
Children = Easing = SlideOutEasing,
Children =
{ {
new KeyFrame new KeyFrame
{ {
Setters = Setters = { new Setter { Property = translateProperty, Value = 0d } },
{
new Setter
{
Property = translateProperty,
Value = 0d
}
},
Cue = new Cue(0d) Cue = new Cue(0d)
}, },
new KeyFrame new KeyFrame
@ -100,10 +105,10 @@ namespace Avalonia.Animation
} }
}, },
Cue = new Cue(1d) Cue = new Cue(1d)
} }
} },
Duration = Duration
}; };
animation.Duration = Duration;
tasks.Add(animation.RunAsync(from)); tasks.Add(animation.RunAsync(from));
} }
@ -112,9 +117,9 @@ namespace Avalonia.Animation
to.IsVisible = true; to.IsVisible = true;
var animation = new Animation var animation = new Animation
{ {
Easing = SlideInEasing,
Children = Children =
{ {
new KeyFrame new KeyFrame
{ {
Setters = Setters =
@ -129,19 +134,12 @@ namespace Avalonia.Animation
}, },
new KeyFrame new KeyFrame
{ {
Setters = Setters = { new Setter { Property = translateProperty, Value = 0d } },
{
new Setter
{
Property = translateProperty,
Value = 0d
}
},
Cue = new Cue(1d) Cue = new Cue(1d)
} }
} },
Duration = Duration
}; };
animation.Duration = Duration;
tasks.Add(animation.RunAsync(to)); tasks.Add(animation.RunAsync(to));
} }

43
src/Skia/Avalonia.Skia/DrawingContextImpl.cs

@ -583,14 +583,45 @@ namespace Avalonia.Skia
var center = radialGradient.Center.ToPixels(targetSize).ToSKPoint(); var center = radialGradient.Center.ToPixels(targetSize).ToSKPoint();
var radius = (float)(radialGradient.Radius * targetSize.Width); var radius = (float)(radialGradient.Radius * targetSize.Width);
// TODO: There is no SetAlpha in SkiaSharp var origin = radialGradient.GradientOrigin.ToPixels(targetSize).ToSKPoint();
//paint.setAlpha(128);
// would be nice to cache these shaders possibly? if (origin.Equals(center))
using (var shader =
SKShader.CreateRadialGradient(center, radius, stopColors, stopOffsets, tileMode))
{ {
paintWrapper.Paint.Shader = shader; // when the origin is the same as the center the Skia RadialGradient acts the same as D2D
using (var shader =
SKShader.CreateRadialGradient(center, radius, stopColors, stopOffsets, tileMode))
{
paintWrapper.Paint.Shader = shader;
}
}
else
{
// when the origin is different to the center use a two point ConicalGradient to match the behaviour of D2D
// reverse the order of the stops to match D2D
var reversedColors = new SKColor[stopColors.Length];
Array.Copy(stopColors, reversedColors, stopColors.Length);
Array.Reverse(reversedColors);
// and then reverse the reference point of the stops
var reversedStops = new float[stopOffsets.Length];
for (var i = 0; i < stopOffsets.Length; i++)
{
reversedStops[i] = stopOffsets[i];
if (reversedStops[i] > 0 && reversedStops[i] < 1)
{
reversedStops[i] = Math.Abs(1 - stopOffsets[i]);
}
}
// compose with a background colour of the final stop to match D2D's behaviour of filling with the final color
using (var shader = SKShader.CreateCompose(
SKShader.CreateColor(reversedColors[0]),
SKShader.CreateTwoPointConicalGradient(center, radius, origin, 0, reversedColors, reversedStops, tileMode)
))
{
paintWrapper.Paint.Shader = shader;
}
} }
break; break;

4
src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs

@ -200,6 +200,10 @@ namespace Avalonia.Win32
DipFromLParam(lParam), GetMouseModifiers(wParam)); DipFromLParam(lParam), GetMouseModifiers(wParam));
break; break;
} }
// Mouse capture is lost
case WindowsMessage.WM_CANCELMODE:
_mouseDevice.Capture(null);
break;
case WindowsMessage.WM_MOUSEMOVE: case WindowsMessage.WM_MOUSEMOVE:
{ {

124
tests/Avalonia.RenderTests/Media/RadialGradientBrushTests.cs

@ -18,7 +18,7 @@ namespace Avalonia.Direct2D1.RenderTests.Media
public RadialGradientBrushTests() : base(@"Media\RadialGradientBrush") public RadialGradientBrushTests() : base(@"Media\RadialGradientBrush")
{ {
} }
[Fact] [Fact]
public async Task RadialGradientBrush_RedBlue() public async Task RadialGradientBrush_RedBlue()
{ {
@ -43,5 +43,127 @@ namespace Avalonia.Direct2D1.RenderTests.Media
await RenderToFile(target); await RenderToFile(target);
CompareImages(); CompareImages();
} }
/// <summary>
/// Tests using a GradientOrigin that falls inside of the circle described by Center/Radius.
/// </summary>
[Fact]
public async Task RadialGradientBrush_RedBlue_Offset_Inside()
{
Decorator target = new Decorator
{
Padding = new Thickness(8),
Width = 200,
Height = 200,
Child = new Border
{
Background = new RadialGradientBrush
{
GradientStops =
{
new GradientStop { Color = Colors.Red, Offset = 0 },
new GradientStop { Color = Colors.Blue, Offset = 1 }
},
GradientOrigin = new RelativePoint(0.25, 0.25, RelativeUnit.Relative)
}
}
};
await RenderToFile(target);
CompareImages();
}
/// <summary>
/// Tests using a GradientOrigin that falls outside of the circle described by Center/Radius.
/// </summary>
[Fact]
public async Task RadialGradientBrush_RedBlue_Offset_Outside()
{
Decorator target = new Decorator
{
Padding = new Thickness(8),
Width = 200,
Height = 200,
Child = new Border
{
Background = new RadialGradientBrush
{
GradientStops =
{
new GradientStop { Color = Colors.Red, Offset = 0 },
new GradientStop { Color = Colors.Blue, Offset = 1 }
},
GradientOrigin = new RelativePoint(0.1, 0.1, RelativeUnit.Relative)
}
}
};
await RenderToFile(target);
CompareImages();
}
/// <summary>
/// Tests using a GradientOrigin that falls inside of the circle described by Center/Radius.
/// </summary>
[Fact]
public async Task RadialGradientBrush_RedGreenBlue_Offset_Inside()
{
Decorator target = new Decorator
{
Padding = new Thickness(8),
Width = 200,
Height = 200,
Child = new Border
{
Background = new RadialGradientBrush
{
GradientStops =
{
new GradientStop { Color = Colors.Red, Offset = 0 },
new GradientStop { Color = Colors.Green, Offset = 0.5 },
new GradientStop { Color = Colors.Blue, Offset = 1 }
},
GradientOrigin = new RelativePoint(0.25, 0.25, RelativeUnit.Relative),
Center = new RelativePoint(0.5, 0.5, RelativeUnit.Relative),
Radius = 0.5
}
}
};
await RenderToFile(target);
CompareImages();
}
/// <summary>
/// Tests using a GradientOrigin that falls outside of the circle described by Center/Radius.
/// </summary>
[Fact]
public async Task RadialGradientBrush_RedGreenBlue_Offset_Outside()
{
Decorator target = new Decorator
{
Padding = new Thickness(8),
Width = 200,
Height = 200,
Child = new Border
{
Background = new RadialGradientBrush
{
GradientStops =
{
new GradientStop { Color = Colors.Red, Offset = 0 },
new GradientStop { Color = Colors.Green, Offset = 0.25 },
new GradientStop { Color = Colors.Blue, Offset = 1 }
},
GradientOrigin = new RelativePoint(0.1, 0.1, RelativeUnit.Relative),
Center = new RelativePoint(0.5, 0.5, RelativeUnit.Relative),
Radius = 0.5
}
}
};
await RenderToFile(target);
CompareImages();
}
} }
} }

BIN
tests/TestFiles/Direct2D1/Media/RadialGradientBrush/RadialGradientBrush_RedBlue_Offset_Inside.expected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

BIN
tests/TestFiles/Direct2D1/Media/RadialGradientBrush/RadialGradientBrush_RedBlue_Offset_Outside.expected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

BIN
tests/TestFiles/Direct2D1/Media/RadialGradientBrush/RadialGradientBrush_RedGreenBlue_Offset_Inside.expected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
tests/TestFiles/Direct2D1/Media/RadialGradientBrush/RadialGradientBrush_RedGreenBlue_Offset_Outside.expected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
tests/TestFiles/Skia/Media/RadialGradientBrush/RadialGradientBrush_RedBlue_Offset_Inside.expected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

BIN
tests/TestFiles/Skia/Media/RadialGradientBrush/RadialGradientBrush_RedBlue_Offset_Outside.expected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

BIN
tests/TestFiles/Skia/Media/RadialGradientBrush/RadialGradientBrush_RedGreenBlue_Offset_Inside.expected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
tests/TestFiles/Skia/Media/RadialGradientBrush/RadialGradientBrush_RedGreenBlue_Offset_Outside.expected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Loading…
Cancel
Save