Browse Source

Fix indeterminate animation on old theme

pull/4074/head
Jumar Macato 6 years ago
parent
commit
a0be18e3f6
No known key found for this signature in database GPG Key ID: B19884DAC3A5BF3F
  1. 42
      src/Avalonia.Controls/ProgressBar.cs
  2. 8
      src/Avalonia.Themes.Default/ProgressBar.xaml

42
src/Avalonia.Controls/ProgressBar.cs

@ -11,12 +11,14 @@ namespace Avalonia.Controls
{
public class ProgressBarTemplateProperties : AvaloniaObject
{
private double _Container2Width;
private double _ContainerWidth;
private double _container2Width;
private double _containerWidth;
private double _containerAnimationStartPosition;
private double _containerAnimationEndPosition;
private double _container2AnimationStartPosition;
private double _container2AnimationEndPosition;
private double _indeterminateStartingOffset;
private double _indeterminateEndingOffset;
public static readonly DirectProperty<ProgressBarTemplateProperties, double> ContainerAnimationStartPositionProperty =
AvaloniaProperty.RegisterDirect<ProgressBarTemplateProperties, double>(
@ -54,6 +56,18 @@ namespace Avalonia.Controls
p => p.ContainerWidth,
(p, o) => p.ContainerWidth = o);
public static readonly DirectProperty<ProgressBarTemplateProperties, double> IndeterminateStartingOffsetProperty =
AvaloniaProperty.RegisterDirect<ProgressBarTemplateProperties, double>(
nameof(IndeterminateStartingOffset),
p => p.IndeterminateStartingOffset,
(p, o) => p.IndeterminateStartingOffset = o);
public static readonly DirectProperty<ProgressBarTemplateProperties, double> IndeterminateEndingOffsetProperty =
AvaloniaProperty.RegisterDirect<ProgressBarTemplateProperties, double>(
nameof(IndeterminateEndingOffset),
p => p.IndeterminateEndingOffset,
(p, o) => p.IndeterminateEndingOffset = o);
public double ContainerAnimationStartPosition
{
get => _containerAnimationStartPosition;
@ -74,14 +88,14 @@ namespace Avalonia.Controls
public double Container2Width
{
get => _Container2Width;
set => SetAndRaise(Container2WidthProperty, ref _Container2Width, value);
get => _container2Width;
set => SetAndRaise(Container2WidthProperty, ref _container2Width, value);
}
public double ContainerWidth
{
get => _ContainerWidth;
set => SetAndRaise(ContainerWidthProperty, ref _ContainerWidth, value);
get => _containerWidth;
set => SetAndRaise(ContainerWidthProperty, ref _containerWidth, value);
}
public double Container2AnimationEndPosition
@ -89,6 +103,18 @@ namespace Avalonia.Controls
get => _container2AnimationEndPosition;
set => SetAndRaise(Container2AnimationEndPositionProperty, ref _container2AnimationEndPosition, value);
}
public double IndeterminateStartingOffset
{
get => _indeterminateStartingOffset;
set => SetAndRaise(IndeterminateStartingOffsetProperty, ref _indeterminateStartingOffset, value);
}
public double IndeterminateEndingOffset
{
get => _indeterminateEndingOffset;
set => SetAndRaise(IndeterminateEndingOffsetProperty, ref _indeterminateEndingOffset, value);
}
}
private Border _indicator;
@ -182,6 +208,10 @@ namespace Avalonia.Controls
TemplateProperties.Container2AnimationStartPosition = barIndicatorWidth2 * -1.5; // Position at -150%
TemplateProperties.Container2AnimationEndPosition = barIndicatorWidth2 * 1.66; // Position at 166%
// Remove these properties when we switch to fluent as default and removed the old one.
TemplateProperties.IndeterminateStartingOffset = -dim;
TemplateProperties.IndeterminateEndingOffset = dim * 2;
var padding = Padding;
var rectangle = new RectangleGeometry(

8
src/Avalonia.Themes.Default/ProgressBar.xaml

@ -61,11 +61,11 @@
Easing="LinearEasing">
<KeyFrame Cue="0%">
<Setter Property="TranslateTransform.X"
Value="{Binding ContainerAnimationStartPosition, RelativeSource={RelativeSource TemplatedParent}}" />
Value="{Binding TemplateProperties.IndeterminateStartingOffset, RelativeSource={RelativeSource TemplatedParent}}" />
</KeyFrame>
<KeyFrame Cue="100%">
<Setter Property="TranslateTransform.X"
Value="{Binding ContainerAnimationEndPosition, RelativeSource={RelativeSource TemplatedParent}}" />
Value="{Binding TemplateProperties.IndeterminateEndingOffset, RelativeSource={RelativeSource TemplatedParent}}" />
</KeyFrame>
</Animation>
</Style.Animations>
@ -77,11 +77,11 @@
Easing="LinearEasing">
<KeyFrame Cue="0%">
<Setter Property="TranslateTransform.Y"
Value="{Binding ContainerAnimationStartPosition, RelativeSource={RelativeSource TemplatedParent}}" />
Value="{Binding TemplateProperties.IndeterminateStartingOffset, RelativeSource={RelativeSource TemplatedParent}}" />
</KeyFrame>
<KeyFrame Cue="100%">
<Setter Property="TranslateTransform.Y"
Value="{Binding ContainerAnimationEndPosition, RelativeSource={RelativeSource TemplatedParent}}" />
Value="{Binding TemplateProperties.IndeterminateEndingOffset, RelativeSource={RelativeSource TemplatedParent}}" />
</KeyFrame>
</Animation>
</Style.Animations>

Loading…
Cancel
Save