Browse Source

PR comments

pull/1117/head
Eli Arbel 9 years ago
parent
commit
c434cb215a
  1. 18
      src/Avalonia.Controls/DrawingPresenter.cs
  2. 2
      src/Avalonia.Visuals/Matrix.cs
  3. 12
      src/Avalonia.Visuals/Media/DrawingGroup.cs
  4. 18
      src/Avalonia.Visuals/Media/PolylineGeometry.cs

18
src/Avalonia.Controls/DrawingPresenter.cs

@ -6,9 +6,18 @@ namespace Avalonia.Controls
{ {
public class DrawingPresenter : Control public class DrawingPresenter : Control
{ {
static DrawingPresenter()
{
AffectsMeasure(DrawingProperty);
AffectsRender(DrawingProperty);
}
public static readonly StyledProperty<Drawing> DrawingProperty = public static readonly StyledProperty<Drawing> DrawingProperty =
AvaloniaProperty.Register<DrawingPresenter, Drawing>(nameof(Drawing)); AvaloniaProperty.Register<DrawingPresenter, Drawing>(nameof(Drawing));
public static readonly StyledProperty<Stretch> StretchProperty =
AvaloniaProperty.Register<DrawingPresenter, Stretch>(nameof(Stretch), Stretch.Uniform);
[Content] [Content]
public Drawing Drawing public Drawing Drawing
{ {
@ -16,21 +25,12 @@ namespace Avalonia.Controls
set => SetValue(DrawingProperty, value); set => SetValue(DrawingProperty, value);
} }
public static readonly StyledProperty<Stretch> StretchProperty =
AvaloniaProperty.Register<DrawingPresenter, Stretch>(nameof(Stretch), Stretch.Uniform);
public Stretch Stretch public Stretch Stretch
{ {
get => GetValue(StretchProperty); get => GetValue(StretchProperty);
set => SetValue(StretchProperty, value); set => SetValue(StretchProperty, value);
} }
static DrawingPresenter()
{
AffectsMeasure(DrawingProperty);
AffectsRender(DrawingProperty);
}
private Matrix _transform = Matrix.Identity; private Matrix _transform = Matrix.Identity;
protected override Size MeasureOverride(Size availableSize) protected override Size MeasureOverride(Size availableSize)

2
src/Avalonia.Visuals/Matrix.cs

@ -302,7 +302,7 @@ namespace Avalonia
/// </summary> /// </summary>
/// <param name="s">The string.</param> /// <param name="s">The string.</param>
/// <param name="culture">The current culture.</param> /// <param name="culture">The current culture.</param>
/// <returns>The <see cref="Thickness"/>.</returns> /// <returns>The <see cref="Matrix"/>.</returns>
public static Matrix Parse(string s, CultureInfo culture) public static Matrix Parse(string s, CultureInfo culture)
{ {
var parts = s.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries) var parts = s.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries)

12
src/Avalonia.Visuals/Media/DrawingGroup.cs

@ -5,27 +5,27 @@ namespace Avalonia.Media
{ {
public class DrawingGroup : Drawing public class DrawingGroup : Drawing
{ {
[Content]
public AvaloniaList<Drawing> Children { get; } = new AvaloniaList<Drawing>();
public static readonly StyledProperty<double> OpacityProperty = public static readonly StyledProperty<double> OpacityProperty =
AvaloniaProperty.Register<DrawingGroup, double>(nameof(Opacity), 1); AvaloniaProperty.Register<DrawingGroup, double>(nameof(Opacity), 1);
public static readonly StyledProperty<Transform> TransformProperty =
AvaloniaProperty.Register<DrawingGroup, Transform>(nameof(Transform));
public double Opacity public double Opacity
{ {
get => GetValue(OpacityProperty); get => GetValue(OpacityProperty);
set => SetValue(OpacityProperty, value); set => SetValue(OpacityProperty, value);
} }
public static readonly StyledProperty<Transform> TransformProperty =
AvaloniaProperty.Register<DrawingGroup, Transform>(nameof(Transform));
public Transform Transform public Transform Transform
{ {
get => GetValue(TransformProperty); get => GetValue(TransformProperty);
set => SetValue(TransformProperty, value); set => SetValue(TransformProperty, value);
} }
[Content]
public AvaloniaList<Drawing> Children { get; } = new AvaloniaList<Drawing>();
public override void Draw(DrawingContext context) public override void Draw(DrawingContext context)
{ {
using (context.PushPreTransform(Transform?.Value ?? Matrix.Identity)) using (context.PushPreTransform(Transform?.Value ?? Matrix.Identity))

18
src/Avalonia.Visuals/Media/PolylineGeometry.cs

@ -26,13 +26,15 @@ namespace Avalonia.Media
public static readonly AvaloniaProperty<bool> IsFilledProperty = public static readonly AvaloniaProperty<bool> IsFilledProperty =
AvaloniaProperty.Register<PolylineGeometry, bool>(nameof(IsFilled)); AvaloniaProperty.Register<PolylineGeometry, bool>(nameof(IsFilled));
private Points _points;
private bool _isDirty;
private IDisposable _pointsObserver;
static PolylineGeometry() static PolylineGeometry()
{ {
PointsProperty.Changed.Subscribe(onNext: v => PointsProperty.Changed.AddClassHandler<PolylineGeometry>((s, e) =>
{ s.OnPointsChanged(e.OldValue as Points, e.NewValue as Points));
(v.Sender as PolylineGeometry)?.OnPointsChanged(v.OldValue as Points, v.NewValue as Points); IsFilledProperty.Changed.AddClassHandler<PolylineGeometry>((s, _) => s.NotifyChanged());
});
IsFilledProperty.Changed.AddClassHandler<PolylineGeometry>(x => a => x.NotifyChanged());
} }
/// <summary> /// <summary>
@ -53,8 +55,6 @@ namespace Avalonia.Media
{ {
Points.AddRange(points); Points.AddRange(points);
IsFilled = isFilled; IsFilled = isFilled;
PrepareIfNeeded();
} }
public void PrepareIfNeeded() public void PrepareIfNeeded()
@ -109,10 +109,6 @@ namespace Avalonia.Media
protected set => base.PlatformImpl = value; protected set => base.PlatformImpl = value;
} }
private Points _points;
private bool _isDirty;
private IDisposable _pointsObserver;
/// <inheritdoc/> /// <inheritdoc/>
public override Geometry Clone() public override Geometry Clone()
{ {

Loading…
Cancel
Save