mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Implemented layer element saving
Added a working setting to the brush element
This commit is contained in:
1 parent
275d2b32a6
commit
1a44e34d16
24 files changed
+440
-85
No files matched your search
@@ -113,6 +113,7 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>echo Copying plugin to Artemis.UI output directory
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Models.Surface;
|
||||
using Artemis.Core.Plugins.LayerElement;
|
||||
@@ -11,9 +13,9 @@ namespace Artemis.Plugins.LayerElements.Brush
|
||||
private SKShader _shader;
|
||||
private List<SKColor> _testColors;
|
||||
|
||||
public BrushLayerElement(Layer layer, BrushLayerElementSettings settings, LayerElementDescriptor descriptor) : base(layer, settings, descriptor)
|
||||
public BrushLayerElement(Layer layer, Guid guid, BrushLayerElementSettings settings, LayerElementDescriptor descriptor) : base(layer, guid, settings, descriptor)
|
||||
{
|
||||
Settings = settings ?? new BrushLayerElementSettings();
|
||||
Settings = settings;
|
||||
|
||||
_testColors = new List<SKColor>();
|
||||
for (var i = 0; i < 9; i++)
|
||||
@@ -26,13 +28,31 @@ namespace Artemis.Plugins.LayerElements.Brush
|
||||
|
||||
CreateShader();
|
||||
Layer.RenderPropertiesUpdated += (sender, args) => CreateShader();
|
||||
Settings.PropertyChanged += (sender, args) => CreateShader();
|
||||
}
|
||||
|
||||
private void CreateShader()
|
||||
{
|
||||
var center = new SKPoint(Layer.AbsoluteRenderRectangle.MidX, Layer.AbsoluteRenderRectangle.MidY);
|
||||
var shader = SKShader.CreateSweepGradient(center, _testColors.ToArray(), null, SKShaderTileMode.Clamp, 0, 360);
|
||||
|
||||
SKShader shader;
|
||||
switch (Settings.BrushType)
|
||||
{
|
||||
case BrushType.Solid:
|
||||
shader = SKShader.CreateColor(_testColors.First());
|
||||
break;
|
||||
case BrushType.LinearGradient:
|
||||
shader = SKShader.CreateLinearGradient(new SKPoint(0, 0), new SKPoint(Layer.AbsoluteRenderRectangle.Width, 0), _testColors.ToArray(), SKShaderTileMode.Clamp);
|
||||
break;
|
||||
case BrushType.RadialGradient:
|
||||
shader = SKShader.CreateRadialGradient(center, Math.Min(Layer.AbsoluteRenderRectangle.Width, Layer.AbsoluteRenderRectangle.Height), _testColors.ToArray(), SKShaderTileMode.Clamp);
|
||||
break;
|
||||
case BrushType.SweepGradient:
|
||||
shader = SKShader.CreateSweepGradient(center, _testColors.ToArray(), null, SKShaderTileMode.Clamp, 0, 360);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
var oldShader = _shader;
|
||||
_shader = shader;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using Artemis.Core.Plugins.LayerElement;
|
||||
using SkiaSharp;
|
||||
|
||||
@@ -6,11 +7,40 @@ namespace Artemis.Plugins.LayerElements.Brush
|
||||
{
|
||||
public class BrushLayerElementSettings : LayerElementSettings
|
||||
{
|
||||
private BrushType _brushType;
|
||||
private List<SKColor> _colors;
|
||||
|
||||
public BrushLayerElementSettings()
|
||||
{
|
||||
BrushType = BrushType.Solid;
|
||||
Colors = new List<SKColor>();
|
||||
}
|
||||
|
||||
public List<SKColor> Colors { get; set; }
|
||||
public BrushType BrushType
|
||||
{
|
||||
get => _brushType;
|
||||
set => SetAndNotify(ref _brushType, value);
|
||||
}
|
||||
|
||||
public List<SKColor> Colors
|
||||
{
|
||||
get => _colors;
|
||||
set => SetAndNotify(ref _colors, value);
|
||||
}
|
||||
}
|
||||
|
||||
public enum BrushType
|
||||
{
|
||||
[Description("Solid")]
|
||||
Solid,
|
||||
|
||||
[Description("Linear Gradient")]
|
||||
LinearGradient,
|
||||
|
||||
[Description("Radial Gradient")]
|
||||
RadialGradient,
|
||||
|
||||
[Description("Sweep Gradient")]
|
||||
SweepGradient
|
||||
}
|
||||
}
|
||||
@@ -20,35 +20,116 @@
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid Margin="12">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Setting 1 -->
|
||||
<StackPanel Grid.Row="0" Grid.Column="0">
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">Setting title</TextBlock>
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}" Foreground="{DynamicResource MaterialDesignCheckBoxDisabled}">Setting subtitle</TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
||||
<ToggleButton Style="{StaticResource MaterialDesignSwitchToggleButton}" ToolTip="Default ToggleButton Style" />
|
||||
</StackPanel>
|
||||
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
|
||||
<!-- Brush type -->
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0" VerticalAlignment="Center">
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">Brush type</TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
||||
<ComboBox HorizontalAlignment="Left"
|
||||
ItemsSource="{Binding Path=BrushTypes}"
|
||||
SelectedValuePath="Value"
|
||||
DisplayMemberPath="Description"
|
||||
SelectedValue="{Binding Path=LayerElement.Settings.BrushType}" />
|
||||
</StackPanel>
|
||||
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
|
||||
</Grid>
|
||||
|
||||
<!-- Sample 1 -->
|
||||
<Grid Grid.Row="2">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0">
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">Setting title</TextBlock>
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}" Foreground="{DynamicResource MaterialDesignCheckBoxDisabled}">Setting subtitle</TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
||||
<ToggleButton Style="{StaticResource MaterialDesignSwitchToggleButton}" ToolTip="Default ToggleButton Style" />
|
||||
</StackPanel>
|
||||
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
|
||||
</Grid>
|
||||
|
||||
<!-- Sample 1 -->
|
||||
<Grid Grid.Row="3">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0">
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">Setting title</TextBlock>
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}" Foreground="{DynamicResource MaterialDesignCheckBoxDisabled}">Setting subtitle</TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
||||
<ToggleButton Style="{StaticResource MaterialDesignSwitchToggleButton}" ToolTip="Default ToggleButton Style" />
|
||||
</StackPanel>
|
||||
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
|
||||
</Grid>
|
||||
|
||||
<!-- Setting 2 -->
|
||||
<StackPanel Grid.Row="2" Grid.Column="0">
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">Setting title</TextBlock>
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}" Foreground="{DynamicResource MaterialDesignCheckBoxDisabled}">Setting subtitle</TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="2" Grid.Column="1" VerticalAlignment="Center">
|
||||
<ToggleButton Style="{StaticResource MaterialDesignSwitchToggleButton}" ToolTip="Default ToggleButton Style" />
|
||||
</StackPanel>
|
||||
<Separator Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignLightSeparator}" />
|
||||
<Grid Grid.Row="4">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0">
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">Setting title</TextBlock>
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}" Foreground="{DynamicResource MaterialDesignCheckBoxDisabled}">Setting subtitle</TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
||||
<ToggleButton Style="{StaticResource MaterialDesignSwitchToggleButton}" ToolTip="Default ToggleButton Style" />
|
||||
</StackPanel>
|
||||
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
|
||||
</Grid>
|
||||
|
||||
<!-- Setting 2 -->
|
||||
<Grid Grid.Row="5">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0">
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">Setting title</TextBlock>
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}" Foreground="{DynamicResource MaterialDesignCheckBoxDisabled}">Setting subtitle</TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
||||
<ToggleButton Style="{StaticResource MaterialDesignSwitchToggleButton}" ToolTip="Default ToggleButton Style" />
|
||||
</StackPanel>
|
||||
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -1,4 +1,6 @@
|
||||
using Artemis.Core.Plugins.LayerElement;
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Core.Plugins.LayerElement;
|
||||
using Artemis.Core.Utilities;
|
||||
|
||||
namespace Artemis.Plugins.LayerElements.Brush
|
||||
{
|
||||
@@ -10,5 +12,6 @@ namespace Artemis.Plugins.LayerElements.Brush
|
||||
}
|
||||
|
||||
public new BrushLayerElement LayerElement { get; }
|
||||
public IEnumerable<ValueDescription> BrushTypes => EnumUtilities.GetAllValuesAndDescriptions(typeof(BrushType));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user