Browse Source

Minor fixes.

pull/1461/head
Jumar Macato 9 years ago
parent
commit
c828437239
  1. 14
      samples/ControlCatalog/SideBar.xaml
  2. 2
      samples/RenderTest/MainWindow.xaml
  3. 8
      samples/RenderTest/Pages/AnimationsPage.xaml
  4. 14
      src/Avalonia.Styling/Styling/Style.cs
  5. 51
      src/Avalonia.Visuals/Animation/Keyframes/TransformKeyFrames.cs

14
samples/ControlCatalog/SideBar.xaml

@ -1,4 +1,5 @@
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
<Style Selector="TabControl.sidebar">
<Setter Property="Template">
<ControlTemplate>
@ -32,9 +33,20 @@
<Setter Property="FontSize" Value="14"/>
<Setter Property="Margin" Value="0"/>
<Setter Property="Padding" Value="16"/>
<Setter Property="Opacity" Value="0.5"/>
<Setter Property="Transitions">
<Transitions>
<DoubleTransition Property="Opacity" Duration="0:0:0.5"/>
</Transitions>
</Setter>
</Style>
<Style Selector="TabControl.sidebar TabStripItem:pointerover">
<Setter Property="Opacity" Value="1"/>
</Style>
<Style Selector="TabControl.sidebar TabStripItem:selected">
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush2}"/>
<Setter Property="Opacity" Value="1"/>
</Style>
</Styles>

2
samples/RenderTest/MainWindow.xaml

@ -1,6 +1,6 @@
<Window xmlns="https://github.com/avaloniaui"
Title="Avalonia Render Test"
xmlns:pages="clr-namespace:RenderTest.Pages;assembly=RenderTest" MinWidth="400" MinHeight="200"
xmlns:pages="clr-namespace:RenderTest.Pages;assembly=RenderTest" MinWidth="900" MinHeight="600"
>
<DockPanel>
<Menu DockPanel.Dock="Top">

8
samples/RenderTest/Pages/AnimationsPage.xaml

@ -1,7 +1,6 @@
<UserControl xmlns="https://github.com/avaloniaui">
<Grid>
<Grid.Styles>
<Styles>
<UserControl.Styles>
<Styles>
<Style Selector="Rectangle.Test">
<Setter Property="Margin" Value="15"/>
<Setter Property="Width" Value="100"/>
@ -55,7 +54,8 @@
</Style.Animations>
</Style>
</Styles>
</Grid.Styles>
</UserControl.Styles>
<Grid>
<StackPanel VerticalAlignment="Center"
HorizontalAlignment="Center"
ClipToBounds="False">

14
src/Avalonia.Styling/Styling/Style.cs

@ -8,6 +8,7 @@ using System.Reactive.Linq;
using Avalonia.Controls;
using Avalonia.Metadata;
using Avalonia.Animation;
using System.Diagnostics;
namespace Avalonia.Styling
{
@ -117,7 +118,18 @@ namespace Avalonia.Styling
foreach (var animation in Animations)
{
subs.Add(animation.Apply((Animatable)control, match.ObservableResult));
// TODO: Needs more work in passing the appropriate
// observable.
IObservable<bool> obsMatch = match.ObservableResult;
if (match.ImmediateResult == true)
{
obsMatch = Observable.Return(true);
}
var sub = animation.Apply((Animatable)control, obsMatch);
subs.Add(sub);
}
foreach (var setter in Setters)

51
src/Avalonia.Visuals/Animation/Keyframes/TransformKeyFrames.cs

@ -16,7 +16,7 @@ namespace Avalonia.Animation.Keyframes
public class TransformKeyFrames : KeyFrames<double>
{
DoubleKeyFrames childKeyFrames;
/// <inheritdoc/>
public override IDisposable Apply(Animation animation, Animatable control, IObservable<bool> obsMatch)
{
@ -27,45 +27,52 @@ namespace Avalonia.Animation.Keyframes
{
var renderTransformType = ctrl.RenderTransform.GetType();
if (childKeyFrames == null)
{
InitializeInternalDoubleKeyFrames();
}
// It's only 1 transform object so let's target that.
if (renderTransformType == Property.OwnerType)
{
var targetTransform = Convert.ChangeType(ctrl.RenderTransform, Property.OwnerType);
if (childKeyFrames == null)
{
childKeyFrames = new DoubleKeyFrames();
foreach (KeyFrame k in this)
{
childKeyFrames.Add(k);
}
childKeyFrames.Property = Property;
}
return childKeyFrames.Apply(animation, ctrl.RenderTransform, obsMatch);
}
// TODO: Selection within TransformGroup is not working
if (renderTransformType == typeof(TransformGroup))
{
foreach (Transform t in ((TransformGroup)ctrl.RenderTransform).Children)
foreach (Transform transform in ((TransformGroup)ctrl.RenderTransform).Children)
{
if (renderTransformType == Property.OwnerType)
if (transform.GetType() == Property.OwnerType)
{
return childKeyFrames.Apply(animation, transform, obsMatch);
}
}
}
return null;
// // Throw exception when there is no appropriate transform object found.
// throw new Exception
// ($"TransformKeyFrame hasn't found an appropriate Transform object with type {Property.OwnerType} in target {control}.");
// not existing in the transform
}
}
else
{
throw new InvalidProgramException($"Unsupported property {Property}");
throw new Exception($"Unsupported property {Property}");
}
}
void InitializeInternalDoubleKeyFrames()
{
childKeyFrames = new DoubleKeyFrames();
foreach (KeyFrame keyframe in this)
{
childKeyFrames.Add(keyframe);
}
return null;
childKeyFrames.Property = Property;
}
/// <inheritdocs/>

Loading…
Cancel
Save