Skip to content

Commit

Permalink
mostly fix animation editor
Browse files Browse the repository at this point in the history
  • Loading branch information
Aytackydln committed Jul 24, 2024
1 parent 0cfd01a commit a6965f3
Show file tree
Hide file tree
Showing 13 changed files with 1,253 additions and 1,241 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System.Windows.Controls;
using AuroraRgb.EffectsEngine.Animations;

namespace AuroraRgb.Controls;

public partial class Control_AnimationEditor
{
private void CreateCircle(AnimationCircle circle, StackPanel newPanel, double separatorHeight)
{
var varItemColor = new Control_VariableItem
{
VariableTitle = "Color",
VariableObject = circle.Color
};
varItemColor.VariableUpdated += VarItemColor_VariableUpdated;
var varItemWidth = new Control_VariableItem
{
VariableTitle = "Width",
VariableObject = circle.Width
};
varItemWidth.VariableUpdated += VarItemWidth_VariableUpdated;
var varItemCenterX = new Control_VariableItem
{
VariableTitle = "Center X",
VariableObject = circle.Center.X
};
varItemCenterX.VariableUpdated += VarItemCenterX_VariableUpdated;
var varItemCenterY = new Control_VariableItem
{
VariableTitle = "Center Y",
VariableObject = circle.Center.Y
};
varItemCenterY.VariableUpdated += VarItemCenterY_VariableUpdated;
var varItemDimensionRadius = new Control_VariableItem
{
VariableTitle = "Radius",
VariableObject = circle.Radius
};
varItemDimensionRadius.VariableUpdated += VarItemDimensionRadius_VariableUpdated;

newPanel.Children.Add(varItemColor);
newPanel.Children.Add(new Separator { Height = separatorHeight, Opacity = 0 });
if (circle is not AnimationFilledCircle)
{
newPanel.Children.Add(varItemWidth);
newPanel.Children.Add(new Separator { Height = separatorHeight, Opacity = 0 });
}

newPanel.Children.Add(varItemCenterX);
newPanel.Children.Add(new Separator { Height = separatorHeight, Opacity = 0 });
newPanel.Children.Add(varItemCenterY);
newPanel.Children.Add(new Separator { Height = separatorHeight, Opacity = 0 });
newPanel.Children.Add(varItemDimensionRadius);
newPanel.Children.Add(new Separator { Height = separatorHeight, Opacity = 0 });
}

private void VarItemDimensionRadius_VariableUpdated(object? sender, object? newVariable)
{
if (_selectedFrameItem is Control_AnimationFrameItem { ContextFrame: AnimationCircle animationCircle } frameItem)
frameItem.ContextFrame = animationCircle.SetRadius((float)newVariable);
}

private void VarItemCenterY_VariableUpdated(object? sender, object? newVariable)
{
if (_selectedFrameItem is Control_AnimationFrameItem { ContextFrame: AnimationCircle animationCircle } frameItem)
frameItem.ContextFrame = animationCircle.SetCenter(animationCircle.Center with { Y = (float)newVariable });
}

private void VarItemCenterX_VariableUpdated(object? sender, object? newVariable)
{
if (_selectedFrameItem is Control_AnimationFrameItem { ContextFrame: AnimationCircle animationCircle } item)
item.ContextFrame = animationCircle.SetCenter(animationCircle.Center with { X = (float)newVariable });
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
using System.Drawing;
using System.Windows.Controls;
using AuroraRgb.EffectsEngine.Animations;

namespace AuroraRgb.Controls;

public partial class Control_AnimationEditor
{
private void CreateLine(AnimationLine line, StackPanel newPanel, double separatorHeight)
{
var varItemColor = new Control_VariableItem
{
VariableTitle = "Start Color",
VariableObject = line.Color
};
varItemColor.VariableUpdated += VarItemColor_VariableUpdated;
var varItemEndColor = new Control_VariableItem
{
VariableTitle = "End Color",
VariableObject = line.EndColor
};
varItemEndColor.VariableUpdated += VarItemEndColor_VariableUpdated;
var varItemWidth = new Control_VariableItem
{
VariableTitle = "Width",
VariableObject = line.Width
};
varItemWidth.VariableUpdated += VarItemWidth_VariableUpdated;
var varItemStartPositionX = new Control_VariableItem
{
VariableTitle = "Start Position X",
VariableObject = line.StartPoint.X
};
varItemStartPositionX.VariableUpdated += VarItemStartPositionX_VariableUpdated;
varItemWidth.VariableUpdated += VarItemWidth_VariableUpdated;
var varItemStartPositionY = new Control_VariableItem
{
VariableTitle = "Start Position Y",
VariableObject = line.StartPoint.Y
};
varItemStartPositionY.VariableUpdated += VarItemStartPositionY_VariableUpdated;
var varItemEndPositionX = new Control_VariableItem
{
VariableTitle = "End Position X",
VariableObject = line.EndPoint.X
};
varItemEndPositionX.VariableUpdated += VarItemEndPositionX_VariableUpdated;
varItemWidth.VariableUpdated += VarItemWidth_VariableUpdated;
var varItemEndPositionY = new Control_VariableItem
{
VariableTitle = "End Position Y",
VariableObject = line.EndPoint.Y
};
varItemEndPositionY.VariableUpdated += VarItemEndPositionY_VariableUpdated;


newPanel.Children.Add(varItemColor);
newPanel.Children.Add(new Separator { Height = separatorHeight, Opacity = 0 });
newPanel.Children.Add(varItemEndColor);
newPanel.Children.Add(new Separator { Height = separatorHeight, Opacity = 0 });
newPanel.Children.Add(varItemWidth);
newPanel.Children.Add(new Separator { Height = separatorHeight, Opacity = 0 });
newPanel.Children.Add(varItemStartPositionX);
newPanel.Children.Add(new Separator { Height = separatorHeight, Opacity = 0 });
newPanel.Children.Add(varItemStartPositionY);
newPanel.Children.Add(new Separator { Height = separatorHeight, Opacity = 0 });
newPanel.Children.Add(varItemEndPositionX);
newPanel.Children.Add(new Separator { Height = separatorHeight, Opacity = 0 });
newPanel.Children.Add(varItemEndPositionY);
newPanel.Children.Add(new Separator { Height = separatorHeight, Opacity = 0 });
}

private void VarItemEndColor_VariableUpdated(object? sender, object? newVariable)
{
if (_selectedFrameItem is Control_AnimationFrameItem { ContextFrame: AnimationLine animationLine } frameItem)
frameItem.ContextFrame = animationLine.SetEndColor((Color)newVariable);
}

private void VarItemEndPositionY_VariableUpdated(object? sender, object? newVariable)
{
if (_selectedFrameItem is Control_AnimationFrameItem { ContextFrame: AnimationLine animationLine } frameItem)
frameItem.ContextFrame = animationLine.SetEndPoint(animationLine.EndPoint with { Y = (float)newVariable });
}

private void VarItemEndPositionX_VariableUpdated(object? sender, object? newVariable)
{
if (_selectedFrameItem is Control_AnimationFrameItem { ContextFrame: AnimationLine animationLine } frameItem)
frameItem.ContextFrame = animationLine.SetEndPoint(animationLine.EndPoint with { X = (float)newVariable });
}

private void VarItemStartPositionY_VariableUpdated(object? sender, object? newVariable)
{
if (_selectedFrameItem is Control_AnimationFrameItem { ContextFrame: AnimationLine animationLine } frameItem)
frameItem.ContextFrame = animationLine.SetStartPoint(animationLine.StartPoint with { Y = (float)newVariable });
}

private void VarItemStartPositionX_VariableUpdated(object? sender, object? newVariable)
{
if (_selectedFrameItem is Control_AnimationFrameItem { ContextFrame: AnimationLine animationLine } frameItem)
frameItem.ContextFrame = animationLine.SetStartPoint(animationLine.StartPoint with { X = (float)newVariable });
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
using System.Windows.Controls;
using AuroraRgb.EffectsEngine.Animations;

namespace AuroraRgb.Controls;

public partial class Control_AnimationEditor
{
private void CreateRectangle(AnimationRectangle rectangle, StackPanel newPanel, double separatorHeight)
{
var varItemColor = new Control_VariableItem
{
VariableTitle = "Color",
VariableObject = rectangle.Color
};
varItemColor.VariableUpdated += VarItemColor_VariableUpdated;
var varItemWidth = new Control_VariableItem
{
VariableTitle = "Width",
VariableObject = rectangle.Width
};
varItemWidth.VariableUpdated += VarItemWidth_VariableUpdated;
var varItemPositionX = new Control_VariableItem
{
VariableTitle = "Position X",
VariableObject = rectangle.Dimension.X
};
varItemPositionX.VariableUpdated += VarItemPositionX_VariableUpdated;
var varItemPositionY = new Control_VariableItem
{
VariableTitle = "Position Y",
VariableObject = rectangle.Dimension.Y
};
varItemPositionY.VariableUpdated += VarItemPositionY_VariableUpdated;
var varItemDimensionWidth = new Control_VariableItem
{
VariableTitle = "Width",
VariableObject = rectangle.Dimension.Width
};
varItemDimensionWidth.VariableUpdated += VarItemDimensionWidth_VariableUpdated;
var varItemDimensionHeight = new Control_VariableItem
{
VariableTitle = "Height",
VariableObject = rectangle.Dimension.Height
};
varItemDimensionHeight.VariableUpdated += VarItemDimensionHeight_VariableUpdated;


newPanel.Children.Add(varItemColor);
newPanel.Children.Add(new Separator { Height = separatorHeight, Opacity = 0 });
if (rectangle is not AnimationFilledRectangle)
{
newPanel.Children.Add(varItemWidth);
newPanel.Children.Add(new Separator { Height = separatorHeight, Opacity = 0 });
}

newPanel.Children.Add(varItemPositionX);
newPanel.Children.Add(new Separator { Height = separatorHeight, Opacity = 0 });
newPanel.Children.Add(varItemPositionY);
newPanel.Children.Add(new Separator { Height = separatorHeight, Opacity = 0 });
newPanel.Children.Add(varItemDimensionWidth);
newPanel.Children.Add(new Separator { Height = separatorHeight, Opacity = 0 });
newPanel.Children.Add(varItemDimensionHeight);
newPanel.Children.Add(new Separator { Height = separatorHeight, Opacity = 0 });
}

private void VarItemDimensionHeight_VariableUpdated(object? sender, object? newVariable)
{
if (_selectedFrameItem is not Control_AnimationFrameItem { ContextFrame: AnimationRectangle animationRectangle } frameItem) return;
var frameType = animationRectangle.GetType();

if (frameType == typeof(AnimationRectangle) || frameType == typeof(AnimationFilledRectangle))
{
frameItem.ContextFrame = animationRectangle.SetDimension(animationRectangle.Dimension with { Height = (float)newVariable });
}
else
{
frameItem.ContextFrame = frameItem.ContextFrame.SetDimension(frameItem.ContextFrame.Dimension with { Height = (float)newVariable });
}
}

private void VarItemDimensionWidth_VariableUpdated(object? sender, object? newVariable)
{
if (_selectedFrameItem is not Control_AnimationFrameItem frameItem) return;
var frameType = frameItem.ContextFrame?.GetType();

if (frameType == typeof(AnimationRectangle) || frameType == typeof(AnimationFilledRectangle))
{
var frame = frameItem.ContextFrame as AnimationRectangle;

frameItem.ContextFrame = frame?.SetDimension(frame.Dimension with { Width = (float)newVariable });
}
else
{
frameItem.ContextFrame = frameItem.ContextFrame?.SetDimension(frameItem.ContextFrame.Dimension with { Width = (float)newVariable });
}
}

private void VarItemPositionY_VariableUpdated(object? sender, object? newVariable)
{
if (_selectedFrameItem is not Control_AnimationFrameItem frameItem) return;
var frameType = frameItem.ContextFrame?.GetType();

if (frameType == typeof(AnimationRectangle) || frameType == typeof(AnimationFilledRectangle))
{
var frame = frameItem.ContextFrame as AnimationRectangle;

frameItem.ContextFrame = frame?.SetDimension(frame.Dimension with { Y = (float)newVariable });
}
else
{
frameItem.ContextFrame = frameItem.ContextFrame?.SetDimension(frameItem.ContextFrame.Dimension with { Y = (float)newVariable });
}
}

private void VarItemPositionX_VariableUpdated(object? sender, object? newVariable)
{
if (_selectedFrameItem is not Control_AnimationFrameItem frameItem) return;
var frameType = frameItem.ContextFrame?.GetType();

if (frameType == typeof(AnimationRectangle) || frameType == typeof(AnimationFilledRectangle))
{
var frame = frameItem.ContextFrame as AnimationRectangle;

frameItem.ContextFrame = frame?.SetDimension(frame.Dimension with { X = (float)newVariable });
}
else
{
frameItem.ContextFrame = frameItem.ContextFrame?.SetDimension(frameItem.ContextFrame.Dimension with { X = (float)newVariable });
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:controls="clr-namespace:AuroraRgb.Controls"
mc:Ignorable="d"
d:DesignHeight="414" d:DesignWidth="535" Loaded="UserControl_Loaded" PreviewKeyDown="UserControl_PreviewKeyDown">
d:DesignHeight="454" d:DesignWidth="635" PreviewKeyDown="UserControl_PreviewKeyDown">
<Grid>
<DockPanel LastChildFill="True">
<Grid DockPanel.Dock="Top">
<DockPanel>
<GroupBox x:Name="grpbxProperties" Header="Properties" BorderThickness="1" Margin="0,0,2,0" Width="200" MinWidth="200" DockPanel.Dock="Right"/>
<Viewbox x:Name="viewbxAnimationView" StretchDirection="Both" Margin="0,0,7,0" >
<GroupBox x:Name="PropertiesGrpbx" Header="Properties" BorderThickness="1" Margin="0,0,2,0" Width="200" MinWidth="200" DockPanel.Dock="Right"/>
<Viewbox x:Name="AnimationView" StretchDirection="Both" Margin="0,0,7,0" >
<Border Margin="5,10,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Background="#A51E1E1E" CornerRadius="8" MinWidth="650" MinHeight="216">
<Grid>
<Rectangle Margin="0" Width="15" Height="15" HorizontalAlignment="Left" VerticalAlignment="Top" Fill="White"/>
<controls:Control_Ruler x:Name="rulerHorizontalPixels" Height="15" Margin="15,0,0,0" Background="White" VerticalAlignment="Top" Foreground="Black" />
<controls:Control_Ruler x:Name="rulerVerticalPixels" Width="15" Margin="0,15,0,0" Background="White" IsVertical="True" HorizontalAlignment="Left" Foreground="Black" />
<Image x:Name="keyboard_overlayPreview" RenderOptions.BitmapScalingMode="HighQuality" SizeChanged="keyboard_overlayPreview_SizeChanged" Margin="15,15,0,0" Stretch="Fill" />
<Grid x:Name="keyboard_grid" Margin="15,15,0,0" Opacity="0.8">
<controls:Control_Ruler x:Name="HorizontalPixelsRuler" Height="15" Margin="15,0,0,0" Background="White" VerticalAlignment="Top" Foreground="Black" />
<controls:Control_Ruler x:Name="VerticalPixelsRuler" Width="15" Margin="0,15,0,0" Background="White" IsVertical="True" HorizontalAlignment="Left" Foreground="Black" />
<Image x:Name="KeyboardOverlayPreview" RenderOptions.BitmapScalingMode="HighQuality" SizeChanged="keyboard_overlayPreview_SizeChanged" Margin="15,15,0,0" Stretch="Fill" />
<Grid x:Name="KeyboardGrid" Margin="15,15,0,0" Opacity="0.8">
<Grid.CacheMode>
<BitmapCache EnableClearType="True"/>
</Grid.CacheMode>
Expand All @@ -28,7 +28,8 @@
</Viewbox>
</DockPanel>
</Grid>
<controls:Control_AnimationMixPresenter x:Name="animMixer" DockPanel.Dock="Bottom" AnimationMixRendered="animMixer_AnimationMixRendered" AnimationFrameItemSelected="animMixer_AnimationFrameItemSelected" AnimationMixUpdated="animMixer_AnimationMixUpdated" />
<controls:Control_AnimationMixPresenter x:Name="AnimMixer" DockPanel.Dock="Bottom" AnimationMixRendered="animMixer_AnimationMixRendered"
AnimationFrameItemSelected="animMixer_AnimationFrameItemSelected" AnimationMixUpdated="animMixer_AnimationMixUpdated" />
</DockPanel>
</Grid>
</UserControl>
Loading

0 comments on commit a6965f3

Please sign in to comment.